PDA

View Full Version : GetPixel With Windows Libary



Floby
27-03-2007, 02:31 AM
i cant get the Getpixel Command to work i need to define DC (device Context) andi cant set this up right causei have no idea what so ever my programmign teacher at school does java so has no idea how to help me can someone plz help me.

WILL
27-03-2007, 01:56 PM
The PAramatars For GETpixel are (DC,X,Y) but i cant get DC to work (Device Context) and im Stumped on how to do it can someone plz help

You already have this post. Please do not double post as this is not looked upon kindly.

If you don't get an answer it is because you either didn't provide enough information or did not explain your problem clearly.

In this case I'd assume that you're not giving enough information as I do not understand what you're having problems with. We are not 'all knowing' (despite what some may claim ;) ) so you will have to explain what you are asking help with in enough detail so that we will all get it too. Considering that not everyone is using the library that you are using.

Floby
05-04-2007, 06:54 AM
Ok Sorry Will This is whats wrong ok Im using the Windows Libary and when using the Get pixel function like this where the paramaters are changed because i need the windows libary for something else
i cant get DC to work im kinda new to programming but i hope some one can help.

hbc := GetDC(null);
PixelColour := GetPixel(hbc,x1,y1);

DarknessX
06-04-2007, 12:38 AM
Well, I dunno, but I don't think your supposed to have (hbc,x1,y1), I think its supposed to be (hbc,1,1). Try that.

AthenaOfDelphi
06-04-2007, 10:07 AM
Ok Sorry Will This is whats wrong ok Im using the Windows Libary and when using the Get pixel function like this where the paramaters are changed because i need the windows libary for something else
i cant get DC to work im kinda new to programming but i hope some one can help.

hbc := GetDC(null);
PixelColour := GetPixel(hbc,x1,y1);

Hi Floby,

You need to provide GetDC with a handle. In most cases if you can do things like this with a control, the control will have a handle property.

So, lets say you have a panel called myPanel and you want to look at pixel x1,y1. This is how you would do it.


var
dc : HDC;
col : TColor;

...

dc:=getDC(myPanel.handle);
col:=getPixel(dc,x1,y1);

...



Hope this helps. If you are using a Borland compiler, you can sometimes get access to the controls canvas property. This provides a whole bunch of routines for drawing and doesn't require you to know about window handles and device contexts. One of the properties it provides is the pixels property (an array that provides access to the pixels of the canvas).