Image persistence (cue Twilight Zone theme...)

This is a discussion on Image persistence (cue Twilight Zone theme...) within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm trying to make a simple function that draws a bitmap image to a window (effectively using a BitBlt ...

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266

    Exclamation Image persistence (cue Twilight Zone theme...)

    Hi,
    I'm trying to make a simple function that draws a bitmap image to a window (effectively using a BitBlt call). This works fine, except that when the window is overlapped or moved so that the area where the image is is offscreen, the obscured parts of the image are removed and not redrawn.

    Is there a way I can prevent Windows from destroying the data that's there (much like the AutoRedraw property in Visual Basic) or perhaps redraw selected regions of the image as opposed to the entire image (I tested that, it's sloooow )?

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Are you saving the Bitmap data anywhere? Remember, it has to be redrawn with each WM_PAINT message. If you want to redraw a part of the screen call InvalidateRect() and pass it a RECT struct with the coords you want redrawn.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    The bitmap data is always available (selected into a memory DC), but is there a way I can use the coordinates from a WM_PAINT message to only redraw part of it?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    This BEFORE the call to BeginPaint() will get the paint area (the area that Windows thinks needs to be redrawn)

    Code:
    GetUpdateRect(hWnd, &theRect, 0);
    if (IsRectEmpty(&theRect))
    {
         GetClientRect(hWnd,&theRect);
    }
    You should use a frame buffer. That is have two HDCs
    One to draw to the screen.
    Another that you do all the drawing too, then copy to the one that is drawn to the screen.
    Then call for a paint.

    If you declare the HDC in a callback (in say response to a WN_CREATE or INIT or PAINT msg), is it static?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 05:17 AM
  2. Replies: 1
    Last Post: 05-27-2009, 01:46 PM
  3. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 01:10 PM
  4. Replies: 4
    Last Post: 03-02-2003, 09:12 AM

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