Results 1 to 5 of 5

Thread: GetPixel With Windows Libary

  1. #1

    GetPixel With Windows Libary

    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.
    Practice makes Perfect But
    <br />Nobody is Perfect
    <br />So why Bother

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    GetPixel With Windows Libary

    Quote Originally Posted by Floby
    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.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3

    GetPixel With Windows Libary

    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);
    Practice makes Perfect But
    <br />Nobody is Perfect
    <br />So why Bother

  4. #4

    GetPixel With Windows Libary

    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.
    --MagicRPG--

  5. #5
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    GetPixel With Windows Libary

    Quote Originally Posted by Floby
    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.

    [pascal]
    var
    dc : HDC;
    col : TColor;

    ...

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

    ...

    [/pascal]

    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).
    :: AthenaOfDelphi :: My Blog :: My Software ::

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •