No pointer to .BITMAP\bmBits with #PB_Image_DisplayFormat

Windows specific forum
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

No pointer to .BITMAP\bmBits with #PB_Image_DisplayFormat

Post by dige »

For images created with #PB_Image_DisplayFormat, you'll get no pointer to the .BITMAP\bmBits bit values for the bitmap...

Why? Is it a PB Bug?

Code: Select all

Procedure.l GetDIBSection (ImgID.i)
  If GetObject_(ImageID(ImgID), SizeOf(DIBSECTION), ds.DIBSECTION )
    Debug ""
    Debug "Image Nr: " + Str(ImgID) 
    Debug "Width x Height: " + StrU(ds\dsBm\bmWidth, #PB_Long) + ", " + StrU(ds\dsBm\bmHeight, #PB_Long)
    Debug "BitsPixel: " + Hex(ds\dsBm\bmBitsPixel)
    Debug "ImageSize: " + StrU(ds\dsBmih\biSizeImage, #PB_Long)
    Debug "-> BitmapPixel Location: " + Hex(ds\dsBm\bmBits)

  EndIf
EndProcedure

If ExamineDesktops()
  Debug "DesktopDepth  : " + Str(DesktopDepth(0))
EndIf

CreateImage(1, 64, 64, 24)
CreateImage(2, 64, 64, 32)
CreateImage(3, 64, 64, #PB_Image_DisplayFormat)

Debug "ImageDepth 1: " + Str(ImageDepth(1)) + " bit"
Debug "ImageDepth 2: " + Str(ImageDepth(2)) + " bit"
Debug "ImageDepth 3: " + Str(ImageDepth(3)) + " bit"

GetDIBSection(1)
GetDIBSection(2)
GetDIBSection(3)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Such a bitmap is obviously not a DIB section. It will undoubtedly be a device dependent bitmap and in these cases GetObject_() will not return a pointer to the bitmap bit values.

You should really use the GetDIBits_() api function.
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

My understanding of PB image objects is that they are device-independent to allow for maximum flexibility, and this was the only option for some years. However, with the introduction of PureBasic v4.0 came a new choice: #PB_Image_DisplayFormat, which gives an image without device-independence and its depth is taken from the display properties. This was intended to be used for images whose only rendering-destination is the screen and it will give much better performance there than a DIB would. You seem to have caught srod in a rare moment of lucidity, so if you want to work with the color bits in one of these creatures you will need to follow his advice and use GetDIBits_().
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Hey, since when was 89 classed as being old ya young whippasnapper?

If I hadn't recently fallen down and broken my zimmer I'd be hobbling my way t'wards Canada right now to chew your ears off! At least I would if I hadn't flushed my false teeth down the toilet by mistake - again! I don't know, they've been round more u-bends than that creature of the night Sparkie who is always rummaging around those dark places looking for my old discarded bits of code!

He'll catch something very unpleasant one day; something like fangbeast! :wink:
I may look like a mule, but I'm not a complete ass.
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

thx guys, good to know ... have to check a lot of sources now..
Post Reply