📄 sd0132.h
字号:
//
// Windows CE Software Graphics Library
// sd0132.h
//
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
//
// This header file contains the function template for special case blit
// routines with 1 bit source and 32 bit destination surfaces. This code
// does not stretch, colorkey, mask, clip, or blend.
#if !defined(FUNCTION)
#error Must define FUNCTION
#endif
#if !defined(DWORD_OP)
#error Must define DWORD_OP
#endif
BOOL
FUNCTION(
BLT_PARAM * Parameters
)
{
// Local variables.
// Source-related info.
const RECT * SrcRect = Parameters->SourceRect;
LONG SrcScanStride = Parameters->Source->Stride;
BYTE * SrcScanLine = (BYTE *)Parameters->Source->Ptr +
SrcRect->top * SrcScanStride +
(SrcRect->left >> 3);
// Destination-related info.
const RECT * DstRect = Parameters->DestRect;
LONG DstScanStride = Parameters->Destination->Stride / sizeof(DWORD);
DWORD * DstScanLine = (DWORD *)Parameters->Destination->Ptr +
DstRect->top * DstScanStride +
DstRect->left;
ULONG SourceColors[2];
ULONG Rows = RectHeight(DstRect);
ULONG Cols = RectWidth(DstRect);
ULONG FirstBit;
ULONG StartAlignment;
ULONG EndAlignment;
ULONG WholeCols;
ULONG Preshift;
ULONG Row, Col;
BYTE * SrcPixel;
DWORD * DstPixel;
register BYTE SrcValue;
// Check parameters.
// !TODO!
FirstBit = (8 - (SrcRect->left & 0x7));
if (Cols >= 8) {
// We know that we will make at least one byte boundary, and hence
// do not need a preshift, we need only read to the boundary.
Preshift = 0;
StartAlignment = FirstBit & 0x7;
}
else {
// All of the bits we need are within a single byte. (eg. Cols should
// never be greater than FirstBit here: that would imply that we are
// crossing a byte boundary.)
Preshift = FirstBit - Cols;
StartAlignment = Cols;
}
WholeCols = (Cols - StartAlignment) >> 3;
EndAlignment = (Cols - StartAlignment) & 0x7;
// Lookup the palette for the source surface for use in calling the
// DWORD_OP macro. Use black and white as a default if there is no
// palette.
if (Parameters->Source->Format->FourCC == FOURCC_PAL) {
memcpy(SourceColors,
Parameters->Source->Format->Palette,
2 * sizeof(ULONG));
}
else {
SourceColors[0] = 0x00000000;
SourceColors[1] = 0xFFFFFFFF;
}
for (Row = 0; Row < Rows; Row++) {
// Set up pointers to first bytes on source and destination scanlines.
SrcPixel = SrcScanLine;
DstPixel = DstScanLine;
// Do the unaligned first couple bits.
SrcValue = (*SrcPixel) >> Preshift;
switch (StartAlignment) {
case 7:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 6) & 0x1]);
case 6:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 5) & 0x1]);
case 5:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 4) & 0x1]);
case 4:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 3) & 0x1]);
case 3:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 2) & 0x1]);
case 2:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 1) & 0x1]);
case 1:
*DstPixel++ = DWORD_OP(*DstPixel, SourceColors[SrcValue & 0x1]);
SrcPixel++;
}
// Do the main aligned loop.
for (Col = 0; Col < WholeCols; Col++ ) {
SrcValue = *SrcPixel;
*(DstPixel + 7) = DWORD_OP(*(DstPixel + 7), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 6) = DWORD_OP(*(DstPixel + 6), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 5) = DWORD_OP(*(DstPixel + 5), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 4) = DWORD_OP(*(DstPixel + 4), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 3) = DWORD_OP(*(DstPixel + 3), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 2) = DWORD_OP(*(DstPixel + 2), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel + 1) = DWORD_OP(*(DstPixel + 1), SourceColors[SrcValue & 0x1]);
SrcValue = SrcValue >> 1;
*(DstPixel) = DWORD_OP(*DstPixel, SourceColors[SrcValue & 0x1]);
DstPixel += 8;
SrcPixel++;
}
// Do the unaligned end bits.
SrcValue = *SrcPixel;
switch (EndAlignment) {
case 7: *(DstPixel + 6) = DWORD_OP(*(DstPixel + 6), SourceColors[(SrcValue >> 1) & 0x1]);
case 6: *(DstPixel + 5) = DWORD_OP(*(DstPixel + 5), SourceColors[(SrcValue >> 2) & 0x1]);
case 5: *(DstPixel + 4) = DWORD_OP(*(DstPixel + 4), SourceColors[(SrcValue >> 3) & 0x1]);
case 4: *(DstPixel + 3) = DWORD_OP(*(DstPixel + 3), SourceColors[(SrcValue >> 4) & 0x1]);
case 3: *(DstPixel + 2) = DWORD_OP(*(DstPixel + 2), SourceColors[(SrcValue >> 5) & 0x1]);
case 2: *(DstPixel + 1) = DWORD_OP(*(DstPixel + 1), SourceColors[(SrcValue >> 6) & 0x1]);
case 1: *DstPixel = DWORD_OP(*DstPixel, SourceColors[(SrcValue >> 7) & 0x1]);
case 0: break;
}
// Advance to next scanline.
SrcScanLine += SrcScanStride;
DstScanLine += DstScanStride;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -