You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB
C

1 month ago
#pragma once
#include "stdafx.h"
#include <optional>
class GDIPlusImageDrawer
{
public:
GDIPlusImageDrawer(HDC hDestDC, HBITMAP hb);
// <20><><EFBFBD><EFBFBD>͸<EFBFBD><CDB8>ɫ
void SetTransparentColor(const std::optional<Gdiplus::Color>& transparentColor);
// <20><><EFBFBD><EFBFBD>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>
void SetOpacity(float opacity);
// <20><><EFBFBD><EFBFBD> ROP <20><><EFBFBD><EFBFBD>
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<Gdiplus::Color> m_transparentColor;
};