Thread: GetPixel Problem

  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
    Location
    Waterloo, Texas
    Posts
    5,708
    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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Moved to the Windows board.

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    Maybe if you can put bitmapHandle in a static control..you can use correctly GetPixel
    * 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.

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, 11: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, 05:46 PM