Search code examples
c++image-processingmfcatl

How can I rotate and make the image semitransparent at the same time by using ATL::CImage?


I just started using ATL::CImage in my MFC project, and this is very basic question about it. I know ATL::CImage members support AlphaBlend() for controlling the transparency, and plgblt() for rotating. But they are all the independent functions for only "Displaying" on DC as I understand. How Can I apply both transparency and rotation of the image and display/save it?

I know GDI+ supports everything what I want, but I wanna know how to realize them with CImage class members too.

Thank you.


Solution

  • This isn't possible in the same way. You can use a temporary DC for each operation.

    1. Create a DC with a bitmap of the needed size.
    2. Perform the operation of the CImage into the DC.
    3. Get the Bitmap from the DC and form a new CImage or simply work on with the DC.

    The better way is always to use GDI+ to perform such operations. CImage is only needed when you need to store the interim result, or need to reuse it.