目录
方法二常用一点。
效果:
如图
方法一:
思路:获取屏幕图像,反色后,设置为壁纸。
头文件:#include <windows.h>
#include <vector.h>
#include <cstdio>
#include <string>
#include <tchar.h>
代码:(调用Screenshot反转颜色)
BOOL GetHDCData(HDC hdc, const RECT& rcDC, std::vector<BYTE>& vtBuf)
{
BOOL bRes = FALSE;
HBITMAP hBmp = NULL;
HDC hdcMem = NULL;
__try
{
//Initilaize the bitmap information
BITMAPINFO bmpInfo = { 0 };
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = rcDC.right - rcDC.left;
bmpInfo.bmiHeader.biHeight = rcDC.bottom - rcDC.top;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
//Create the compatible DC to get the data
hdcMem = CreateCompatibleDC(hdc);
if (hdcMem == NULL)
{
//ASSERT(FALSE);
//RETAILMSG(TRUE,(TEXT("CreateCompatibleDC failed! Error Code:0x%x\r\n"),GetLastError()));
__leave;
}
//Get the data from the memory DC
BYTE* pData = NULL;
hBmp = CreateDIBSection(hdcMem, &bmpInfo, DIB_RGB_COLORS, reinterpret_cast<VOID**>(&pData), NULL, 0);
if (hBmp == NULL)
{
//ASSERT(FALSE);
//RETAILMSG(TRUE,(TEXT("CreateDIBSection failed! Error Code:0x%x\r\n"),GetLastError()));
__leave;
}
HGDIOBJ hOldObj = SelectObject(hdcMem, hBmp);
//Draw to the memory DC
SIZE sizeImg = { bmpInfo.b