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.

DarkBASIC Discussion / getting rgb from memblock image

Author
Message
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 01:11
what was the formula for getting the red, green, or blue of a pixel in a memblock?

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 01:30
Not sure for 16 bit, but here it is for 32 bit

Pos = 12 + (X + Y*Width) * 4

Red = Memblock Byte(mem, Pos)
Green = Memblock byte(Mem, Pos+1)
Blue = Memblock Byte(Mem, Pos+2)
Alpha = Memblock Byte(Mem, Pos+3)

talk to ashinga bout 16 bit lol

New Site! Check it out \/
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Jun 2009 02:01
You got it backwards Caleb:

Blue = Memblock Byte(mem, Pos)
Green = Memblock byte(Mem, Pos+1)
Red = Memblock Byte(Mem, Pos+2)
Alpha = Memblock Byte(Mem, Pos+3)

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 02:03
right, i recall memblocks store rgb backwards (bgr)

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 02:22
Oh sorry

New Site! Check it out \/
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Jun 2009 02:48
Quote: "right, i recall memblocks store rgb backwards (bgr)"

never knew that, that might explain a lot...

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 03:26
lol Ya i could get that to work for soooo long because of that lol

New Site! Check it out \/
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 12th Jun 2009 03:30
I thought you just had to do
rgbr for red
rgbg for green
rgbb for blue

just for instance

r=rgbr(memblock word(1,12))
g=rgbg(memblock word(1,12))
b=rgbb(memblock word(1,12))
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 04:32
They are talking about a Memblock image or bitmap so like this:

Make memblock form bitmap Memblock,Bitmap

Then the memblock is filled like this:

12 byte header:
DWORD Width
DWORD Height
DWORD Depth
Color Data(RGB and Alpha)
DWORD per pixel for 32 bit depth
WORD per pixel for 16 bit depth

so then theres 1 DWORD/WORD for each pixel. you can edit this to the color you want then make the bitmap again with:

Make bitmap from memblock Bitmap,memblock

And you will have the Changed image. it's faster to use this and get the color data then using the POINT() function. and faster to edit images depending on what your doing.

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 04:42
right pictionary, thats one way, but that has to go get the memblock word AND find the color value of that value

the other method only has to get a byte, nothing else

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 05:07
Well if it's a WORD then theres some other stuff you have to do to get the color values(Can't remember) but if it's a DWORD then ya you just get the first 3 bytes and it's BGR (RGB Backwards) or just get the dword and thats the color also. if you need all three then just use RGBR,RGBG,RGBB stuff

New Site! Check it out \/
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 12th Jun 2009 05:20
o so its quicker if you get the bytes for a dword
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 07:27
Well not quicker just easier.

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 12th Jun 2009 16:02
it prolly is quicker since getting the values will take about the same amount of time, but you wont need to do rgbr/g/b

some1 should run some tests, not me im not good w/ timer()

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Jun 2009 17:03
Oh i thought he was talking about getting the color from a WORD vs. a DWORD.

Ya getting each byte could be faster. not by much. for me i ussually just test against a RGB() value. i don't ussually get the indevidual colors.

New Site! Check it out \/
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 12th Jun 2009 17:15
what about for a 16 bit image. How would you do that. I find this information very useful btw.

Login to post a reply

Server time is: 2025-08-08 11:54:33
Your offset time is: 2025-08-08 11:54:33