raw manipulation of #image data possible?

Just starting out? Need help? Post your questions and find answers here.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

raw manipulation of #image data possible?

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

You can use Windows API:

Code: Select all

Bmp.BITMAP
GetObject_(ImageID(#Image), SizeOf(BITMAP), @Bmp)
MemoryBuffer = Bmp\bmBits
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I tried that but got a null pointer. Isn't that valid only after loading a bitmap from a file?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Could try GetDiBits_() and SetDiBits_().
I may look like a mule, but I'm not a complete ass.
venom
User
User
Posts: 56
Joined: Fri Jul 25, 2003 1:54 pm
Location: Australia

Post by venom »

DrawingBuffer()? Not sure if it works with images though.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Thanks folks for your reply - looks like GetDiBits_() and SetDiBits_() is the ticket. Thanks srod.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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?
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Have a look at Trond's BlitImageTranslucent routine, found here:

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