📄 image.cpp
字号:
const UCHAR CRGB24Synthesizer::Colors [MAX_COLOR][3] = {
{0, 0, 0}, // BLACK
{255, 255, 255}, // WHITE
{0, 255, 255}, // YELLOW
{255, 255, 0}, // CYAN
{0, 255, 0}, // GREEN
{255, 0, 255}, // MAGENTA
{0, 0, 255}, // RED
{255, 0, 0}, // BLUE
{128, 128, 128} // GREY
};
const UCHAR CYUVSynthesizer::Colors [MAX_COLOR][3] = {
{128, 16, 128}, // BLACK
{128, 235, 128}, // WHITE
{16, 211, 146}, // YELLOW
{166, 170, 16}, // CYAN
{54, 145, 34}, // GREEN
{202, 106, 222}, // MAGENTA
{90, 81, 240}, // RED
{240, 41, 109}, // BLUE
{128, 125, 128}, // GREY
};
/**************************************************************************
LOCKED CODE
**************************************************************************/
#ifdef ALLOC_PRAGMA
#pragma code_seg()
#endif // ALLOC_PRAGMA
void
CImageSynthesizer::
SynthesizeBars (
)
/*++
Routine Description:
Synthesize EIA-189-A standard color bars onto the Image. The image
in question is the current synthesis buffer.
Arguments:
None
Return Value:
None
--*/
{
const COLOR *CurColor = g_ColorBars;
ULONG ColorCount = SIZEOF_ARRAY (g_ColorBars);
//
// Set the default cursor...
//
GetImageLocation (0, 0);
//
// Synthesize a single line.
//
PUCHAR ImageStart = m_Cursor;
for (ULONG x = 0; x < m_Width; x++)
PutPixel (g_ColorBars [((x * ColorCount) / m_Width)]);
PUCHAR ImageEnd = m_Cursor;
//
// Copy the synthesized line to all subsequent lines.
//
for (ULONG line = 1; line < m_Height; line++) {
GetImageLocation (0, line);
RtlCopyMemory (
m_Cursor,
ImageStart,
ImageEnd - ImageStart
);
}
}
/*************************************************/
void
CImageSynthesizer::
OverlayText (
ULONG LocX,
ULONG LocY,
ULONG Scaling,
CHAR *Text,
COLOR BgColor,
COLOR FgColor
)
/*++
Routine Description:
Overlay text onto the synthesized image. Clip to fit the image
if the overlay does not fit. The image buffer used is the set
synthesis buffer.
Arguments:
LocX -
The X location on the image to begin the overlay. This MUST
be inside the image. POSITION_CENTER may be used to indicate
horizontal centering.
LocY -
The Y location on the image to begin the overlay. This MUST
be inside the image. POSITION_CENTER may be used to indicate
vertical centering.
Scaling -
Normally, the overlay is done in 8x8 font. A scaling of
2 indicates 16x16, 3 indicates 24x24 and so forth.
Text -
A character string containing the information to overlay
BgColor -
The background color of the overlay window. For transparency,
indicate TRANSPARENT here.
FgColor -
The foreground color for the text overlay.
Return Value:
None
--*/
{
ASSERT ((LocX <= m_Width || LocX == POSITION_CENTER) &&
(LocY <= m_Height || LocY == POSITION_CENTER));
ULONG StrLen = 0;
//
// Determine the character length of the string.
//
for (CHAR *CurChar = Text; CurChar && *CurChar; CurChar++)
StrLen++;
//
// Determine the physical size of the string plus border. There is
// a definable NO_CHARACTER_SEPARATION. If this is defined, there will
// be no added space between font characters. Otherwise, one empty pixel
// column is added between characters.
//
#ifndef NO_CHARACTER_SEPARATION
ULONG LenX = (StrLen * (Scaling << 3)) + 1 + StrLen;
#else // NO_CHARACTER_SEPARATION
ULONG LenX = (StrLen * (Scaling << 3)) + 2;
#endif // NO_CHARACTER_SEPARATION
ULONG LenY = 2 + (Scaling << 3);
//
// Adjust for center overlays.
//
// NOTE: If the overlay doesn't fit into the synthesis buffer, this
// merely left aligns the overlay and clips off the right side.
//
if (LocX == POSITION_CENTER) {
if (LenX >= m_Width) {
LocX = 0;
} else {
LocX = (m_Width >> 1) - (LenX >> 1);
}
}
if (LocY == POSITION_CENTER) {
if (LenY >= m_Height) {
LocY = 0;
} else {
LocY = (m_Height >> 1) - (LenY >> 1);
}
}
//
// Determine the amount of space available on the synthesis buffer.
// We will clip anything that finds itself outside the synthesis buffer.
//
ULONG SpaceX = m_Width - LocX;
ULONG SpaceY = m_Height - LocY;
//
// Set the default cursor position.
//
GetImageLocation (LocX, LocY);
//
// Overlay a background color row.
//
if (BgColor != TRANSPARENT && SpaceY) {
for (ULONG x = 0; x < LenX && x < SpaceX; x++) {
PutPixel (BgColor);
}
}
LocY++;
if (SpaceY) SpaceY--;
//
// Loop across each row of the image.
//
for (ULONG row = 0; row < 8 && SpaceY; row++) {
//
// Generate a line.
//
GetImageLocation (LocX, LocY++);
PUCHAR ImageStart = m_Cursor;
ULONG CurSpaceX = SpaceX;
if (CurSpaceX) {
PutPixel (BgColor);
CurSpaceX--;
}
//
// Generate the row'th row of the overlay.
//
CurChar = Text;
while (CurChar && *CurChar) {
UCHAR CharBase = g_FontData [*CurChar++][row];
for (ULONG mask = 0x80; mask && CurSpaceX; mask >>= 1) {
for (ULONG scale = 0; scale < Scaling && CurSpaceX; scale++) {
if (CharBase & mask) {
PutPixel (FgColor);
} else {
PutPixel (BgColor);
}
CurSpaceX--;
}
}
//
// Separate each character by one space. Account for the border
// space at the end by placing the separator after the last
// character also.
//
#ifndef NO_CHARACTER_SEPARATION
if (CurSpaceX) {
PutPixel (BgColor);
CurSpaceX--;
}
#endif // NO_CHARACTER_SEPARATION
}
//
// If there is no separation character defined, account for the
// border.
//
#ifdef NO_CHARACTER_SEPARATION
if (CurSpaceX) {
PutPixel (BgColor);
CurSpaceX--;
}
#endif // NO_CHARACTER_SEPARATION
PUCHAR ImageEnd = m_Cursor;
//
// Copy the line downward scale times.
//
for (ULONG scale = 1; scale < Scaling && SpaceY; scale++) {
GetImageLocation (LocX, LocY++);
RtlCopyMemory (m_Cursor, ImageStart, ImageEnd - ImageStart);
SpaceY--;
}
}
//
// Add the bottom section of the overlay.
//
GetImageLocation (LocX, LocY);
if (BgColor != TRANSPARENT && SpaceY) {
for (ULONG x = 0; x < LenX && x < SpaceX; x++) {
PutPixel (BgColor);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -