c++mfcgdi+resizecbitmap

How do you scale a CBitmap object?


I've loaded a CBitmap object from a resource ID, and I'm now wanting to scale it to 50% its size in each dimension. How might I go about this?


Solution

    1. Select your CBitmap obj into a memDC A (using CDC::SelectObject())
    2. Create a new CBitmap with desired sized and select it into another MemDC B
    3. Use CDC::stretchblt(...) to stretch bmp in MemDC A into MemDC B
    4. Deselect your CBitmap objects (by selecting what was returned from the previous calls to SelectObject)
    5. Use your new CBitmap