So frustrating!
#1
Ok, so this is probably quite simple, but it's frustrating the heck out of me!  Huh
[Image: A.jpg] 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))
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Reply
#2
Try this:
Screen _NewImage(1000, 800, 32)   ' <<<< not 256
b = b + ...
Reply
#3
(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.  Big Grin
But I don't understand why 256 was not accepted. Nevamind, problem solvered, as they say.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Reply
#4
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 + ...
Reply
#5
(03-09-2023, 07:30 AM)PhilOfPerth Wrote: Ok, so this is probably quite simple, but it's frustrating the heck out of me!  Huh
[Image: A.jpg] 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. Smile
Reply
#6
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
Reply
#7
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?
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Reply
#8
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 + ...
Reply
#9
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?  Undecided
Sorry to be so dense!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Reply
#10
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 + ...
Reply




Users browsing this thread: 1 Guest(s)