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 Professional Discussion / Trying to read image pixel colors with a memblock

Author
Message
Deagle
20
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 27th Jan 2008 16:29
So, i'm trying to read each pixel of an image and check the pixel's color, and if the color is, for example, red (255,0,0), something happens. So, i propably have to make memblock from image, and use the memblock (byte?) commands, but i'm not quite sure how these things works with images.

Deagle aka D-Eagle
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 27th Jan 2008 16:44 Edited at: 27th Jan 2008 16:45
Yes, you convert an image to a memblock using the command
make memblock from image

The structure of a memblock image is as followed:

DWORD 0: width
DWORD 4: height
DWORD 8: depth

n = pixel (ranging from 1 to width*depth)
byte 12 + (n-1)*4: blue
byte 13 + (n-1)*4: green
byte 14 + (n-1)*4: red
byte 15 + (n-1)*4: alpha

eg. memblock byte(1, 12) will return the blue value from the pixel in the top left corner (n = 1).

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Deagle
20
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 27th Jan 2008 16:59 Edited at: 27th Jan 2008 17:13
Thanks, then how about, if i make memblock from bitmap(some.bmp), does it have the alpha byte too, or only the blue, green and red bytes?
EDIT: Never mind, i got it now, tanks a ton, man!

Deagle aka D-Eagle

Login to post a reply

Server time is: 2026-06-12 05:08:21
Your offset time is: 2026-06-12 05:08:21