Page 1 of 1

No pointer to .BITMAP\bmBits with #PB_Image_DisplayFormat

Posted: Wed Apr 29, 2009 9:22 am
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)

Posted: Wed Apr 29, 2009 10:48 am
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.

Posted: Wed Apr 29, 2009 2:31 pm
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_().

Posted: Wed Apr 29, 2009 2:45 pm
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:

Posted: Thu Apr 30, 2009 7:50 am
by dige
thx guys, good to know ... have to check a lot of sources now..