Copy region of bitmap to region of rectangle

This is a discussion on Copy region of bitmap to region of rectangle within the Windows Programming forums, part of the Platform Specific Boards category; I want to take part of a bitmap and copy it onto part of a rectangle. For example, take the ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    22

    Copy region of bitmap to region of rectangle

    I want to take part of a bitmap and copy it onto part of a rectangle. For example, take the region from (10,10) to (20,20) of the bitmap and copy it to the region from (35,35) to (45,45) of a rectangle. So far all of the functions I've seen only allow you to specify where on the destination rectangle to copy to, but not from the source bitmap.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    BitBlt will do that for you - there are several different variations of Blt, but this is the specification for the standard variant:
    Code:
    BOOL BitBlt(
      HDC hdcDest, // handle to destination DC
      int nXDest,  // x-coord of destination upper-left corner
      int nYDest,  // y-coord of destination upper-left corner
      int nWidth,  // width of destination rectangle
      int nHeight, // height of destination rectangle
      HDC hdcSrc,  // handle to source DC
      int nXSrc,   // x-coordinate of source upper-left corner
      int nYSrc,   // y-coordinate of source upper-left corner
      DWORD dwRop  // raster operation code
    );
    As you can see, it has the source and destination coordinates (since it's a fixed size Blt, you only need to specify height and width once of course).

    --
    Mats

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    22
    That did it; thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 06:33 AM
  2. dynamic memory alloccation & returning objects
    By haditya in forum C++ Programming
    Replies: 8
    Last Post: 04-22-2005, 12:55 AM
  3. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 05:04 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. Help With pointers in classes.
    By indigo0086 in forum C++ Programming
    Replies: 12
    Last Post: 10-10-2002, 03:03 PM

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