Replace temp14fe78.png with any handy image you have.
Code: (Select All)
Img& = _LoadImage("temp14fe78.png", 32) ' If , 32 is not used the screen must be created, first.
If Img& >= -1 Then Print "Image not found.": End
Screen _NewImage(640, 400, 32): Cls , _RGB32(255, 255, 255)
_Source Img&
clr~& = Point(0, 0) ' Get background color from image source.
_Dest 0
a& = 0: d% = 1
Do
_Limit 120
a& = a& + d%
If a& = 255 Or a& = 0 Then d% = -d%
If a& = 0 Then cc` = Not cc` ' Switches ClearColor on and off.
_SetAlpha a&, , Img&
If cc` Then _ClearColor clr~&, Img&
Cls ' Required to apply alpha transparency.
_PutImage (0, 0), Img&
Locate 1, 1: Print "Alpha:"; a&; "| ClearColor: ";: If cc` Then Print "ON "; Else Print "OFF ";
_Display
Loop Until _KeyHit
System
So I noticed that if I could measure the image dimensions, I could use those to make the screen the image size.
1) Is there a way to measure the image size when _loadimage is used?
2) I also noticed that using the format: _LoadImage("ImageName", 32) compared to using _LoadImage("ImageName") without the 32-bit image optional mode added, the program will fail unless the screen is created BEFORE the image is loaded. Why is that?
(04-12-2025, 04:58 PM)Pete Wrote: 2) I also noticed that using the format: _LoadImage("ImageName", 32) compared to using _LoadImage("ImageName") without the 32-bit image optional mode added, the program will fail unless the screen is created BEFORE the image is loaded. Why is that?
Pete
Sorry. I was in town earlier on only had my phone for typing. Needless to say, you're not going to get any detailed explanation from old Steve and his poor knuckles on that damn thing!
This answer is very simple:
Code: (Select All)
Screen12
Img& = _LoadImage("temp14fe78.png") ' If , 32 is not used the screen must be created, first. If Img& >= -1ThenPrint"Image not found.": End Print_PixelSize(Img&); " <-- a 1 here indicates that we're loaded in 256 color mode." _FreeImage Img& Sleep'so you can see that first result before we swap screens.
Screen_NewImage(640, 480, 32)
Img& = _LoadImage("temp14fe78.png") ' If , 32 is not used the screen must be created, first. If Img& >= -1ThenPrint"Image not found.": End Print_PixelSize(Img&); " <-- a 4 here indicates that we're loaded in 32 color mode."
Run the above; you'll see what's going on quickly. Without a specified screen mode, the image tries to load and match the one you currently have, matching palettes, blah, blah, blah. Without having a screen mode set, QB64 defaults to SCREEN 0. Of course, you can't load a graphical image onto SCREEN 0, so it... explodes and tosses you that error.
Specify:
_LoadImage("foo", 32) to force 32-bit image to load.
_LoadImage("foo", 256) to force 256 color image to load.
_LoadImage("foo", 257) to force 256 adaptive palette image to load.
But _LoadImage("foo"), with no specification, tries to default to the same as the current screen, and that's not going to work in this case, so it screams and shouts and yells, "PETE IS A BIG ZERO!!!"
Now, where's my point for pointing out, "PETE IS A BIG ZERO!!!"
Open"getinfo.ps1"ForOutputAs #1 Print #1, "# Specify the path to your images" Print #1, "$Path = '" + image$ + "' # Adjust the path and file type as needed"
The above writes the info for you into a CSV file so you can just INPUT the fields directly without having to parse anything. I used LINE INPUT here just to show the output in its raw form for you.
04-13-2025, 03:33 PM (This post was last modified: 04-13-2025, 03:34 PM by Kernelpanic.)
Quote:Easiest thing here is just to load the image, then use _WIDTH and _HEIGHT to get those dimensions, then free it.
Thanks for the tip. I had the same idea last night, but I didn't feel like trying it anymore. It works. I've now implemented it with a procedure. Can it be simplified even further? We'll see. - The images are in the 7z file if anyone wants to try it out.
Code: (Select All)
'Bildanzeigen mit Prozedur - 13. April 2025
Option _Explicit
Declare Sub Bildanzeigen(bild As Long)
Dim As Long bild
bild = _LoadImage("Franziska.jpg", 32)
If bild >= -1 Then Print "Image not found.": End
Call Bildanzeigen(bild)
Sleep 5