0
votes

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

1

1 Answers

1
votes

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);