I guess really I am aiming this at Freak having just read the latest PB blog regarding the new 2d drawing library etc.
Timo, I use the following to quickly convert an image to 8-bit gray-scale which works fine for my purposes with earlier versions of PB :
Code: Select all
ProcedureDLL ImageTo8bit(imageIn)
Protected imageOut, color, width, height, hdc
Protected Dim colors.l(255)
width = ImageWidth(imageIn) : height = ImageHeight(imageIn)
If width And height
;Set up a 'grey' colortable.
For color = 0 To 255
colors(color) = color + color<<8 + color<<16
Next
;Create an 8-bit image.
imageOut = CreateImage(#PB_Any, width, height, 8)
If imageOut
;Convert the original image to gray-scale by simply setting the new image's color table and then copying the first image.
hdc = StartDrawing(ImageOutput(imageOut))
If hdc
SetDIBColorTable_(hdc, 0, 256, @colors())
DrawImage(ImageID(imageIN),0,0)
StopDrawing()
Else
FreeImage(imageOut)
imageOut = 0
EndIf
EndIf
EndIf
ProcedureReturn imageOut
EndProcedure
My unserstanding is that the new images are all DIB sections and of course the SetDIBColorTable_() is designed to work with these kinds of images - or at least I thought it was?
Any idea what might be afoot here? I could of course switch back to ddb's via api, but I would rather work with PB commands as much as possible.
Thanks.


