CreateImage bug in V6.30?

Just starting out? Need help? Post your questions and find answers here.
dangerfreak
User
User
Posts: 82
Joined: Tue Jan 12, 2010 4:56 pm

CreateImage bug in V6.30?

Post by dangerfreak »

I think I found a bug in V6.30 concerning "CreateImage". If you create an image with a depth of 32 bit, you mustn't add an optional BackColor (parameter after the depth). Otherweise you always get a blank image, even if you draw anything on it later.

Note: If you try the same code with V6.21, it works.

Does not work with v6.30 (but with V6.21), results in a blank image:

Code: Select all

Enumeration
   #fenster
   #imageGadget
   #image
EndEnumeration

OpenWindow(#fenster,0,0,600,600,"TEST")

CreateImage(#image,500,500,32,#White)
StartDrawing(ImageOutput(#image))
LineXY(0,0,500,500,#Red)
StopDrawing()

ImageGadget(#imageGadget,0,0,500,500,ImageID(#image))

While WaitWindowEvent()<>#PB_Event_CloseWindow
   Delay(50)
Wend

Works with v6.30 (32 bit, no BackColor parameter):

Code: Select all

Enumeration
   #fenster
   #imageGadget
   #image
EndEnumeration

OpenWindow(#fenster,0,0,600,600,"TEST")

CreateImage(#image,500,500,32)
StartDrawing(ImageOutput(#image))
LineXY(0,0,500,500,#Red)
StopDrawing()

ImageGadget(#imageGadget,0,0,500,500,ImageID(#image))

While WaitWindowEvent()<>#PB_Event_CloseWindow
   Delay(50)
Wend

Works with v6.30 (depth 24 bit, with BackColor paramater):

Code: Select all

Enumeration
   #fenster
   #imageGadget
   #image
EndEnumeration

OpenWindow(#fenster,0,0,600,600,"TEST")

CreateImage(#image,500,500,24,#white)
StartDrawing(ImageOutput(#image))
LineXY(0,0,500,500,#Red)
StopDrawing()

ImageGadget(#imageGadget,0,0,500,500,ImageID(#image))

While WaitWindowEvent()<>#PB_Event_CloseWindow
   Delay(50)
Wend
Can someone please check that?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5032
Joined: Sun Apr 12, 2009 6:27 am

Re: CreateImage bug in V6.30?

Post by RASHAD »

Hi
The backcolor used when the image is created.
If the image is 24-bit, use RGB() to get a valid color.
If the image is 32-bit, use RGBA() to get a valid color. For 32-bit image, special constants can be used as well:
- #PB_Image_Transparent which is similar to RGBA(255,255,255,0), white background which can help for light antialiasing.
- #PB_Image_TransparentBlack which is similar to RGBA(0,0,0,0), black background which can help for dark antialiasing.

The default backcolor is black if not specified.

Code: Select all

Enumeration
   #fenster
   #imageGadget
   #image
EndEnumeration

OpenWindow(#fenster,0,0,600,600,"TEST")

CreateImage(#image,500,500,32,$FFFFFFFF)
StartDrawing(ImageOutput(#image))
LineXY(0,0,500,500,#Red)
StopDrawing()

ImageGadget(#imageGadget,0,0,500,500,ImageID(#image))

While WaitWindowEvent()<>#PB_Event_CloseWindow
   Delay(50)
Wend
Egypt my love
User avatar
mk-soft
Always Here
Always Here
Posts: 6539
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CreateImage bug in V6.30?

Post by mk-soft »

Code: Select all

...
CreateImage(#image,500,500,32,$FF000000 | #white)
...
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
dangerfreak
User
User
Posts: 82
Joined: Tue Jan 12, 2010 4:56 pm

Re: CreateImage bug in V6.30?

Post by dangerfreak »

Ok, that makes sense and explains it.

I only think it's a bit confusing, because:
- the color constants (like #white, #black, etc.) work for CreateImage with 32 bit in Purebasic v6.21, but not in v6.30
- drawing a line with a color constant (like #red in my example) in a 32 bit image works even in Purebasic v6.30

However, thanks for the help! :)
Post Reply