• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Taking part of a bitmap

I have a bitmap loaded in a HBITMAP and I know the width and height . How can I create a HBITMAP that will have part of this image ( w/o being drawn first ) . For example , for a bitmap 100x100 i would take the 50x50 from 0x25 of the bitmap coordinates .
1 Solution
You can create a new one and use something like BitBlt(). Or may be I don't catch your problem?
It is possible to access the bitmap bits directly and copy the ones you are interested in to a new bitmap. This however is non-standard since different color depths use different formats for storing bitmaps. If you know in advance what color depth you will be using, then this might be a good solution for you. If you are using 24-bit bitmaps, you can take a look at my CodeGuru article, Directly Accessing Pixels in a 24-bit Bitmap, at http://codeguru.developer.com/bitmap/pixel_access.shtml .
WxWAuthor Commented:
MichaelS : I will try to use BitBlt and inform you of the results .

slarti : I use 24-bit bitmaps so I will check ur article .

Yeah, simply use BitBlt. For DIBs, search for the CropDIB sample.

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now