#pragma once #include "stdafx.h" #include class GDIPlusImageDrawer { public: GDIPlusImageDrawer(HDC hDestDC, HBITMAP hb); // 设置透明色 void SetTransparentColor(const std::optional& transparentColor); // 设置透明度 void SetOpacity(float opacity); // 设置 ROP 操作 void SetROP(DWORD rop); bool Draw(int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight); private: void SetTransparentColor(Gdiplus::ImageAttributes& attributes); void SetOpacity(Gdiplus::ImageAttributes& attributes); bool PerformDraw(int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, Gdiplus::ImageAttributes& attributes); bool PerformROP(int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, Gdiplus::ImageAttributes& attributes); HDC m_hDestDC = nullptr; HBITMAP m_hBitmap = nullptr; float m_opacity = 1.0; DWORD m_rop = 0; std::optional m_transparentColor; };