GetPixel function

This is a discussion on GetPixel function within the C++ Programming forums, part of the General Programming Boards category; I have no clue how this function is used, i only know its parameters. Can anyone tell me how its ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    17

    GetPixel function

    I have no clue how this function is used, i only know its parameters. Can anyone tell me how its supposed to be implemented? I've searched all kinds of places to figure it out but i cant find anything lol

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    At a guess I would say that it would return the ARGB colour value at a co-ord.

    [edit] At least that is what the name would suggest [/edit]

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    6
    Is this what you were looking for?

    http://msdn2.microsoft.com/en-us/lib...wt(VS.71).aspx

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    no, like what to include in order to use it, and do i have to do anything else to use it as well?

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    6
    Did you not take the time to look on the site? It's a member of the CImage class. All the requirements are on this page.

    http://msdn2.microsoft.com/en-us/lib...y5(VS.80).aspx

  6. #6
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Could MSDN be any slower, geez. But to answer your question that function returns a long word with the Red Green and Blue value of a pixel in an unsigned long value at the given coordinate. How you use it is up to you, you call the function and do something with it.

    I would think that an image editing program could implement a color dropper, burn, etc tool to change the color of the pixels around it, and many other implementations I assume.

    here's the definition of COLORREF to show you how to interpret the value returned
    http://msdn2.microsoft.com/en-us/library/aa923096.aspx
    Last edited by indigo0086; 07-03-2007 at 11:13 AM.

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    ok i finally found an article that's sort of about GetPixel(), and this is what it had in the example:
    Code:
    int x,y;
     	unsigned char pixels[30][100];
     	
     	HDC hdc = GetDC(NULL);
     	
     	for(y=SY;y<SY+30;y++)
     	for(x=SX;y<SX+100;x++)
     	
     	
     	if(GetPixel(hdc,x,y)==0)
            cout << "black" << endl;
    and he included windows.h for it, but when i run this code i get an error that says "Undefined reference to GetPixel@12". Anyone know what might be wrong there?

  8. #8
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    You need to add the "gdi32.lib" in your project properties
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  9. #9
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    now it says build error and thats it

  10. #10
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    What compiler and ide are you using. if you are using msw you have to include "gdi32.lib", if you are using gcc/g++ you have to use "gdi32lib.a". Most IDEs allow you to just put "gdi32. And it will look in the library path for it, others may not.

  11. #11
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    I'm using dev c++ and i dont really know what the ide is, i think its mingw/gcc or something like that

  12. #12
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    okay, there should be a place where you can change the build options of a project. Look for "linker settings" or "library settings" and add "gdi32"

  13. #13
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    I already had that there but it was "gdi32.lib" and it comes with this exact error
    Code:
     C:\Dev-Cpp\Makefile.win [Build Error]  ["HTS] Error 1
    and its the same when i take .lib off

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Under Tools -> Compiler Options
    Check the box for: Add these commands to the linker command line
    and then add: -lgdi32

  15. #15
    Registered User
    Join Date
    Jul 2007
    Posts
    17
    ok i got it, i didnt need to put it in the project properties, i had to put it where swoopy specified

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21