sparkeh9
sparkeh9

Reputation: 75

How to rotate an ATL::CImage object

My question basically is, how do I rotate a windows ATL::CImage object?

I have loaded in a JPG image using the windows ATL CImage object, such as:

CImage myImage; myImage.Load(L"IMG1.JPG");

I have also managed to alter the pixels (made the pixels brighter) and save the new image, now I am struggling to rotate my image.

I only need to be able to rotate in 90 degree increments, so arbitrary rotation would be a bonus

Upvotes: 0

Views: 2048

Answers (1)

Sheng Jiang 蒋晟
Sheng Jiang 蒋晟

Reputation: 15271

demo only, error handling omitted, should not to do this to begin with, just use GDI+ image instead of the ATL CImage and save a round trip of pixel copying.

Bitmap* gdiPlusBitmap=Bitmap::FromHandle(atlBitmap.Detach());
gdiPlusBitmap->RotateFlip(Rotate90FlipNone);
HBITMAP hbmp;
gdiPlusBitmap->GetHBITMAP(Color::White, &hbmp);
atlBitmap.Attach(hbmp);

Upvotes: 1

Related Questions