Link to home
Create AccountLog in
Avatar of JonRead
JonRead

asked on

How do I scale and rotate bitmaps?

I'd like to be able to draw bitmaps in a CDC in various sizes and rotated at certain angles.
Avatar of Zoppo
Zoppo
Flag of Germany image

Avatar of krisp
krisp

Hi,

  To enlarge the bitmap loaded on a dialog, first put the following code in the else part of IsIconic loop of OnPaint. Here  IDB_BITMAP1 is the bitmap ID,

--------------------------------------------------------------------------------------------

CPaintDC dc(this);
HBITMAP hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),                                                              MAKEINTRESOURCE(IDB_BITMAP1));
HDC hMemDC = ::CreateCompatibleDC(NULL);
SelectObject(hMemDC, hbitmap);
            ::StretchBlt(dc.m_hDC, 50, 50, width, hieght, hMemDC, 0, 0, 250,250, SRCCOPY);
::DeleteDC(hMemDC);
::DeleteObject(hbitmap);
--------------------------------------------------------------------------------------------
width and hieght variables are of type integer with values 100 each, and they are declared as global.
To increase the size of the bitmap, increase the values of width and hieght.
from wherever is needed and call InvalidateRect fuction from there.

Hope this will help u.

cheers,
Krisp
Hi krisp,

how can you know that JonRead want's to draw the bitmap loaded from resource onto a dialog???

ZOPPO
ASKER CERTIFIED SOLUTION
Avatar of Viz
Viz

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of JonRead

ASKER

Thanks for your help.