I am trying to rotate and flip images via SetWorldTransform. I can't
get it to work...
Here is the most simplest ( and crude ) code to show what I am trying,
It just tries to draw a rotated bitmap onto the desktop ( Messy, I
know, but thats not the point here )
#include <windows.h>
int main(int argc, char **argv)
{
HBITMAP hBm = (HBITMAP)LoadImageA(NULL, argv[1], IMAGE_BITMAP, 0,
0, LR_LOADFROMFILE);
HDC dc = CreateCompatibleDC(NULL);
SelectObject(dc, hBm);
HDC dc2 = CreateCompatibleDC(NULL);
HBITMAP hBm2 = CreateCompatibleBitmap(dc, 600, 600);
SelectObject(dc2, hBm2);
XFORM xForm;
xForm.eM11 = (FLOAT) 0.8660;
xForm.eM12 = (FLOAT) 0.5000;
xForm.eM21 = (FLOAT) -0.5000;
xForm.eM22 = (FLOAT) 0.8660;
xForm.eDx = (FLOAT) 0.0;
xForm.eDy = (FLOAT) 0.0;
SetGraphicsMode(dc2, GM_ADVANCED);
SetWorldTransform(dc2, &xForm);
BitBlt(dc2, 0, 0, 600, 600, dc, 0, 0, SRCCOPY);
HDC ddc = GetWindowDC(GetDesktopWindow());
BitBlt(ddc, 0, 0, 600, 600, dc2, 0, 0, SRCCOPY);
return 0;
}
Commenting out SetWorldTransform does paint the image onto the
desktop
Why does this not work?
Thanks in advance
V
I don't have time to look at this in the context you show, but I know that I've used
PlgBlt to rotate and flip bitmap images (if you have our Win32 book, it has two pages of
examples, but all were generated from the GDI Explorer program!)
joe
No.
The best and fastest way is SetWorldTransform
See MS samples in SDK