GetPixel Problem

This is a discussion on GetPixel Problem within the Windows Programming forums, part of the Platform Specific Boards category; PHP Code: HDC bitmapDC ; HBITMAP bitmapHandle ; COLORREF bmpSample ;      bitmapHandle =( HBITMAP ) LoadImage ( 0 , "e:\mytestsample.bmp" , IMAGE_BITMAP ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    10

    GetPixel Problem

    PHP Code:
    HDC bitmapDC;
    HBITMAP bitmapHandle;
    COLORREF bmpSample;
        
    bitmapHandle=(HBITMAP)LoadImage(0,"e:\\mytestsample.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
        
    bitmapDC GetDC((HWND)bitmapHandle);
        
    bmpSample GetPixel(bitmapDC2331);
        
    cout << "aaa " << bmpSample << '\n'
    I get a 9 digit value for bmpSample lol.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Posts
    5,439
    this question belongs on the windows board...

    // bitmapDC = GetDC((HWND)bitmapHandle);

    first of all, why are you casting an HBITMAP to HWND? their completely incompatible types. you need to create a compatible device context with the one you'll be drawing to (in this case, the screen), then select the bitmap into it.

    Code:
    HDC sdc = GetDC(NULL); // ie: the screen
    HDC cdc = CreateCompatibleDC(sdc);
    SelectObject(cdc, bmp);
    Code:
    int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000
    <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan
    (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000
    )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,515
    Moved to the Windows board.

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    305
    Maybe if you can put bitmapHandle in a static control..you can use correctly GetPixel

    * Debian 6.0.1 on Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM.
    * lighttpd, php5, perl, eruby, python.
    * geany, XHTML & CSS & JavaScript, C, C++.
    * GTK+ C & perl-gtk2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

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