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.
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(::AfxGetInsta nceHandle( ), MAKEINTRESOURCE(IDB_BITMAP 1));
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
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(::AfxGetInsta
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
how can you know that JonRead want's to draw the bitmap loaded from resource onto a dialog???
ZOPPO
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks for your help.
Rotation:
http://www.codeguru.com/bitmap/rotate_bitmap.shtml or
http://www.codeguru.com/bitmap/RotateByShear.shtml
Scaling:
http://www.codeguru.com/bitmap/2_pass_scale.shtml
hope that helps,
ZOPPO