本文整理汇总了C++中PatBlt函数的典型用法代码示例。如果您正苦于以下问题:C++ PatBlt函数的具体用法?C++ PatBlt怎么用?C++ PatBlt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PatBlt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BltCard
/*
* internal
*/
static __inline VOID BltCard(HDC hdc, INT x, INT y, INT dx, INT dy, HDC hdcCard, DWORD dwRasterOp, BOOL bStretch)
{
if (bStretch)
{
StretchBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, CARD_WIDTH, CARD_HEIGHT, dwRasterOp);
} else
{
BitBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, dwRasterOp);
/*
* This is need when using Microsoft images, because they use two-color red/white images for
* red cards and thus needs fix-up of the edge to black color.
*/
#if 0
if (ISREDCARD(card))
{
PatBlt(hdc, x, y + 2, 1, dy - 4, BLACKNESS);
PatBlt(hdc, x + dx - 1, y + 2, 1, dy - 4, BLACKNESS);
PatBlt(hdc, x + 2, y, dx - 4, 1, BLACKNESS);
PatBlt(hdc, x + 2, y + dy - 1, dx - 4, 1, BLACKNESS);
SetPixel(hdc, x + 1, y + 1, 0);
SetPixel(hdc, x + dx - 2, y + 1, 0);
SetPixel(hdc, x + 1, y + dy - 2, 0);
SetPixel(hdc, x + dx - 2, y + dy - 2, 0);
}
#endif
}
}
示例2: GetWindowDC
//-----------------------------------------------------------------------------
// Name: HighlightWindow (from MSDN Spy Sample)
// Object: highlight or unhightlight a window
// Parameters :
// in : HWND hwnd : target window handle
// BOOL fDraw : TRUE to draw, FALSE to clear
// Return : TRUE on success
//-----------------------------------------------------------------------------
void CSelectWindow::HighlightWindow( HWND hwnd, BOOL fDraw )
{
#define DINV 3
HDC hdc;
RECT rc;
BOOL bBorderOn;
bBorderOn = fDraw;
if (hwnd == NULL || !IsWindow(hwnd))
return;
hdc = GetWindowDC(hwnd);
GetWindowRect(hwnd, &rc);
OffsetRect(&rc, -rc.left, -rc.top);
if (!IsRectEmpty(&rc))
{
PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, DINV, DSTINVERT);
PatBlt(hdc, rc.left, rc.bottom - DINV, DINV,
-(rc.bottom - rc.top - 2 * DINV), DSTINVERT);
PatBlt(hdc, rc.right - DINV, rc.top + DINV, DINV,
rc.bottom - rc.top - 2 * DINV, DSTINVERT);
PatBlt(hdc, rc.right, rc.bottom - DINV, -(rc.right - rc.left),
DINV, DSTINVERT);
}
ReleaseDC(hwnd, hdc);
}
示例3: RenderTrackingRect
// utility function that uses the PatBlt function to
// render a tracking rectangle
void RenderTrackingRect(IN HDC HDestDC, IN const RECT& RRender)
{
const int width = RRender.right - RRender.left;
const int height = RRender.bottom - RRender.top;
const DWORD dwROP3 = DSTINVERT; // experiment with others
// render top bar
PatBlt(HDestDC,
RRender.left, RRender.top,
width, line_width,
dwROP3);
// render bottom bar
PatBlt(HDestDC,
RRender.left, RRender.bottom - line_width,
width, line_width,
dwROP3);
// render left bar
PatBlt(HDestDC,
RRender.left, RRender.top + line_width,
line_width, height - (2 * line_width),
dwROP3);
// render right bar
PatBlt(HDestDC,
RRender.right - line_width, RRender.top + line_width,
line_width, height - (2 * line_width),
dwROP3);
}
示例4: DrawUIBorder
void DrawUIBorder( LPRECT lprc )
{
HDC hDC;
int sbx, sby;
hDC = CreateDC( "DISPLAY", NULL, NULL, NULL );
SelectObject( hDC, GetStockObject( GRAY_BRUSH ) );
sbx = GetSystemMetrics( SM_CXBORDER );
sby = GetSystemMetrics( SM_CYBORDER );
PatBlt( hDC, lprc->left,
lprc->top,
lprc->right - lprc->left-sbx,
sby, PATINVERT );
PatBlt( hDC, lprc->right - sbx,
lprc->top,
sbx,
lprc->bottom - lprc->top-sby, PATINVERT );
PatBlt( hDC, lprc->right,
lprc->bottom-sby,
-(lprc->right - lprc->left-sbx),
sby, PATINVERT );
PatBlt( hDC, lprc->left,
lprc->bottom,
sbx,
-(lprc->bottom - lprc->top-sby), PATINVERT );
DeleteDC( hDC );
}
示例5: Win32_AspectBlt
static void Win32_AspectBlt( HDC hdc, win32BackBuffer_t *buffer, int width, int height ) {
if ( height == 0 ) {
height = 1;
}
if ( width == 0 ) {
width = 1;
}
float scale = 1.f;
int scaledWidth = buffer->width;
int scaledHeight = buffer->height;
if ( width < height ) {
scaledWidth = width;
scale = ( ( ( float ) width / ( float ) buffer->width ) + 0.5f );
scaledHeight = ( int ) ( ( scale * ( float ) buffer->height ) + 0.5f );
} else {
scaledHeight = height;
scale = ( ( ( float ) height / ( float ) buffer->height ) + 0.5f );
scaledWidth = ( int ) ( ( scale * ( float ) buffer->width ) + 0.5f );
}
int x = ( int ) ( ( ( width - scaledWidth ) / 2.f ) + 0.5f );
int y = ( int ) ( ( ( height - scaledHeight ) / 2.f ) + 0.5f );
PatBlt( hdc, 0, 0, width, height, WHITENESS );
PatBlt( hdc, x, y, scaledWidth, scaledHeight, BLACKNESS );
StretchDIBits( hdc,
x, y, scaledWidth, scaledHeight,
0, 0, buffer->width, buffer->height,
buffer->memory, &buffer->bitmapInfo,
DIB_RGB_COLORS, SRCCOPY );
/*PatBlt( hdc, 0, 0, x, y, WHITENESS );
PatBlt( hdc, x + scaledWidth, y + scaledHeight, width - x, height - y, WHITENESS );*/
}
示例6: highlightWindowFrame
/*
* highlightWindowFrame
*
* Highlight (or unhighlight) the specified
* window handle's frame.
*/
static void
highlightWindowFrame(HWND hWnd)
{
HDC hdc;
RECT rc;
if (!IsWindow(hWnd))
return;
hdc = GetWindowDC(hWnd);
GetWindowRect(hWnd, &rc);
OffsetRect(&rc, -rc.left, -rc.top);
if (!IsRectEmpty(&rc)) {
PatBlt(hdc, rc.left, rc.top, rc.right-rc.left, DINV, DSTINVERT);
PatBlt(hdc, rc.left, rc.bottom-DINV, DINV, -(rc.bottom-rc.top-2*DINV),
DSTINVERT);
PatBlt(hdc, rc.right-DINV, rc.top+DINV, DINV, rc.bottom-rc.top-2*DINV,
DSTINVERT);
PatBlt(hdc, rc.right, rc.bottom-DINV, -(rc.right-rc.left), DINV,
DSTINVERT);
}
ReleaseDC(hWnd, hdc);
UpdateWindow(hWnd);
}
示例7: Win32DisplayBufferInWindow
INTERNAL_LINKAGE int
Win32DisplayBufferInWindow(HDC deviceContext, Win32ScreenBuffer *screenBuffer, Win32WindowSize window_size)
{
int result = 0;
int offsetX = 10;
int offsetY = 10;
#if 0
// top
PatBlt(deviceContext, 0, 0, window_size.width, offsetY, BLACKNESS);
// left
PatBlt(deviceContext, 0, 0, offsetX, window_size.height, BLACKNESS);
// bottom
PatBlt(deviceContext, 0, screenBuffer->height + offsetY,
windowSize.width, windowSize.height, BLACKNESS);
// right
PatBlt(deviceContext, screenBuffer->width + offsetX, 0,
windowSize.width, windowSize.height, BLACKNESS);
#endif
result = StretchDIBits(deviceContext,
0, 0, window_size.width, window_size.height,
0, 0, screenBuffer->width, screenBuffer->height,
screenBuffer->memory,
(BITMAPINFO *)&screenBuffer->bitmapInfo,
DIB_RGB_COLORS, SRCCOPY);
return result;
}
示例8: DisplayStreamInfos
void DisplayStreamInfos(HWND hW)
{
HWND hWS=GetDlgItem(hW,IDC_SAREA);
HDC hdc;RECT r;HBRUSH hBO;int ch,dy,i,j,id;
//----------------------------------------------------//
GetClientRect(hWS,&r); // get size of stream display
hdc=GetDC(hWS); // device context
r.right--; // leave the right border intact
ScrollDC(hdc,-1,0,&r,&r,NULL,NULL); // scroll one pixel to the left
//----------------------------------------------------//
hBO = (HBRUSH) SelectObject(hdc,hBStream[0]); // clean the right border
PatBlt(hdc,r.right-1,0,1,r.bottom,PATCOPY);
//----------------------------------------------------//
dy=r.bottom/MAXCHAN; // size of one channel area
for(ch=0;ch<MAXCHAN;ch++) // loop the channels
{
if(s_chan[ch].iIrqDone)
{
s_chan[ch].iIrqDone=0;
PatBlt(hdc,r.right-1,ch*r.bottom/MAXCHAN,
1,dy,BLACKNESS);
continue;
}
if(s_chan[ch].bOn) // channel is on?
{
j=s_chan[ch].sval;if(j<0) j=-j; // -> get one channel data (-32k ... 32k)
j=(dy*j)/32768; if(j==0) j=1; // -> adjust to display coords
i=(dy/2)+(ch*r.bottom/MAXCHAN)-j/2; // -> position where to paint it
if (s_chan[ch].iMute) id=1; // -> get color id
else if(s_chan[ch].bNoise) id=2;
else if(s_chan[ch].bFMod==2) id=3;
else if(s_chan[ch].bFMod==1) id=4;
else id=5;
SelectObject(hdc,hBStream[id]); // -> select the brush
PatBlt(hdc,r.right-1,i,1,j,PATCOPY); // -> paint the value line
}
if(ch) SetPixel(hdc,r.right-1, // -> not first line?
ch*r.bottom/MAXCHAN,RGB(0,0,0)); // --> draw the line (one dot scrolled to the left)
}
//----------------------------------------------------//
SelectObject(hdc,hBO); // repair brush
ReleaseDC(hWS,hdc); // release context
}
示例9: DrawRectangle
void DrawRectangle(HDC hdc, int x1, int y1, int x2, int y2)
{
HGDIOBJ hOldBrush = ::SelectObject(hdc, ::GetSysColorBrush(COLOR_BTNSHADOW));
PatBlt(hdc, x1, y1, x2 - x1, 1, PATCOPY);
PatBlt(hdc, x1, y1, 1, y2 - y1, PATCOPY);
PatBlt(hdc, x1, y2, x2 - x1, 1, PATCOPY);
PatBlt(hdc, x2, y1, 1, y2 - y1 + 1, PATCOPY);
::SelectObject(hdc, hOldBrush);
}
示例10: Win32TransferBufferToWindows
/**
* Transfer our buffer into windows via StretchDIBits syscall.
* @param *buffer A pointer to the buffer info struct. We use a pointer because
* it is a fairly big struct so that if the compiler doesn't inline
* the code, it would require a 'big' memory copy in the stack. So
* we send the pointer even though we do not modify the origin struct.
*/
internal void
Win32TransferBufferToWindows(HDC deviceContext,
win32_offscreen_buffer *buffer,
int windowWidth, int windowHeight)
{
if((windowWidth >= 2 * buffer->width) &&
(windowHeight >= 2 * buffer->height))
{
// If we can double stretch the buffer, we do it, because double-sampling
// will not produce artifacts with StretchDIBits
StretchDIBits(deviceContext,
/*
x, y, destWidth, destHeight,
x, y, originWidth, originHeight,
*/
0, 0, 2 * buffer->width, 2 * buffer->height,
0, 0, buffer->width, buffer->height,
buffer->memory,
&buffer->info,
DIB_RGB_COLORS,
SRCCOPY);
}
else
{
int offsetX = 10;
int offsetY = 10;
// We have to clean the rectangles outside of our render target rectangle
PatBlt(deviceContext, 0, 0, windowWidth, offsetY, BLACKNESS);
PatBlt(deviceContext, 0, 0, offsetX, windowHeight, BLACKNESS);
PatBlt(deviceContext, offsetX, offsetY + buffer->height,
windowWidth - offsetX, windowHeight - (offsetY + buffer->height),
BLACKNESS);
PatBlt(deviceContext, offsetX + buffer->width, offsetY,
windowWidth - (offsetX + buffer->width), windowHeight - offsetY,
BLACKNESS);
// NOTE(Cristián): For prototyping, we're are always going to blit 1-1 pixels
// to make sure we don't introduce artifacts. This will change when the renderer
// code is done.
StretchDIBits(deviceContext,
/*
x, y, destWidth, destHeight,
x, y, originWidth, originHeight,
*/
offsetX, offsetY, buffer->width, buffer->height,
0, 0, buffer->width, buffer->height,
buffer->memory,
&buffer->info,
DIB_RGB_COLORS,
SRCCOPY);
}
}
示例11: TWnd_OnPaint
/*****************************************************************************
*
* TWnd_OnPaint
*
* Handle WM_PAINT message to time window.
*
* HWND hWnd - Window handle
*
* Repaint the 3D inset borders around the edge of the client area.
* Repaint the time.
*
*****************************************************************************/
VOID NEAR PASCAL TWnd_OnPaint( HWND hWnd) { PAINTSTRUCT ps; HDC hDC;
HBRUSH hBrOld; int nWidth; int nHeight;
RECT rc;
GetClientRect(hWnd, &rc);
nWidth = rc.right;
nHeight = rc.bottom;
hDC = BeginPaint(hWnd, &ps);
hBrOld = (HBRUSH)SelectObject(hDC, GetStockObject(GRAY_BRUSH));
PatBlt(hDC, 0, 0, 1, nHeight-1, PATCOPY);
PatBlt(hDC, 1, 0, nWidth-2, 1, PATCOPY);
SelectObject(hDC, GetStockObject(BLACK_BRUSH));
PatBlt(hDC, 1, 1, 1, nHeight-3, PATCOPY);
PatBlt(hDC, 2, 1, nWidth-4, 1, PATCOPY);
SelectObject(hDC, GetStockObject(WHITE_BRUSH));
PatBlt(hDC, rc.right-1, 0, 1, nHeight-1, PATCOPY);
PatBlt(hDC, 0, rc.bottom-1, nWidth, 1, PATCOPY);
SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
PatBlt(hDC, rc.right-2, 1, 1, nHeight-2, PATCOPY);
PatBlt(hDC, 1, rc.bottom-2, nWidth-2, 1, PATCOPY);
SelectObject(hDC, hBrOld);
gbRepaint = TRUE;
PaintTime(hDC);
EndPaint(hWnd, &ps);
}
示例12: DrawBox
/******************************************************************************
* DrawBox(hDC, xChar, yChar, wChar, kChar, scale, htSep)
*
* purpose: draws the edit box for the character being edited and colors the
* grid squares according to the pixels set for the character.
*
* params: HDC hDC : handle to display context
* DWORD xChar : x-location of char box.
* DWORD yChar : y-location of char box
* DWORD wChar : width of char box
* DWORD kChar : height of char
* INT wScale : Scale of the squares.
* DWORD htSep : height of square separators
*
* returns: none
*
* side effects: alters matBox (global 2-d array with ready pixel info. on
* currently displayed box)
*****************************************************************************/
VOID
DrawBox(
HDC hDC,
DWORD xChar, /* x-location of char. */
DWORD yChar, /* y-location of char. */
DWORD wChar, /* width of char. */
DWORD kChar, /* height of char */
INT wScale, /* scale of the squares. */
DWORD htSep /* hgt of square separators */
)
/* draw a character of separate squares of height 'scale' with sep. 'htSep' */
{
DWORD i, j, sep;
if (fAll) { /* redraw them all */
for (j = 0; j < kChar; j++) {
sep = (j >= font.Ascent) ? htSep : 0;
for (i = 0; i < wChar; i++) {
if (wScale == 1)
SetPixel(hDC, xChar + i, yChar + j,
matBox[i][j] == TRUE ? BLACK : WHITE);
else
PatBlt(hDC,
xChar + wScale * i,
yChar + wScale * j + sep,
wScale - htSep,
wScale - htSep,
colors[matBox[i][j] == TRUE ? 1 : 0]);
}
}
}
else { /* redraw one just flipped */
if (wScale == 1)
SetPixel(hDC,
xChar + ptC.x,
yChar + ptC.y,
matBox[ptC.x][ptC.y] == TRUE ? BLACK : WHITE);
else {
sep = (((DWORD) ptC.y >= font.Ascent) ? htSep : 0L);
SelectObject(hDC, hbrGray);
PatBlt(hDC,
xChar + wScale * ptC.x,
yChar + wScale * ptC.y + sep,
wScale - htSep,
wScale - htSep,
colors[matBox[ptC.x][ptC.y]]);
}
}
}
示例13: TreeListDrawSplitBar
VOID
TreeListDrawSplitBar(
__in PTREELIST_OBJECT Object,
__in LONG x,
__in LONG y,
__in BOOLEAN EndTrack
)
{
HDC hdc;
RECT Rect;
HBRUSH hBrushOld;
hdc = GetDC(Object->hWnd);
if (!hdc) {
return;
}
GetClientRect(Object->hWnd, &Rect);
hBrushOld = SelectObject(hdc, Object->hBrushBar);
//
// Clean the splibar we drew last time
//
if (Object->SplitbarLeft > 0) {
PatBlt(hdc, Object->SplitbarLeft, y,
Object->SplitbarBorder,
Rect.bottom - Rect.top - y,
PATINVERT );
}
if (!EndTrack) {
Rect.left += x;
PatBlt(hdc, Rect.left, y, Object->SplitbarBorder,
Rect.bottom - Rect.top - y, PATINVERT);
Object->SplitbarLeft = Rect.left;
}
else {
Object->SplitbarLeft = 0xffff8001;
}
SelectObject(hdc, hBrushOld);
ReleaseDC(Object->hWnd, hdc);
}
示例14: Shutdown
void Vid::SetMode( int ModeValue ) {
if ( BackBuffer ) {
Shutdown();
}
WindowWidth = ModeList[ModeValue].Width;
WindowHeight = ModeList[ModeValue].Height;
BufferHeight = WindowHeight;
BufferWidth = WindowWidth;
if ( ModeList[ModeValue].Type == ModeState::WINDOWED ) {
SetWindowedMode( ModeValue );
} else {
SetFullscrenMode( ModeValue );
}
ShowWindow( MainWindow, SW_SHOWDEFAULT );
HDC DeviceContext = GetDC( MainWindow );
PatBlt( DeviceContext, 0, 0, BufferWidth, BufferHeight, BLACKNESS );
ReleaseDC( MainWindow, DeviceContext );
// define our bitmap info
BitMapInfo.bmiHeader.biSize = sizeof( BitMapInfo.bmiHeader );
BitMapInfo.bmiHeader.biWidth = BufferWidth;
BitMapInfo.bmiHeader.biHeight = -BufferHeight;
BitMapInfo.bmiHeader.biPlanes = 1;
BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel;
BitMapInfo.bmiHeader.biCompression = BI_RGB;
BackBuffer = FrameBuffer( BufferWidth, BufferHeight, BytesPerPixel );
}
示例15: MainWindowCallback
LRESULT CALLBACK MainWindowCallback( HWND Window,
UINT Message,
WPARAM WParam,
LPARAM LParam)
{
LRESULT Result = 0;
switch(Message){
case WM_SIZE:
{
OutputDebugStringA("WN_SIZE \n" );
}break;
case WM_DESTROY:
{
OutputDebugStringA("WN_DESTROY \n" );
}break;
case WM_CLOSE:
{
OutputDebugStringA("WN_CLOSE \n" );
}break;
case WM_ACTIVATEAPP:
{
OutputDebugStringA("WM_ACTIVATEAPP \n" );
}break;
case WM_PAINT:
{
PAINTSTRUCT Paint;
HDC DeviceContext = BeginPaint(Window,&Paint );
int X = Paint.rcPaint.left;
int Y = Paint.rcPaint.top;
int Height = Paint.rcPaint.bottom - Paint.rcPaint.top;
int Width = Paint.rcPaint.right - Paint.rcPaint.left;
static DWORD operation = WHITENESS;
PatBlt(DeviceContext,X, Y, Width,Height, operation);
if(operation == WHITENESS){
operation = BLACKNESS;
}
else{
operation = WHITENESS;
}
EndPaint(Window, &Paint);
}
default:
{
//OutputDebugStringA("Default \n" );
Result = DefWindowProc(Window,Message,WParam,LParam);
}break;
}
return Result;
}