Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
Ok, so this is probably quite simple, but it's frustrating the heck out of me!
This is A.jpg
(Please try to keep response simple).
Code: (Select All) Screen _NewImage(1000, 800, 256)
Print "Why is line 8 returning Illegal function call?"
Sleep 2
h = 200: v = 200 ' horiz and vert position for pic
ReDim pic(4) As Long
im(1) = _LoadImage("RecPics/" + Chr$(65) + ".jpg")
Print: Print "im(1) is"; im(1); " (if less than -1, this handle should be ok)"
_PutImage (h, v), im(1)
Sleep
_FreeImage (im(1))
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
Try this:
Screen _NewImage(1000, 800, 32) ' <<<< not 256
b = b + ...
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
(03-09-2023, 07:56 AM)bplus Wrote: Try this:
Screen _NewImage(1000, 800, 32) ' <<<< not 256
Thanks bplus. I knew you'd come through! It works, of course.
But I don't understand why 256 was not accepted. Nevamind, problem solvered, as they say.
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
Hi Phil,
I am looking at _LoadImage at Wiki now (to see if PDF, SVG, EPS, DXF images are accepted, doesn't look like it).
It does appear 256 could work but I guess it depends of the image format the file was created under. I am no expert on this either.
b = b + ...
Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
(03-09-2023, 07:30 AM)PhilOfPerth Wrote: Ok, so this is probably quite simple, but it's frustrating the heck out of me!
This is A.jpg
Do you really want to see that cute cat in 256 colors? Maybe in greyscale it could work...
You got away with im(1) without dimensioning an array called " im". Try not to go over ten with the subscript. Otherwise you must do something like:
Code: (Select All) DIm im(1 to 10) As Long
near the top of your source code.
Also remove the extra parenthesis from _FREEIMAGE call, they are not needed. It's not a function.
Posts: 372
Threads: 23
Joined: May 2022
Reputation:
56
Actually `Screen _NewImage(1000, 800, 256)` does work.
The problem is with `im(1) = _LoadImage("RecPics/" + Chr$(65) + ".jpg")`.
So, basically, we are trying to blit a 32bpp image to an 8bpp surface. This will not work.
If we really want 256 color images, then we could change the _LoadImage line as:
`im(1) = _LoadImage("RecPics/" + Chr$(65) + ".jpg", 256) ' this forces the image to be loaded as 8bpp`
_LOADIMAGE - QB64 Phoenix Edition Wiki
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
Thanks all. I'm starting to get it.
@mnrvovrfc: No I don't think I need 256 colours, the images are quite simple. They seem to be ok in 32 colours, so I'll stay with that.
Is it ok to have a file with maybe 20 images in it, but only have one image-handle, and attach a different pic each time? and if so, when do I need to use _FreeImage?
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
For the record that 32 isn't 32 colors, I think it's 32 bits = 4 bytes, 1 byte = 2^8 = 256 each for Red, Green, Blue and Alpha. That's 256 * 256 * 256 * 256 color options.
b = b + ...
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
03-10-2023, 04:21 AM
(This post was last modified: 03-10-2023, 04:23 AM by PhilOfPerth.)
Using 32bit mode, I'm not able to use any color options, although the pics are in ok colors. Is there a way to use my 32bit pics with color for text, frames etc. or do I need to use 256bit pics?
Sorry to be so dense!
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
03-10-2023, 05:35 AM
(This post was last modified: 03-10-2023, 05:38 AM by bplus.)
Red~& = _RGB32(255, 0, 0)
Green~& = _RGB32(0, 255, 0) ' very light green almost yellow
Blue~& = _RGB32(0, 0, 255)
Yellow~& = _RGB32(255, 255, 0)
Purple~& = _RGB32(255, 0, 255)
Cyan~& = _RGB32(0, 255, 255)
Black~& = _RGB32(0, 0, 0)
White~& = _RGB32(255, 255, 255)
see _RGB32 in Wiki for complete description.
So red print on blue paper:
Color _RGB32(255, 0, 0), _RGB32(0, 0, 255)
Where you see 255 you can replace with number 0 to 255 for different shades.
b = b + ...
|