Page 1 of 1

raw manipulation of #image data possible?

Posted: Mon Oct 30, 2006 10:52 am
by mskuma
If I write something like this

Code: Select all

  StartDrawing(ImageOutput(#ImgText)) 
    Box(0,0,40,25,#Black) 
    DrawText(10,10,"Hello",#White) 
  StopDrawing() 
Can I later access & manipulate the raw image data (RGBA) in anyway? Thanks.

Posted: Mon Oct 30, 2006 11:47 am
by Trond
You can use Windows API:

Code: Select all

Bmp.BITMAP
GetObject_(ImageID(#Image), SizeOf(BITMAP), @Bmp)
MemoryBuffer = Bmp\bmBits

Posted: Mon Oct 30, 2006 12:03 pm
by mskuma
I tried that but got a null pointer. Isn't that valid only after loading a bitmap from a file?

Posted: Mon Oct 30, 2006 12:14 pm
by srod
Could try GetDiBits_() and SetDiBits_().

Posted: Mon Oct 30, 2006 12:22 pm
by venom
DrawingBuffer()? Not sure if it works with images though.

Posted: Mon Oct 30, 2006 12:48 pm
by mskuma
Thanks folks for your reply - looks like GetDiBits_() and SetDiBits_() is the ticket. Thanks srod.

Posted: Mon Oct 30, 2006 1:11 pm
by srod
I'm not sure about the alpha channel though?

Using GetDIBits_() with #DIB_RGB_COLORS, seems to only account for the usual 3 channels. Not sure if it will return the alpha channel as such as I have little experience with such things. In fact I don't know how Windows handles alpha-channels, if indeed it does at all?

Posted: Mon Oct 30, 2006 1:16 pm
by netmaestro
Have a look at Trond's BlitImageTranslucent routine, found here:

http://www.purebasic.fr/english/viewtop ... 92&start=5