关于bitblt函数的一些猜想!

小君履冰 2016-09-21 11:17:50
在windows 中假如我用 BitBlt得到的位块数据是多少进制的,可否十进制处理,我想那样会好处理一点? 我很难理解就是用 BitBlt得到的数据是什么格式的?就一个像素点颜色值挨着下一个颜色值?没有bmp文件的那种有宽高的信息在里面,也没有像说明是第几个像素点的信息在里面?因为我看他们截屏函数保存为bmp都需要自己加 宽高和显示模式。若截屏下来的像素点数据都是24位的?跟显示器有什么关系吗?
...全文
546 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
小君履冰 2016-09-22
  • 打赏
  • 举报
回复
引用 2 楼 赵4老师的回复:
仅供参考:
#pragma comment(lib,"gdi32")
#include <windows.h>
#include <vector>
using namespace std;
// 获取HDC的数据
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.bmiHeader.biWidth,bmpInfo.bmiHeader.biHeight};
        SIZE sizeDC = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};
        StretchBlt(hdcMem,
                    0,
                    0,
                    sizeImg.cx,
                    sizeImg.cy,
                    hdc,
                    rcDC.left,
                    rcDC.top,
                    sizeDC.cx,
                    sizeDC.cy,
                    SRCCOPY|0x40000000);//CAPTUREBLT


        vtBuf.resize(sizeImg.cx * sizeImg.cy * 3);
        memcpy(&vtBuf[0],pData,vtBuf.size());

        SelectObject(hdcMem, hOldObj);

        bRes = TRUE;

    }
    __finally
    {

        if (hBmp != NULL)
        {
            DeleteObject(hBmp);
        }

        if (hdcMem != NULL)
        {
            DeleteDC(hdcMem);
        }
    }

    return bRes;
}
// 保存HDC为BMP文件
BOOL WriteBmp(const char *strFile,HDC hdc,const RECT &rcDC)
{
    std::vector<BYTE> vtData;
    if (GetHDCData(hdc,rcDC,vtData) == FALSE)
    {
        return FALSE;
    }

    SIZE sizeImg = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};

    BITMAPINFOHEADER bmInfoHeader = {0};
    bmInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmInfoHeader.biWidth = sizeImg.cx;
    bmInfoHeader.biHeight = sizeImg.cy;
    bmInfoHeader.biPlanes = 1;
    bmInfoHeader.biBitCount = 24;

    //Bimap file header in order to write bmp file
    BITMAPFILEHEADER bmFileHeader = {0};
    bmFileHeader.bfType = 0x4d42;  //bmp
    bmFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    bmFileHeader.bfSize = bmFileHeader.bfOffBits + ((bmInfoHeader.biWidth * bmInfoHeader.biHeight) * 3); ///3=(24 / 8)

    HANDLE hFile = CreateFile(strFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        return FALSE;
    }

    DWORD dwWrite = 0;
    WriteFile(hFile,&bmFileHeader,sizeof(BITMAPFILEHEADER),&dwWrite,NULL);
    WriteFile(hFile,&bmInfoHeader, sizeof(BITMAPINFOHEADER),&dwWrite,NULL);
    WriteFile(hFile,&vtData[0], vtData.size(),&dwWrite,NULL);


    CloseHandle(hFile);

    return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

    HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
    RECT rcSave = {0,0,GetDeviceCaps(hdc,HORZRES),GetDeviceCaps(hdc,VERTRES)};
    WriteBmp("D:\\ScreenCapture.BMP",hdc,rcSave);
    DeleteDC(hdc);

    return 0;
}

#if 0

#ifndef CAPTUREBLT
#define CAPTUREBLT 0x40000000
#endif
HBITMAP CaptureScreen(LPRECT lpRect)//lpRect为NULL时表示全屏幕截图
{
    HDC      hdc, hdcMem ;
    HBITMAP  hemfCopy ;
    HWND     hwndScr ;
    int      dstcx, dstcy ;
    if(lpRect)
    {
        dstcx = lpRect->right - lpRect->left ;
        dstcy = lpRect->bottom - lpRect->top ;
    }
    else
    {
        dstcx = GetSystemMetrics(SM_CXSCREEN) ;
        dstcy = GetSystemMetrics(SM_CYSCREEN) ;
    }
    if (LockWindowUpdate(hwndScr = GetDesktopWindow ()))
    {
        hdc  = GetDCEx (hwndScr, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
        hdcMem = CreateCompatibleDC (hdc) ;
        if(NULL==hdcMem)
        {
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        hemfCopy = CreateCompatibleBitmap (hdc, abs(dstcx), abs(dstcy)) ;
        if(NULL==hemfCopy)
        {
            DeleteDC (hdcMem) ;
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        SelectObject (hdcMem, hemfCopy) ;
        if(lpRect)
            StretchBlt (hdcMem, 0, 0, abs(dstcx), abs(dstcy),
                hdc, lpRect->left, lpRect->top, dstcx, dstcy, SRCCOPY|CAPTUREBLT) ;
        else
            BitBlt (hdcMem, 0, 0, dstcx, dstcy,
                hdc, 0, 0, SRCCOPY|CAPTUREBLT) ;
        DeleteDC (hdcMem) ;
        ReleaseDC (hwndScr, hdc) ;
        LockWindowUpdate (NULL) ;
        return hemfCopy;
    }
    return NULL;
}

#endif
英语不好,确实是编程的短板。。。。
小君履冰 2016-09-22
  • 打赏
  • 举报
回复
引用 2 楼 赵4老师的回复:
仅供参考:
#pragma comment(lib,"gdi32")
#include <windows.h>
#include <vector>
using namespace std;
// 获取HDC的数据
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.bmiHeader.biWidth,bmpInfo.bmiHeader.biHeight};
        SIZE sizeDC = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};
        StretchBlt(hdcMem,
                    0,
                    0,
                    sizeImg.cx,
                    sizeImg.cy,
                    hdc,
                    rcDC.left,
                    rcDC.top,
                    sizeDC.cx,
                    sizeDC.cy,
                    SRCCOPY|0x40000000);//CAPTUREBLT


        vtBuf.resize(sizeImg.cx * sizeImg.cy * 3);
        memcpy(&vtBuf[0],pData,vtBuf.size());

        SelectObject(hdcMem, hOldObj);

        bRes = TRUE;

    }
    __finally
    {

        if (hBmp != NULL)
        {
            DeleteObject(hBmp);
        }

        if (hdcMem != NULL)
        {
            DeleteDC(hdcMem);
        }
    }

    return bRes;
}
// 保存HDC为BMP文件
BOOL WriteBmp(const char *strFile,HDC hdc,const RECT &rcDC)
{
    std::vector<BYTE> vtData;
    if (GetHDCData(hdc,rcDC,vtData) == FALSE)
    {
        return FALSE;
    }

    SIZE sizeImg = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};

    BITMAPINFOHEADER bmInfoHeader = {0};
    bmInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmInfoHeader.biWidth = sizeImg.cx;
    bmInfoHeader.biHeight = sizeImg.cy;
    bmInfoHeader.biPlanes = 1;
    bmInfoHeader.biBitCount = 24;

    //Bimap file header in order to write bmp file
    BITMAPFILEHEADER bmFileHeader = {0};
    bmFileHeader.bfType = 0x4d42;  //bmp
    bmFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    bmFileHeader.bfSize = bmFileHeader.bfOffBits + ((bmInfoHeader.biWidth * bmInfoHeader.biHeight) * 3); ///3=(24 / 8)

    HANDLE hFile = CreateFile(strFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        return FALSE;
    }

    DWORD dwWrite = 0;
    WriteFile(hFile,&bmFileHeader,sizeof(BITMAPFILEHEADER),&dwWrite,NULL);
    WriteFile(hFile,&bmInfoHeader, sizeof(BITMAPINFOHEADER),&dwWrite,NULL);
    WriteFile(hFile,&vtData[0], vtData.size(),&dwWrite,NULL);


    CloseHandle(hFile);

    return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

    HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
    RECT rcSave = {0,0,GetDeviceCaps(hdc,HORZRES),GetDeviceCaps(hdc,VERTRES)};
    WriteBmp("D:\\ScreenCapture.BMP",hdc,rcSave);
    DeleteDC(hdc);

    return 0;
}

#if 0

#ifndef CAPTUREBLT
#define CAPTUREBLT 0x40000000
#endif
HBITMAP CaptureScreen(LPRECT lpRect)//lpRect为NULL时表示全屏幕截图
{
    HDC      hdc, hdcMem ;
    HBITMAP  hemfCopy ;
    HWND     hwndScr ;
    int      dstcx, dstcy ;
    if(lpRect)
    {
        dstcx = lpRect->right - lpRect->left ;
        dstcy = lpRect->bottom - lpRect->top ;
    }
    else
    {
        dstcx = GetSystemMetrics(SM_CXSCREEN) ;
        dstcy = GetSystemMetrics(SM_CYSCREEN) ;
    }
    if (LockWindowUpdate(hwndScr = GetDesktopWindow ()))
    {
        hdc  = GetDCEx (hwndScr, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
        hdcMem = CreateCompatibleDC (hdc) ;
        if(NULL==hdcMem)
        {
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        hemfCopy = CreateCompatibleBitmap (hdc, abs(dstcx), abs(dstcy)) ;
        if(NULL==hemfCopy)
        {
            DeleteDC (hdcMem) ;
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        SelectObject (hdcMem, hemfCopy) ;
        if(lpRect)
            StretchBlt (hdcMem, 0, 0, abs(dstcx), abs(dstcy),
                hdc, lpRect->left, lpRect->top, dstcx, dstcy, SRCCOPY|CAPTUREBLT) ;
        else
            BitBlt (hdcMem, 0, 0, dstcx, dstcy,
                hdc, 0, 0, SRCCOPY|CAPTUREBLT) ;
        DeleteDC (hdcMem) ;
        ReleaseDC (hwndScr, hdc) ;
        LockWindowUpdate (NULL) ;
        return hemfCopy;
    }
    return NULL;
}

#endif
赵4老师!你总是如此专业我也拜你为师!
赵4老师 2016-09-22
  • 打赏
  • 举报
回复
仅供参考:
#pragma comment(lib,"gdi32")
#include <windows.h>
#include <vector>
using namespace std;
// 获取HDC的数据
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.bmiHeader.biWidth,bmpInfo.bmiHeader.biHeight};
        SIZE sizeDC = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};
        StretchBlt(hdcMem,
                    0,
                    0,
                    sizeImg.cx,
                    sizeImg.cy,
                    hdc,
                    rcDC.left,
                    rcDC.top,
                    sizeDC.cx,
                    sizeDC.cy,
                    SRCCOPY|0x40000000);//CAPTUREBLT


        vtBuf.resize(sizeImg.cx * sizeImg.cy * 3);
        memcpy(&vtBuf[0],pData,vtBuf.size());

        SelectObject(hdcMem, hOldObj);

        bRes = TRUE;

    }
    __finally
    {

        if (hBmp != NULL)
        {
            DeleteObject(hBmp);
        }

        if (hdcMem != NULL)
        {
            DeleteDC(hdcMem);
        }
    }

    return bRes;
}
// 保存HDC为BMP文件
BOOL WriteBmp(const char *strFile,HDC hdc,const RECT &rcDC)
{
    std::vector<BYTE> vtData;
    if (GetHDCData(hdc,rcDC,vtData) == FALSE)
    {
        return FALSE;
    }

    SIZE sizeImg = {rcDC.right - rcDC.left,rcDC.bottom - rcDC.top};

    BITMAPINFOHEADER bmInfoHeader = {0};
    bmInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmInfoHeader.biWidth = sizeImg.cx;
    bmInfoHeader.biHeight = sizeImg.cy;
    bmInfoHeader.biPlanes = 1;
    bmInfoHeader.biBitCount = 24;

    //Bimap file header in order to write bmp file
    BITMAPFILEHEADER bmFileHeader = {0};
    bmFileHeader.bfType = 0x4d42;  //bmp
    bmFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
    bmFileHeader.bfSize = bmFileHeader.bfOffBits + ((bmInfoHeader.biWidth * bmInfoHeader.biHeight) * 3); ///3=(24 / 8)

    HANDLE hFile = CreateFile(strFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        return FALSE;
    }

    DWORD dwWrite = 0;
    WriteFile(hFile,&bmFileHeader,sizeof(BITMAPFILEHEADER),&dwWrite,NULL);
    WriteFile(hFile,&bmInfoHeader, sizeof(BITMAPINFOHEADER),&dwWrite,NULL);
    WriteFile(hFile,&vtData[0], vtData.size(),&dwWrite,NULL);


    CloseHandle(hFile);

    return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

    HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
    RECT rcSave = {0,0,GetDeviceCaps(hdc,HORZRES),GetDeviceCaps(hdc,VERTRES)};
    WriteBmp("D:\\ScreenCapture.BMP",hdc,rcSave);
    DeleteDC(hdc);

    return 0;
}

#if 0

#ifndef CAPTUREBLT
#define CAPTUREBLT 0x40000000
#endif
HBITMAP CaptureScreen(LPRECT lpRect)//lpRect为NULL时表示全屏幕截图
{
    HDC      hdc, hdcMem ;
    HBITMAP  hemfCopy ;
    HWND     hwndScr ;
    int      dstcx, dstcy ;
    if(lpRect)
    {
        dstcx = lpRect->right - lpRect->left ;
        dstcy = lpRect->bottom - lpRect->top ;
    }
    else
    {
        dstcx = GetSystemMetrics(SM_CXSCREEN) ;
        dstcy = GetSystemMetrics(SM_CYSCREEN) ;
    }
    if (LockWindowUpdate(hwndScr = GetDesktopWindow ()))
    {
        hdc  = GetDCEx (hwndScr, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
        hdcMem = CreateCompatibleDC (hdc) ;
        if(NULL==hdcMem)
        {
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        hemfCopy = CreateCompatibleBitmap (hdc, abs(dstcx), abs(dstcy)) ;
        if(NULL==hemfCopy)
        {
            DeleteDC (hdcMem) ;
            ReleaseDC (hwndScr, hdc) ;
            LockWindowUpdate (NULL) ;
            return NULL;
        }
        SelectObject (hdcMem, hemfCopy) ;
        if(lpRect)
            StretchBlt (hdcMem, 0, 0, abs(dstcx), abs(dstcy),
                hdc, lpRect->left, lpRect->top, dstcx, dstcy, SRCCOPY|CAPTUREBLT) ;
        else
            BitBlt (hdcMem, 0, 0, dstcx, dstcy,
                hdc, 0, 0, SRCCOPY|CAPTUREBLT) ;
        DeleteDC (hdcMem) ;
        ReleaseDC (hwndScr, hdc) ;
        LockWindowUpdate (NULL) ;
        return hemfCopy;
    }
    return NULL;
}

#endif
赵4老师 2016-09-22
  • 打赏
  • 举报
回复
BitBlt The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. BOOL BitBlt( HDC hdcDest, // handle to destination device context int nXDest, // x-coordinate of destination rectangle's upper-left // corner int nYDest, // y-coordinate of destination rectangle's upper-left // corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle HDC hdcSrc, // handle to source device context int nXSrc, // x-coordinate of source rectangle's upper-left // corner int nYSrc, // y-coordinate of source rectangle's upper-left // corner DWORD dwRop // raster operation code ); Parameters hdcDest Handle to the destination device context. nXDest Specifies the logical x-coordinate of the upper-left corner of the destination rectangle. nYDest Specifies the logical y-coordinate of the upper-left corner of the destination rectangle. nWidth Specifies the logical width of the source and destination rectangles. nHeight Specifies the logical height of the source and the destination rectangles. hdcSrc Handle to the source device context. nXSrc Specifies the logical x-coordinate of the upper-left corner of the source rectangle. nYSrc Specifies the logical y-coordinate of the upper-left corner of the source rectangle. dwRop Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color. The following list shows some common raster operation codes: Value Description BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.) DSTINVERT Inverts the destination rectangle. MERGECOPY Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator. MERGEPAINT Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator. NOTSRCCOPY Copies the inverted source rectangle to the destination. NOTSRCERASE Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color. PATCOPY Copies the specified pattern into the destination bitmap. PATINVERT Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator. PATPAINT Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator. SRCAND Combines the colors of the source and destination rectangles by using the Boolean AND operator. SRCCOPY Copies the source rectangle directly to the destination rectangle. SRCERASE Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator. SRCINVERT Combines the colors of the source and destination rectangles by using the Boolean XOR operator. SRCPAINT Combines the colors of the source and destination rectangles by using the Boolean OR operator. WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.) Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT: To get extended error information, callGetLastError. Remarks If a rotation or shear transformation is in effect in the source device context, BitBlt returns an error. If other transformations exist in the source device context (and a matching transformation is not in effect in the destination device context), the rectangle in the destination device context is stretched, compressed, or rotated as necessary. If the color formats of the source and destination device contexts do not match, the BitBlt function converts the source color format to match the destination format. When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context. Not all devices support the BitBlt function. For more information, see the RC_BITBLT raster capability entry in the GetDeviceCaps function as well as the following functions: MaskBlt, PlgBlt, StretchBlt. BitBlt returns an error if the source and destination device contexts represent different devices. ICM: No color management is performed when blits occur. Windows CE: In Windows CE version 1.0, the dwRop parameter can only be assigned the following values: SRCCOPY SRCAND SRCPAINT SRCINVERT In Windows CE version 2.0, the dwRop parameter can be any ROP3. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in wingdi.h. Import Library: Use gdi32.lib. See Also Bitmaps Overview, Bitmap Functions

18,124

社区成员

发帖
与我相关
我的任务
社区描述
Windows客户端使用相关问题交流社区
社区管理员
  • Windows客户端使用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧