Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / reversing pixels in BMP to opposite with simple loop

Author
Message
im not really here
13
Years of Service
User Offline
Joined: 14th Oct 2010
Location: iowa
Posted: 9th Nov 2010 11:48
hello i am trying to take an image.bmp display it and cycle threw it pixel by pixel using a loop like so

and change it.....and im trying to stay away from sync...i want to keep this as simple as possible im trying to go step by step to learn all this stuff...thanks again!
p.s...im not to worried about how slow it is at this point
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Nov 2010 16:05
Look at dbMakeMemblockFromBitmap (or something like that). Once you create the memblock, you can modify each byte to be what you want. I would read each pixil value and then swap as needed, then do a dbMakeBitmapFromMemblock (or something like that). Each pixil value will have either RGB or RGBA (3 or 4 bytes). You'll have to find that out yourself. There may be a way to get the pixil format using db functions, but I don't know what that is.

The fastest code is the code never written.
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Nov 2010 19:47 Edited at: 9th Nov 2010 19:52
Quote: "im not sure how to swap from the RGB red value to its blue.
"


With the dbRGBR, dbRGBG, dbRGBB commands you can get the individual colour values out of the colour variable that you read out of the bitmap. Then you can construct dbRGB from these values, reversing the colours. Then write it back into the bitmap, for example with dbDot (if it works, some computers have a problem with that) but you need to set the current bitmap to let the system know that you are drawing to bitmap and not the screen.

Another way is to use bit masking and shifting to get the colour values out of the variable. That will probably be faster and if you use memblocks, then I think that should be the preferred way, even if it takes some experimenting to get it right. In this thread you will find an exercise about manipulating colours with bit shifting, to point you in this direction (search for "colour conversion").

http://forum.thegamecreators.com/?m=forum_view&t=177106&b=22
im not really here
13
Years of Service
User Offline
Joined: 14th Oct 2010
Location: iowa
Posted: 10th Nov 2010 00:16
ahh! i want to replace pixel using i missed that in the book...thanks....is there a simpler way to test the pixel and reverse from red value to blue? like its exact opposite ...thanks again guys
im not really here
13
Years of Service
User Offline
Joined: 14th Oct 2010
Location: iowa
Posted: 10th Nov 2010 02:20
never mind i figured it out....woot woot!

Login to post a reply

Server time is: 2024-06-30 10:51:08
Your offset time is: 2024-06-30 10:51:08