Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetWorldTransform and BitBlt not working

317 views
Skip to first unread message

rep_movsd

unread,
Oct 14, 2009, 4:02:46 AM10/14/09
to
Hi

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

Joseph M. Newcomer

unread,
Oct 18, 2009, 10:59:02 PM10/18/09
to
Not sure why, but an alternative might be to use PlgBlt. You can download the GDI
Explorer as part of the download for the Win32 book and play with PlgBlt, plugging in
various values (such as various coordinates multiplied by 0.8660) and seeing what happens.

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

jeff

unread,
Oct 19, 2009, 3:55:44 PM10/19/09
to
Joseph M. Newcomer wrote:
> Not sure why, but an alternative might be to use PlgBlt.

No.
The best and fastest way is SetWorldTransform
See MS samples in SDK

0 new messages