gdidrv32b.c
来自「深圳市微逻辑电子有限公司 巨果• Kingmos® 系统核心」· C语言 代码 · 共 937 行 · 第 1/2 页
C
937 行
register LPDWORD lpDestStart;
register DWORD clrFore, clrBack;
register BYTE pattern;
//得到开始地址
lpDestStart = (LPDWORD)(lpLineData->lpDestImage->bmBits + lpLineData->lpDestImage->bmWidthBytes * y0) + x0;
//前景色和背景色
clrFore = (DWORD)lpLineData->color;
clrBack = (DWORD)lpLineData->clrBack;
pattern = lpLineData->pattern;
if( lpLineData->rop == R2_COPYPEN )
{ //拷贝
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
if( pattern & patternMask[ x0 & 0x07 ] )
*lpDestStart = (DWORD)clrFore;
else
*lpDestStart = (DWORD)clrBack;
}
}
else if( lpLineData->rop == R2_XORPEN )
{ //异或
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
if( pattern & patternMask[x0&0x07] )
*lpDestStart ^= clrFore;
else
*lpDestStart ^= clrBack;
}
}
else if( lpLineData->rop == R2_NOT )
{ //非
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
*lpDestStart = ~*lpDestStart;
}
}
return TRUE;
}
// *****************************************************************
//声明:static BOOL __ScanTransparentLine( _LPLINEDATA lpLineData,
// int x0,
// int y0,
// int xDir,
// unsigned int uLen )
//参数:
// IN lpLineData - _LINEDATA结构指针,包含画线需要的数据
// IN x0 - 起点 x 坐标
// IN y0 - 起点 y 坐标
// IN xDir - 方向(当 < 0 , 由右向左)
// IN uLen - 点数
//返回值:
// 返回TRUE
//功能描述:
// 带模板用纯色画透明水平线
//引用:
// 被 line.h 使用
// *****************************************************************
static BOOL __ScanTransparentLine( _LPLINEDATA lpLineData, int x0, int y0, int xDir, unsigned int uLen )
{
register LPDWORD lpDestStart;
register DWORD clrFore;
register BYTE pattern;
//得到目标地址
lpDestStart = (LPDWORD)(lpLineData->lpDestImage->bmBits + lpLineData->lpDestImage->bmWidthBytes * y0 ) + x0;
clrFore = (DWORD)lpLineData->color;
pattern = lpLineData->pattern;
//根据操作模式做不同的处理
if( lpLineData->rop == R2_COPYPEN )
{ //拷贝
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
if( pattern & patternMask[x0&0x07] )
*lpDestStart = (DWORD)clrFore;
}
}
else if( lpLineData->rop == R2_XORPEN )
{ //异或
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
if( pattern & patternMask[x0&0x07] )
*lpDestStart ^= (DWORD)clrFore;
}
}
else if( lpLineData->rop == R2_NOT )
{ //非
for( ; uLen; lpDestStart += xDir, x0 += xDir, uLen-- )
{
*lpDestStart = ~*lpDestStart;
}
}
return TRUE;
}
#include "..\include\line.h"
#define _SRCCOPY 0xCC // dest = source
#define _SRCPAINT 0xEE // dest = source OR dest
#define _SRCAND 0x88 // dest = source AND dest
#define _SRCINVERT 0x66 // dest = source XOR dest
/*
static void __MoveBits( LPBYTE lpDest, int nBits, LPCBYTE lpSrc, WORD count )
{
int vBits;
if( nBits > 0 ) // >>
{
*lpDest++ = *lpSrc++ >> nBits;
vBits = 8 - nBits;
count--;
while( count )
{
*lpDest = (((WORD)*(lpSrc-1)) << vBits ) | (*lpSrc >> nBits);
lpDest++; lpSrc++;
count--;
}
// end byte
*lpDest = *(lpSrc-1) << vBits;
}
else if( nBits < 0 ) // <<
{
nBits = -nBits;
vBits = 8-nBits;
count--; // read for end byte
while( count )
{
*lpDest = (*lpSrc << nBits) | (*(lpSrc+1) >> vBits);
lpDest++; lpSrc++;
count--;
}
// end byte
*lpDest = *lpSrc << nBits;
}
else // No move
{
while( count )
{
*lpDest++ = *lpSrc++;
count--;
}
}
}
*/
// *****************************************************************
//声明:static BOOL __BltFillTransparentPattern( _LPBLKBITBLT lpData )
//参数:
// IN lpData - _BLKBITBLT结构指针
//返回值:
// 返回TRUE
//功能描述:
// 用纯色输出透明位模(当位模bit为1时,输出;否则不输出)
//引用:
//
// *****************************************************************
static BOOL __BltFillTransparentPattern( _LPBLKBITBLT lpData )
{
LPDWORD lpDestStart, lpDest;
LPCBYTE lpPattern;
DWORD clrFore, widthBytes;
int i, j, n, rows, cols, shift;
BYTE mask, bitMask;
//目标开始地址
lpDestStart = (LPDWORD)(lpData->lpDestImage->bmBits + lpData->lprcDest->top * lpData->lpDestImage->bmWidthBytes) + lpData->lprcDest->left;
lpPattern = lpData->lpBrush->pattern;
rows = lpData->lprcDest->bottom - lpData->lprcDest->top;
cols = lpData->lprcDest->right - lpData->lprcDest->left;
shift = lpData->lprcMask->left & 0x07;
clrFore = (DWORD)lpData->lpBrush->color;
n = lpData->lprcDest->top;
//扫描行字节数
widthBytes = lpData->lpDestImage->bmWidthBytes;
//对每一行进行操作
for( i = 0; i < rows; i++ )
{
mask = *(lpPattern+(n&0x07));
n++;
bitMask = 0x80 >> shift;
lpDest = lpDestStart;
for( j = 0; j < cols; j++ )
{
if( bitMask == 0 )
{
bitMask = 0x80;
}
if( mask & bitMask )
{
*lpDest = (DWORD)clrFore;
}
lpDest++;
bitMask >>= 1;
}
lpDestStart = (LPDWORD)((LPBYTE)lpDestStart + widthBytes);
}
return TRUE;
}
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __TextSrcCopy3201
#define BLT_ROP( bDst, bSrc ) ( (bSrc) )
#include "textblt.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __TextNotSrcCopy3201
#define BLT_ROP( bDst, bSrc ) ( ~(bSrc) )
#include "textblt.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __TextSrcInvert3201
#define BLT_ROP( bDst, bSrc ) ( (bDst) ^ (bSrc) )
#include "textblt.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __TextSrcAnd3201
#define BLT_ROP( bDst, bSrc ) ( (bDst) & (bSrc) )
#include "textblt.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __TextTransparentBlt3201
#define BLT_ROP( bDst, bSrc ) ( (bSrc) )
#include "txttpblt.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltFillPattern
#define BLT_ROP( bDst, bSrc ) ( (bSrc) )
#include "bltfpat.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltPatInvertPattern
#define BLT_ROP( bDst, bSrc ) ( (bDst) ^ (bSrc) )
#include "bltfpat.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltMergeCopy
#define BLT_ROP( bSrc, bBrush ) ( (bSrc) & (bBrush) )
#include "bltmpat.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltSrcCopy
#define BLT_ROP( bDst, bSrc ) ( (bSrc) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltSrcAnd3232
#define BLT_ROP( bDst, bSrc ) ( (bDst) & (bSrc) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltNotSrcCopy3232
#define BLT_ROP( bDst, bSrc ) ( ~(bSrc) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltSrcInvert3232
#define BLT_ROP( bDst, bSrc ) ( (bDst) ^ (bSrc) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltSrcPaint
#define BLT_ROP( bDst, bSrc ) ( (bDst) | (bSrc) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltMergePaint
#define BLT_ROP( bDst, bSrc ) ( (bDst) | (~(bSrc)) )
#include "bltcpy.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltFillSolid
#define BLT_ROP( bDst, bColor ) ( (bColor) )
#include "bltfill.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltPatInvertSolid
#define BLT_ROP( bDst, bSrc ) ( (bDst) ^ (bSrc) )
#include "bltfill.h"
#undef FUNCTION
#undef BLT_ROP
#define FUNCTION __BltDstInvert
#define BLT_ROP( bDst, bSrc ) (~(bDst))
#include "bltfill.h"
// *****************************************************************
//声明:static BOOL _BlkBitTransparentBlt( _LPBLKBITBLT lpData )
//参数:
// IN lpData - _BLKBITBLT结构指针
//返回值:
// 返回TRUE
//功能描述:
// 透明输出位模(当位模bit为1时,输出;否则不输出)
//引用:
//
// *****************************************************************
static BOOL _BlkBitTransparentBlt( _LPBLKBITBLT lpData )
{
if( lpData->lpBrush )
return __BltFillTransparentPattern( lpData );
else if( lpData->lpSrcImage->bmBitsPixel == 1 )
{
return __TextTransparentBlt3201( lpData );
}
return FALSE;
}
#undef FUNCTION
#undef MASK_BLT_ROP
#define MASK_BLT_ROP( bDest, bSrc, bMask ) ( (bMask) ? (bSrc) : ( (bSrc) ^ (bDest) ) )
#define FUNCTION __BltMaskSrcCopySrcInvert
#include "bltmask.h"
#undef FUNCTION
#undef MASK_BLT_ROP
#define MASK_BLT_ROP( bDest, bSrc, bMask ) ((bMask) ? (bSrc) : ( (bSrc) ^ (bDest) ) )
#define FUNCTION __BltMaskBit1SrcCopySrcInvert
#include "bltmask1.h"
#undef FUNCTION
#undef MASK_BLT_ROP
#define MASK_BLT_ROP( bDest, bSrc, bMask ) ( (bMask) ? (bSrc) : (bDest) )
#define FUNCTION __BltMaskSrcCopyDestCopy
#include "bltmask.h"
#undef FUNCTION
#undef MASK_BLT_ROP
#define MASK_BLT_ROP( bDest, bSrc, bMask ) ( (bMask) ? (bSrc) : (bDest) )
#define FUNCTION __BltMaskBit1SrcCopyDestCopy
#include "bltmask1.h"
// *****************************************************************
//声明:static BOOL _BlkBitMaskBlt( _LPBLKBITBLT lpData )
//参数:
// IN lpData - _BLKBITBLT结构指针
//返回值:
// 成功TRUE
//功能描述:
// 带屏蔽位的位块传送
//引用:
//
// *****************************************************************
static BOOL _BlkBitMaskBlt( _LPBLKBITBLT lpData )
{
if( lpData->lpMaskImage->bmBitsPixel == 1 )
{
if( lpData->dwRop == MAKEROP4(SRCCOPY, SRCINVERT) )
{
if( lpData->lpSrcImage->bmPlanes == 1 && lpData->lpSrcImage->bmBitsPixel == 1 )
{
return __BltMaskBit1SrcCopySrcInvert( lpData );
}
if( lpData->lpSrcImage->bmPlanes == 1 && lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltMaskSrcCopySrcInvert( lpData );
}
else if( lpData->dwRop == MAKEROP4(SRCCOPY, 0) )
{
if( lpData->lpSrcImage->bmPlanes == 1 && lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltMaskSrcCopyDestCopy( lpData );
if( lpData->lpSrcImage->bmPlanes == 1 && lpData->lpSrcImage->bmBitsPixel == 1 )
return __BltMaskBit1SrcCopyDestCopy( lpData );
}
}
return FALSE;
}
// *****************************************************************
//声明:static BOOL _BlkBitBlt( _LPBLKBITBLT lpData )
//参数:
// IN lpData - _BLKBITBLT结构指针
//返回值:
// 成功TRUE
//功能描述:
// 位块传送
//引用:
//
// *****************************************************************
static BOOL _BlkBitBlt( _LPBLKBITBLT lpData )
{
switch( lpData->dwRop )
{
case SRCCOPY:
if( lpData->lpSrcImage->bmBitsPixel == 1 ) // mono bitmap
{
return __TextSrcCopy3201( lpData );
}
else if( lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltSrcCopy( lpData );
case SRCAND:
if( lpData->lpSrcImage->bmBitsPixel == 1 ) // mono bitmap
{
return __TextSrcAnd3201( lpData );
}
else if( lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltSrcAnd3232( lpData );
case SRCINVERT:
if( lpData->lpSrcImage->bmBitsPixel == 1 ) // mono bitmap
{
return __TextSrcInvert3201( lpData );
}
else if( lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltSrcInvert3232( lpData );
case SRCPAINT:
return __BltSrcPaint( lpData );
case PATCOPY:
if( lpData->lpBrush == 0 )
return __BltFillSolid( lpData );
else
{
if( lpData->lpBrush->style == BS_SOLID )
{
lpData->solidColor = lpData->lpBrush->color;
return __BltFillSolid( lpData );
}
else
return __BltFillPattern( lpData );
}
case BLACKNESS:
lpData->solidColor = CL_BLACK;
return __BltFillSolid( lpData );
case WHITENESS:
lpData->solidColor = CL_WHITE;
return __BltFillSolid( lpData );
case PATINVERT:
if( lpData->lpBrush == 0 )
return __BltPatInvertSolid( lpData );
else
return __BltPatInvertPattern( lpData );
case DSTINVERT:
return __BltDstInvert( lpData );
case NOTSRCCOPY:
if( lpData->lpSrcImage->bmBitsPixel == 1 ) // mono bitmap
{
return __TextNotSrcCopy3201( lpData );
}
else if( lpData->lpSrcImage->bmBitsPixel == 32 )
return __BltNotSrcCopy3232( lpData );
case MERGECOPY:
if( lpData->lpBrush &&
lpData->lpSrcImage &&
lpData->lpSrcImage->bmBitsPixel == 32 )
{
return __BltMergeCopy( lpData );
}
case MERGEPAINT:
if( lpData->lpSrcImage )
return __BltMergePaint( lpData );
}
return FALSE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?