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 / need pixel detection

Author
Message
Gu re gu
22
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 10th Jan 2003 14:57
does any1 know a function or have a command that can detect the colour of a pixel in an image??

eg. return_value = getpixel(image_number,x,y)
Daih Thel phae 'e, clann 'e phaen
firestarter
22
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 10th Jan 2003 16:23
You must know the width of the picture and the bitdepth.

Then the memoryaddress of an pixel is determined by:

(X + (Y * width))* (bitdepth/8) i think.

I don`t have time to test this now, gotta test it later on.

Bitdepth is divided by 8 so we see how many bytes that is.
mimesis
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 10th Jan 2003 17:19
Cant u just use the POINT(X,Y) function?
mimesis
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 10th Jan 2003 17:22
Hah, I get it - 'Image' not 'Bitmap'

Yeah, firstarter is right. U can always use memblocks too,
which I think its less work.
firestarter
22
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 10th Jan 2003 17:40
Make memblock from image:

This command will make a memblock from an image. The specified values must be integer values and the
source resource must exist or the command will fail. The memblock stores the data as Width(DWORD),
Height(DWORD), Depth(DWORD), Data(BYTES).
---------------------------------------------

Ok, with memblocks remember that the 12 first bytes is for header information. And from the header info u get width and depth info.

(X + (Y * width))* (bitdepth/8) + 12
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jan 2003 20:27
Thats right, and you read 2 bytes for 16 bit, 3 for 24 bit and 4 for 32 bit.

If it doesn't need to be fast, paste the image onto a bitmap. Then you can use the point function to get the colour.
Gu re gu
22
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 12th Jan 2003 00:05
thanks, i completely forgot about the memblocks, duh..

Daih Thel phae 'e, clann 'e phaen
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2003 01:03
Can I ask what you need it for?

It seems that a lot of people keep asking for bitmap type functions for images. If there's a lot of demand, I might be persuaded to write a dll to access images.
mimesis
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 12th Jan 2003 01:21
Support for 8bit alpha-channel would be cool
And any image effects like negative, color effects,filters
any of that $hit would be great
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Jan 2003 01:41
Well that can be arranged if everyone wants it that badly..

xxxpetratxxx
B. R. W
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2003 01:45
Hmm, not quite what I was offering. I was thinking more of the dot/point/line/cls type commands and functions.

I'm not sure it is possible for me to introduce the alpha channel - I think that would need to come from Lee or Mike.

The trouble with writing filters or effects is that no-one ever wants quite the same effect. Still, if you can come up with a good effect on a bitmap, I should be able to convert it into a dll.
mimesis
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 12th Jan 2003 02:58
"The trouble with writing filters or effects is that no-one ever wants quite the same effect. Still, if you can come up with a good effect on a bitmap, I should be able to convert it into a dll."

Try to do a Negative for images as a dll plugin, should be easy and a good test for image dll's. Obviously it would
work best for greyscale images, but if you can do color
negative also that would be cool

Any DLL is a good DLL
Gu re gu
22
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 13th Jan 2003 11:18
IanM-"Can I ask what you need it for?"

A while back i was making a map drawing thing (for table top rpgs) and the project kinda stopped when i realised i didn't know how to detect the pixels in the drawing area, so it couldn't do any coast or forest effects etc.

Daih Thel phae 'e, clann 'e phaen
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2003 14:16
So why not paste the image into a bitmap and detect from that? I'm not saying I won't do it, but I don't want to use my time on this if I don't need to.
Gu re gu
22
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 13th Jan 2003 14:43
I haven't really looked into the bitmap commands much as i spend more time in the 3d environment, so i must have overlooked the use of the point command. But don't stress yourself too far on this bescause i do not need it too soon. I will try pasting the image into a bitmap but i think it may be a bit slow.

Daih Thel phae 'e, clann 'e phaen
mimesis
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Norway
Posted: 13th Jan 2003 21:46
paste image is fast!
Gu re gu
22
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 14th Jan 2003 11:07
oh

Daih Thel phae 'e, clann 'e phaen

Login to post a reply

Server time is: 2025-05-18 22:01:36
Your offset time is: 2025-05-18 22:01:36