您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CreateCompatibleDC函数代码示例

51自学网 2021-06-01 20:14:10
  C++
这篇教程C++ CreateCompatibleDC函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CreateCompatibleDC函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateCompatibleDC函数的具体用法?C++ CreateCompatibleDC怎么用?C++ CreateCompatibleDC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CreateCompatibleDC函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_palette_brush

static void test_palette_brush(void){    char buffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) + 16 * 16];    BITMAPINFO *info = (BITMAPINFO *)buffer;    WORD *indices = (WORD *)info->bmiColors;    char pal_buffer[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];    LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;    HDC hdc = CreateCompatibleDC( 0 );    DWORD *dib_bits;    HBITMAP dib;    HBRUSH brush;    int i;    HPALETTE palette, palette2;    memset( info, 0, sizeof(*info) );    info->bmiHeader.biSize        = sizeof(info->bmiHeader);    info->bmiHeader.biWidth       = 16;    info->bmiHeader.biHeight      = 16;    info->bmiHeader.biPlanes      = 1;    info->bmiHeader.biBitCount    = 32;    info->bmiHeader.biCompression = BI_RGB;    dib = CreateDIBSection( NULL, info, DIB_RGB_COLORS, (void**)&dib_bits, NULL, 0 );    ok( dib != NULL, "CreateDIBSection failed/n" );    info->bmiHeader.biBitCount = 8;    for (i = 0; i < 256; i++) indices[i] = 255 - i;    for (i = 0; i < 256; i++) ((BYTE *)(indices + 256))[i] = i;    brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS );    ok( brush != NULL, "CreateDIBPatternBrushPt failed/n" );    pal->palVersion = 0x300;    pal->palNumEntries = 256;    for (i = 0; i < 256; i++)    {        pal->palPalEntry[i].peRed = i * 2;        pal->palPalEntry[i].peGreen = i * 2;        pal->palPalEntry[i].peBlue = i * 2;        pal->palPalEntry[i].peFlags = 0;    }    palette = CreatePalette( pal );    ok( SelectObject( hdc, dib ) != NULL, "SelectObject failed/n" );    ok( SelectPalette( hdc, palette, 0 ) != NULL, "SelectPalette failed/n" );    ok( SelectObject( hdc, brush ) != NULL, "SelectObject failed/n" );    memset( dib_bits, 0xaa, 16 * 16 * 4 );    PatBlt( hdc, 0, 0, 16, 16, PATCOPY );    for (i = 0; i < 256; i++)    {        DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |                        pal->palPalEntry[255 - i].peGreen << 8 |                        pal->palPalEntry[255 - i].peBlue);        ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u/n", dib_bits[i], expect, i % 16, i / 16 );    }    for (i = 0; i < 256; i++) pal->palPalEntry[i].peRed = i * 3;    palette2 = CreatePalette( pal );    ok( SelectPalette( hdc, palette2, 0 ) != NULL, "SelectPalette failed/n" );    memset( dib_bits, 0xaa, 16 * 16 * 4 );    PatBlt( hdc, 0, 0, 16, 16, PATCOPY );    for (i = 0; i < 256; i++)    {        DWORD expect = (pal->palPalEntry[255 - i].peRed << 16 |                        pal->palPalEntry[255 - i].peGreen << 8 |                        pal->palPalEntry[255 - i].peBlue);        ok( dib_bits[i] == expect, "wrong bits %x/%x at %u,%u/n", dib_bits[i], expect, i % 16, i / 16 );    }    DeleteDC( hdc );    DeleteObject( dib );    DeleteObject( brush );    DeleteObject( palette );    DeleteObject( palette2 );}
开发者ID:iXit,项目名称:wine,代码行数:72,


示例2: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam){    HDC hDC;    PAINTSTRUCT lpPaint;    switch(iMessage)    {    case WM_CLOSE:    case WM_DESTROY:        exit(0);        if(MessageBox(hWnd, "Do you really want to quit?", "Message", MB_YESNO) == IDYES)            PostQuitMessage(0);        break;    case WM_ERASEBKGND:        return 1; // Done    case WM_PAINT:        GdiFlush();        hDC = BeginPaint( hWnd, &lpPaint);        // Assume hPaintDC is a variable of type HDC, and the dc we're rendering to        HDC hBitmapDC = CreateCompatibleDC(hDC);        HBITMAP hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, screenBitmap);        //HPALETTE hOldPalette = SelectPalette(hPaintDC, hPalette, FALSE);        GdiFlush();        if( !BitBlt(hDC, 0, 0, VSCREEN_WIDTH, VSCREEN_HEIGHT, hBitmapDC, 0, 0, SRCCOPY) )        {            DWORD err = GetLastError();            //FormatMessage();            printf("Win error %d", (int)err);            LPVOID lpMsgBuf;            FormatMessage(                          FORMAT_MESSAGE_ALLOCATE_BUFFER |                          FORMAT_MESSAGE_FROM_SYSTEM |                          FORMAT_MESSAGE_IGNORE_INSERTS,                          NULL,                          err,                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language                          (LPTSTR) &lpMsgBuf,                          0, NULL );            printf("WinErr: %s/n", (const char *)lpMsgBuf );        }        GdiFlush();        //SelectPalette(hPaintDC, hOldPalette, TRUE);        SelectObject(hBitmapDC, hOldBitmap);        DeleteDC(hBitmapDC);        /*if(eline)         {         MoveToEx(hDC, 60, 20, NULL);         LineTo(hDC, 264, 122);         }*/        // TODO: paint OS mouse cursor        EndPaint( hWnd, &lpPaint);        break;#if HOVER    case WM_MOUSEHOVER:        {            int xPos = (short)(0x0FFFF & lParam);//GET_X_LPARAM(lParam);            int yPos = VSCREEN_HEIGHT - (short)(0x0FFFF & (lParam>>16));//GET_Y_LPARAM(lParam);            printf("%d,%d/n", xPos, yPos );            TrackMouseEvent(&eventTrack);        }        break;#endif    //case WM_KEYDOWN:    //case WM_KEYUP:        TranslateMessage(  __in  const MSG *lpMsg );    case WM_CHAR:        {            printf("-%x-", (int)lParam );        }        break;    case WM_MOUSEMOVE:        {            int xPos = (short)(0x0FFFF & lParam);//GET_X_LPARAM(lParam);            int yPos = VSCREEN_HEIGHT - (short)(0x0FFFF & (lParam>>16));//GET_Y_LPARAM(lParam);            //	printf("%d,%d/n", xPos, yPos );            drv_video_win32.mouse_x = xPos;            drv_video_win32.mouse_y = yPos;            drv_video_win32.mouse_flags = wParam;            drv_video_win32.mouse();#if 1//.........这里部分代码省略.........
开发者ID:animotron,项目名称:animos,代码行数:101,


示例3: CreateDC

void CDlgScraperOutput::DoBitblt(HBITMAP bitmap, RMapCI r_iter){	CDC			*pDC = m_ScraperBitmap.GetDC();	HDC			hdcControl = *pDC;	HDC			hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);	HDC			hdcCompat1 = CreateCompatibleDC(hdcScreen);	HDC			hdcCompat2 = CreateCompatibleDC(hdcScreen);	HBITMAP		hbm2 = NULL, old_bitmap1 = NULL, old_bitmap2 = NULL;	int			w = 0, h = 0, zoom = 0;	RECT		rect = {0};	CBrush		gray_brush, *pTempBrush = NULL, oldbrush;	CPen		null_pen, *pTempPen = NULL, oldpen;	CString		res = "";	CTransform	trans;	if (in_startup) 		{		DeleteDC(hdcCompat1);		DeleteDC(hdcCompat2);		DeleteDC(hdcScreen);		ReleaseDC(pDC);		return;	}	m_ScraperBitmap.GetWindowRect(&rect);	// Erase control area	gray_brush.CreateSolidBrush(COLOR_GRAY);	pTempBrush = (CBrush*)pDC->SelectObject(&gray_brush);	oldbrush.FromHandle((HBRUSH)pTempBrush);			// Save old brush	null_pen.CreatePen(PS_NULL, 0, COLOR_BLACK);	pTempPen = (CPen*)pDC->SelectObject(&null_pen);	oldpen.FromHandle((HPEN)pTempPen);					// Save old pen	pDC->Rectangle(1, 1, rect.right-rect.left, rect.bottom-rect.top);	pDC->SelectObject(oldbrush);	pDC->SelectObject(oldpen);	// return if all we needed to do was erase display	if (bitmap == NULL)	{		DeleteDC(hdcCompat1);		DeleteDC(hdcCompat2);		DeleteDC(hdcScreen);		ReleaseDC(pDC);		return;	}	// load bitmap into 1st DC and stretchblt to 2nd DC	old_bitmap1 = (HBITMAP) SelectObject(hdcCompat1, bitmap);	zoom = m_Zoom.GetCurSel()==0 ? 1 :		   m_Zoom.GetCurSel()==1 ? 2 :		   m_Zoom.GetCurSel()==2 ? 4 :		   m_Zoom.GetCurSel()==3 ? 8 :		   m_Zoom.GetCurSel()==4 ? 16 : 1;	w = (r_iter->second.right - r_iter->second.left) * zoom;	h = (r_iter->second.bottom - r_iter->second.top) * zoom;	hbm2 = CreateCompatibleBitmap(hdcScreen, w, h);	old_bitmap2 = (HBITMAP) SelectObject(hdcCompat2, hbm2);	StretchBlt(	hdcCompat2, 0, 0, w, h,				hdcCompat1, 0, 0,				r_iter->second.right - r_iter->second.left,				r_iter->second.bottom - r_iter->second.top,				SRCCOPY );	// Copy 2nd DC to control	BitBlt( hdcControl, 1, 1, rect.right-rect.left-2, rect.bottom-rect.top-2,			hdcCompat2, 0, 0, SRCCOPY );	// Output result	trans.DoTransform(r_iter, hdcCompat1, &res);	m_ScraperResult.SetWindowText(res);	// Clean up	SelectObject(hdcCompat1, old_bitmap1);	SelectObject(hdcCompat2, old_bitmap2);	DeleteObject(hbm2);	DeleteDC(hdcCompat1);	DeleteDC(hdcCompat2);	DeleteDC(hdcScreen);	ReleaseDC(pDC);}
开发者ID:buranela,项目名称:OpenHoldemV12,代码行数:83,


示例4: _DrawTransparentBitmap

void _DrawTransparentBitmap(HDC hdc, HBITMAP hBitmap, short xStart, short yStart, COLORREF cTransparentColor){	BITMAP     bm;	COLORREF   cColor;	HBITMAP    bmAndBack, bmAndObject, bmAndMem, bmSave;	HBITMAP    bmBackOld, bmObjectOld, bmMemOld, bmSaveOld;	HDC        hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave;	POINT      ptSize;	hdcTemp = CreateCompatibleDC(hdc);	SelectObject(hdcTemp, hBitmap);   // Select the bitmap	GetObject(hBitmap, sizeof(BITMAP), &bm);	ptSize.x = bm.bmWidth;            // Get width of bitmap	ptSize.y = bm.bmHeight;           // Get height of bitmap	DPtoLP(hdcTemp, &ptSize, 1);      // Convert from device	// to logical points	// Create some DCs to hold temporary data.	hdcBack   = CreateCompatibleDC(hdc);	hdcObject = CreateCompatibleDC(hdc);	hdcMem    = CreateCompatibleDC(hdc);	hdcSave   = CreateCompatibleDC(hdc);	// Create a bitmap for each DC. DCs are required for a number of	// GDI functions.	// Monochrome DC	bmAndBack   = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);	// Monochrome DC	bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);	bmAndMem    = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);	bmSave      = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);	// Each DC must select a bitmap object to store pixel data.	bmBackOld   = (HBITMAP)SelectObject(hdcBack, bmAndBack);	bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject);	bmMemOld    = (HBITMAP)SelectObject(hdcMem, bmAndMem);	bmSaveOld   = (HBITMAP)SelectObject(hdcSave, bmSave);	// Set proper mapping mode.	SetMapMode(hdcTemp, GetMapMode(hdc));	// Save the bitmap sent here, because it will be overwritten.	BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);	// Set the background color of the source DC to the color.	// contained in the parts of the bitmap that should be transparent	cColor = SetBkColor(hdcTemp, cTransparentColor);	// Create the object mask for the bitmap by performing a BitBlt	// from the source bitmap to a monochrome bitmap.	BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,		SRCCOPY);	// Set the background color of the source DC back to the original	// color.	SetBkColor(hdcTemp, cColor);	// Create the inverse of the object mask.	BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0,		NOTSRCCOPY);	// Copy the background of the main DC to the destination.	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart,		SRCCOPY);	// Mask out the places where the bitmap will be placed.	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);	// Mask out the transparent colored pixels on the bitmap.	BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);	// XOR the bitmap with the background on the destination DC.	BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);	// Copy the destination to the screen.	BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0,		SRCCOPY);	// Place the original bitmap back into the bitmap sent here.	BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY);	// Delete the memory bitmaps.	DeleteObject(SelectObject(hdcBack, bmBackOld));	DeleteObject(SelectObject(hdcObject, bmObjectOld));	DeleteObject(SelectObject(hdcMem, bmMemOld));	DeleteObject(SelectObject(hdcSave, bmSaveOld));	// Delete the memory DCs.	DeleteDC(hdcMem);	DeleteDC(hdcBack);	DeleteDC(hdcObject);	DeleteDC(hdcSave);	DeleteDC(hdcTemp);}
开发者ID:killbug2004,项目名称:WSProf,代码行数:99,


示例5: drawsplash

void drawsplash(HWND hDlg, char* str){	m_Blend.BlendOp = AC_SRC_OVER; //theonlyBlendOpdefinedinWindows2000	m_Blend.BlendFlags = 0; //nothingelseisspecial...	m_Blend.AlphaFormat = AC_SRC_ALPHA; //...	m_Blend.SourceConstantAlpha = 255;//AC_SRC_ALPHA 	static Image *m_pImageBack;	if(!m_pImageBack) ImageFromIDResource(IDB_PNG1, L"PNG", m_pImageBack);	//----绘制	PAINTSTRUCT ps;	HDC hdcTemp = BeginPaint(hDlg, &ps);	HDC hMemDC = CreateCompatibleDC(hdcTemp);	RECT rct;	GetWindowRect(hDlg, &rct);	HBITMAP hBitMap = CreateCompatibleBitmap(hdcTemp, rct.right - rct.left, rct.bottom - rct.top);	HBITMAP hBmpOld = (HBITMAP)SelectObject(hMemDC, hBitMap);	HDC hdcScreen = GetDC(hDlg);	POINT ptWinPos = { rct.left, rct.top };	Graphics imageGraphics(hMemDC);	Point points[] = { Point(0, 0),		Point(400, 0),		Point(0, 255) };	Point points2[] = { Point(50, 50),		Point(450, 50),		Point(50, 305) };	// 设置层次窗口	DWORD dwExStyle = GetWindowLong(hDlg, GWL_EXSTYLE);	if ((dwExStyle & 0x80000) != 0x80000){		SetWindowLong(hDlg, GWL_EXSTYLE, dwExStyle ^ 0x80000);	}	POINT    ptSrc = { 0, 0 };	SIZE    sizeWindow = { rct.right - rct.left, rct.bottom - rct.top };	// 完成透明不规则窗口的绘制	imageGraphics.DrawImage(m_pImageBack, points, 3);	WCHAR* drawString = (WCHAR*)calloc(256, sizeof(WCHAR));	MultiByteToWideChar(CP_ACP, 0, str, (int)strlen(str), drawString, 255);	// Create font and brush.	Font* drawFont = new Font(L"Tahoma", 8);	SolidBrush* drawBrush = new SolidBrush(Color::White);	// Create point for upper-left corner of drawing.	PointF drawPoint = PointF(210.0F, 240.0F);	// Draw string to screen.	imageGraphics.DrawString(drawString, -1, drawFont, drawPoint, drawBrush);	delete drawFont;	delete drawBrush;	UpdateLayeredWindow(hDlg, hdcScreen, &ptWinPos, &sizeWindow, hMemDC, &ptSrc, 255, &m_Blend, ULW_ALPHA);	// 释放空间	EndPaint(hDlg, &ps);}
开发者ID:AeanSR,项目名称:kalscope,代码行数:61,


示例6: CSize

DWORD CmdDrawZoom::CmdDrawAjustZooming::SetPoint(DWORD MouseAction, CPoint pt){   CmdDrawZoom *p = dynamic_cast<CmdDrawZoom*>(m_pOwner);   if (enCmdMouseNone == MouseAction)   {      LP_MATERIALINFO pTempInfo = p->m_pReceiver->getComicStripData()->getSelectedInfo();      if (NULL == pTempInfo)      {         return FALSE;      }      CSize size = CSize(pt.x - pTempInfo->GetLTPoint().x, pt.y - pTempInfo->GetLTPoint().y);      size.cx = max(size.cx, 24);      size.cy = max(size.cy, 24);      pTempInfo->SetFinalSize(size);      if (pTempInfo->isPenDraw) {         int width = pTempInfo->m_image.GetWidth();         int height = pTempInfo->m_image.GetHeight();         if (width<size.cx || height<size.cy)         {            int newWidth = max(width, size.cx);            int newHeight = max(height, size.cy);            CxImage tempImage = pTempInfo->m_image;            pTempInfo->m_image.Create(newWidth, newHeight, 24, CXIMAGE_FORMAT_PNG);            RGBQUAD rgb = pTempInfo->m_image.GetPixelColor(1,1);            pTempInfo->m_image.SetTransIndex(0);            pTempInfo->m_image.SetTransColor(rgb);            HDC     memdcOrg   = CreateCompatibleDC(NULL);            HBITMAP hbitmapOrg = tempImage.MakeBitmap();            HGDIOBJ pOldGDIOBJOrg = SelectObject(memdcOrg, hbitmapOrg);            HDC     memdc   = CreateCompatibleDC(NULL);            HBITMAP hbitmap = pTempInfo->m_image.MakeBitmap();            HGDIOBJ pOldGDIOBJ = SelectObject(memdc, hbitmap);            BitBlt(memdc, 0, 0, width, height, memdcOrg, 0, 0, SRCCOPY);            pTempInfo->m_image.CreateFromHBITMAP(hbitmap);            SelectObject(memdc, pOldGDIOBJ);            DeleteObject(hbitmap);            DeleteDC(memdc);            SelectObject(memdcOrg, pOldGDIOBJOrg);            DeleteObject(hbitmapOrg);            DeleteDC(memdcOrg);         }      }      p->m_pReceiver->UpdateComicStrip(pTempInfo->nIDOwner);   }   else if (enCmdMouseLUp == MouseAction)   {      LP_MATERIALINFO pTempInfo = p->m_pReceiver->getComicStripData()->getSelectedInfo();      if (NULL == pTempInfo)      {         return FALSE;      }      CSize size = CSize(pt.x - pTempInfo->GetLTPoint().x, pt.y - pTempInfo->GetLTPoint().y);      size.cx = max(size.cx, 24);      size.cy = max(size.cy, 24);      pTempInfo->SetFinalSize(size);      if (pTempInfo->isPenDraw) {         int width = pTempInfo->m_image.GetWidth();         int height = pTempInfo->m_image.GetHeight();         if (width<size.cx || height<size.cy)         {            CxImage tempImage = pTempInfo->m_image;            pTempInfo->m_image.Create(size.cx, size.cy, 24, CXIMAGE_FORMAT_PNG);            RGBQUAD rgb = pTempInfo->m_image.GetPixelColor(1,1);            pTempInfo->m_image.SetTransIndex(0);            pTempInfo->m_image.SetTransColor(rgb);            HDC     memdcOrg   = CreateCompatibleDC(NULL);            HBITMAP hbitmapOrg = tempImage.MakeBitmap();            HGDIOBJ pOldGDIOBJOrg = SelectObject(memdcOrg, hbitmapOrg);            HDC     memdc   = CreateCompatibleDC(NULL);            HBITMAP hbitmap = pTempInfo->m_image.MakeBitmap();            HGDIOBJ pOldGDIOBJ = SelectObject(memdc, hbitmap);            BitBlt(memdc, 0, 0, width, height, memdcOrg, 0, 0, SRCCOPY);            pTempInfo->m_image.CreateFromHBITMAP(hbitmap);                        SelectObject(memdc, pOldGDIOBJ);            DeleteObject(hbitmap);            DeleteDC(memdc);            SelectObject(memdcOrg, pOldGDIOBJOrg);            DeleteObject(hbitmapOrg);            DeleteDC(memdcOrg);         }      }      p->m_pReceiver->SaveFile();      p->m_pReceiver->UpdateComicStrip(pTempInfo->nIDOwner);      p->m_pDsState = &p->m_dsZoomBgn;      p->m_pReceiver->SetCursor();      p->m_nDrawState = enDrawIdle;   }   return TRUE;}
开发者ID:njustccy,项目名称:NjustTool,代码行数:99,


示例7: GetDesktopWindow

JNIEXPORT jlong JNICALLJava_sun_font_FileFontStrike__1getGlyphImageFromWindows(JNIEnv *env, jobject unused, jstring fontFamily, jint style, jint size, jint glyphCode, jboolean fm) {    GLYPHMETRICS glyphMetrics;    LOGFONTW lf;    BITMAPINFO bmi;    TEXTMETRIC textMetric;    RECT rect;    int bytesWidth, dibBytesWidth, extra, imageSize, dibImageSize;    unsigned char* dibImage = NULL, *rowPtr, *pixelPtr, *dibPixPtr, *dibRowPtr;    unsigned char r,g,b;    unsigned char* igTable;    GlyphInfo* glyphInfo = NULL;    int nameLen;    LPWSTR name;    HFONT oldFont, hFont;    MAT2 mat2;    unsigned short width;    unsigned short height;    short advanceX;    short advanceY;    int topLeftX;    int topLeftY;    int err;    int bmWidth, bmHeight;    int x, y;    HBITMAP hBitmap = NULL, hOrigBM;    int gamma, orient;    HWND hWnd = NULL;    HDC hDesktopDC = NULL;    HDC hMemoryDC = NULL;    hWnd = GetDesktopWindow();    hDesktopDC = GetWindowDC(hWnd);    if (hDesktopDC == NULL) {        return (jlong)0;    }    if (GetDeviceCaps(hDesktopDC, BITSPIXEL) < 15) {        FREE_AND_RETURN;    }    hMemoryDC = CreateCompatibleDC(hDesktopDC);    if (hMemoryDC == NULL || fontFamily == NULL) {        FREE_AND_RETURN;    }    err = SetMapMode(hMemoryDC, MM_TEXT);    if (err == 0) {        FREE_AND_RETURN;    }    memset(&lf, 0, sizeof(LOGFONTW));    lf.lfHeight = -size;    lf.lfWeight = (style & 1) ? FW_BOLD : FW_NORMAL;    lf.lfItalic = (style & 2) ? 0xff : 0;    lf.lfCharSet = DEFAULT_CHARSET;    lf.lfQuality = CLEARTYPE_QUALITY;    lf.lfOutPrecision = OUT_TT_PRECIS;    lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;    lf.lfPitchAndFamily = DEFAULT_PITCH;    nameLen = (*env)->GetStringLength(env, fontFamily);    name = (LPWSTR)alloca((nameLen+1)*2);    if (name == NULL) {       FREE_AND_RETURN;    }    (*env)->GetStringRegion(env, fontFamily, 0, nameLen, name);    name[nameLen] = '/0';    if (nameLen < (sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]))) {        wcscpy(lf.lfFaceName, name);    } else {        FREE_AND_RETURN;    }    hFont = CreateFontIndirectW(&lf);    if (hFont == NULL) {        FREE_AND_RETURN;    }    oldFont = SelectObject(hMemoryDC, hFont);    memset(&textMetric, 0, sizeof(TEXTMETRIC));    err = GetTextMetrics(hMemoryDC, &textMetric);    if (err == 0) {        FREE_AND_RETURN;    }    memset(&glyphMetrics, 0, sizeof(GLYPHMETRICS));    memset(&mat2, 0, sizeof(MAT2));    mat2.eM11.value = 1; mat2.eM22.value = 1;    err = GetGlyphOutline(hMemoryDC, glyphCode,                          GGO_METRICS|GGO_GLYPH_INDEX,                          &glyphMetrics,                          0, NULL, &mat2);    if (err == GDI_ERROR) {        /* Probably no such glyph - ie the font wasn't the one we expected. */        FREE_AND_RETURN;    }//.........这里部分代码省略.........
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:101,


示例8: GetDC

int CWinApp::CaptureAnImage(HWND hWnd){	HDC hdcScreen;	HDC hdcWindow;	HDC hdcMemDC = NULL;	HBITMAP hbmScreen = NULL;	BITMAP bmpScreen;	// Retrieve the handle to a display device context for the client 	// area of the window. 	hdcScreen = GetDC(NULL);	hdcWindow = GetDC(hWnd);		// Create a compatible DC which is used in a BitBlt from the window DC	hdcMemDC = CreateCompatibleDC(hdcWindow); 	if(!hdcMemDC)	{		MessageBox(hWnd, L"StretchBlt has failed",L"Failed", MB_OK);		goto done;	}		// Get the client area for size calculation	RECT rcClient;	GetClientRect(hWnd, &rcClient);	DrawText(hdcWindow,L"客户区字画",_countof(L"客户区字画"),&rcClient,DT_LEFT);	//This is the best stretch mode	SetStretchBltMode(hdcWindow,HALFTONE);	//The source DC is the entire screen and the destination DC is the current window (HWND)	if(!StretchBlt(hdcWindow, 		0,0, 		rcClient.right, rcClient.bottom, 		hdcScreen, 		0,0,		GetSystemMetrics (SM_CXSCREEN),		GetSystemMetrics (SM_CYSCREEN),		SRCCOPY))	{		MessageBox(hWnd, L"StretchBlt has failed",L"Failed", MB_OK);		goto done;	}		// Create a compatible bitmap from the Window DC	hbmScreen = CreateCompatibleBitmap(hdcWindow, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);	if(!hbmScreen)	{		MessageBox(hWnd, L"CreateCompatibleBitmap Failed",L"Failed", MB_OK);		goto done;	}		// Select the compatible bitmap into the compatible memory DC.	SelectObject(hdcMemDC,hbmScreen);	// Bit block transfer into our compatible memory DC.	if(!BitBlt(hdcMemDC,		0,0,		rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, 		hdcWindow, 		0,0,		SRCCOPY))	{		MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK);		goto done;	}		// Get the BITMAP from the HBITMAP	GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen);	BITMAPFILEHEADER   bmfHeader;    	BITMAPINFOHEADER   bi;	bi.biSize = sizeof(BITMAPINFOHEADER);    	bi.biWidth = bmpScreen.bmWidth;    	bi.biHeight = bmpScreen.bmHeight;  	bi.biPlanes = 1;    	bi.biBitCount = 32;    	bi.biCompression = BI_RGB;    	bi.biSizeImage = 0;  	bi.biXPelsPerMeter = 0;    	bi.biYPelsPerMeter = 0;    	bi.biClrUsed = 0;    	bi.biClrImportant = 0;	DWORD dwBmpSize = ((bmpScreen.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight;	// Starting with 32-bit Windows, GlobalAlloc and LocalAlloc are implemented as wrapper functions that 	// call HeapAlloc using a handle to the process's default heap. Therefore, GlobalAlloc and LocalAlloc 	// have greater overhead than HeapAlloc.	HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize); 	char *lpbitmap = (char *)GlobalLock(hDIB);    	// Gets the "bits" from the bitmap and copies them into a buffer 	// which is pointed to by lpbitmap.	GetDIBits(hdcWindow, hbmScreen, 0,		(UINT)bmpScreen.bmHeight,		lpbitmap,		(BITMAPINFO *)&bi, DIB_RGB_COLORS);//.........这里部分代码省略.........
开发者ID:lijiqi,项目名称:WinSln,代码行数:101,


示例9: OnPaint

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)	{		PAINTSTRUCT ps;		HDC hdc = BeginPaint( &ps );		HDC hdcMem, hdcBB;		HBITMAP hbmOld, hbmOldBB;		BLENDFUNCTION func = { AC_SRC_OVER, 0, 0, 0 };		ps.rcPaint.right -= ps.rcPaint.left;		ps.rcPaint.bottom -= ps.rcPaint.top;		if (frame < 400)		{			hdcMem = CreateCompatibleDC( hdc );			hbmOld = (HBITMAP) SelectObject( hdcMem, frames[0] );			BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcMem, hbmOld );			DeleteDC( hdcMem );		}		else if (frame < 500)		{			hdcBB = CreateCompatibleDC( hdc );			hbmOldBB = (HBITMAP) SelectObject( hdcBB, backbuffer );			hdcMem = CreateCompatibleDC( hdc );			hbmOld = (HBITMAP) SelectObject( hdcMem, frames[0] );			BitBlt( hdcBB, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcMem, frames[1] );			func.SourceConstantAlpha = (frame - 400) * 255 / 100;			AlphaBlend( hdcBB, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, func);			SelectObject( hdcMem, hbmOld );			DeleteDC( hdcMem );			BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcBB,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcBB, hbmOldBB );			DeleteDC( hdcBB );		}		else if (frame < 900)		{			hdcMem = CreateCompatibleDC( hdc );			hbmOld = (HBITMAP) SelectObject( hdcMem, frames[1] );			BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcMem, hbmOld );			DeleteDC( hdcMem );		}		else if (frame < 1000)		{			hdcBB = CreateCompatibleDC( hdc );			hbmOldBB = (HBITMAP) SelectObject( hdcBB, backbuffer );			hdcMem = CreateCompatibleDC( hdc );			hbmOld = (HBITMAP) SelectObject( hdcMem, frames[1] );			BitBlt( hdcBB, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcMem, frames[0] );			func.SourceConstantAlpha = (frame - 900) * 255 / 100;			AlphaBlend( hdcBB, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcMem,				ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, func);			SelectObject( hdcMem, hbmOld );			DeleteDC( hdcMem );			BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top,				ps.rcPaint.right, ps.rcPaint.bottom, hdcBB,				ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);			SelectObject( hdcBB, hbmOldBB );			DeleteDC( hdcBB );		}		EndPaint( &ps );//.........这里部分代码省略.........
开发者ID:rogerclark,项目名称:foo_gep,代码行数:101,


示例10: IcoSave

void IcoSave(const std::wstring &fileName, HICON hicon){	std::ofstream store(fileName.c_str(), std::ios_base::binary);	if (!store.is_open())		return;	ICONINFO	ii;	if (!GetIconInfo(hicon, &ii)) {		store.close();		return;	}	HBITMAP hbmMask = ii.hbmMask;	HBITMAP hbmColor = ii.hbmColor;	BITMAP  bmiMask;	BITMAP  bmiColor;	if (GetObject(hbmColor, sizeof(bmiColor), &bmiColor) &&		GetObject(hbmMask, sizeof(bmiMask), &bmiMask) &&		(bmiColor.bmWidth == bmiMask.bmWidth) &&		(bmiColor.bmHeight == bmiMask.bmHeight) &&		(bmiMask.bmHeight) > 0 &&		(bmiMask.bmWidth) > 0) {		BITMAPINFOHEADER  icobmi = { 0 };		MYBITMAPINFO info1 = { 0 };		MYBITMAPINFO info2 = { 0 };		HDC hDC = CreateCompatibleDC(nullptr);		info1.bmiHeader.biSize = sizeof(info1.bmiHeader);		info1.bmiHeader.biWidth = bmiColor.bmWidth;		info1.bmiHeader.biHeight = bmiColor.bmHeight;		info1.bmiHeader.biPlanes = 1;		info1.bmiHeader.biBitCount = bmiColor.bmBitsPixel;		unsigned int size = GetDIBits(hDC, hbmColor, 0, info1.bmiHeader.biHeight, nullptr, (BITMAPINFO*)&info1, DIB_RGB_COLORS);		char* bits1 = new char[info1.bmiHeader.biSizeImage];		size = GetDIBits(hDC, hbmColor, 0, info1.bmiHeader.biHeight, bits1, (BITMAPINFO*)&info1, DIB_RGB_COLORS);		info2.bmiHeader.biSize = sizeof(info2.bmiHeader);		info2.bmiHeader.biWidth = bmiMask.bmWidth;		info2.bmiHeader.biHeight = bmiMask.bmHeight;		info2.bmiHeader.biPlanes = 1;		info2.bmiHeader.biBitCount = bmiMask.bmBitsPixel;		size = GetDIBits(hDC, hbmColor, 0, info1.bmiHeader.biHeight, nullptr, (BITMAPINFO*)&info2, DIB_RGB_COLORS);		char* bits2 = new char[info2.bmiHeader.biSizeImage];		size = GetDIBits(hDC, hbmMask, 0, info2.bmiHeader.biHeight, bits2, (BITMAPINFO*)&info2, DIB_RGB_COLORS);		ICONDIR            icodir;		ICONDIRENTRY      icoent;		icodir.idReserved = 0;		icodir.idType = 1;		icodir.idCount = 1;		icoent.bWidth = (unsigned char)bmiColor.bmWidth;		icoent.bHeight = (unsigned char)bmiColor.bmHeight;		icoent.bColorCount = 8 <= bmiColor.bmBitsPixel ? 0 : 1 << bmiColor.bmBitsPixel;		icoent.bReserved = 0;		icoent.wPlanes = bmiColor.bmPlanes;		icoent.wBitCount = bmiColor.bmBitsPixel;		icoent.dwBytesInRes = sizeof(BITMAPINFOHEADER) + info1.bmiHeader.biSizeImage + info2.bmiHeader.biSizeImage;		icoent.dwImageOffset = sizeof(icodir) + sizeof(icoent);		store.write((char*)&icodir, sizeof(icodir));		store.write((char*)&icoent, sizeof(icoent));		icobmi.biSize = sizeof(icobmi);		icobmi.biWidth = bmiColor.bmWidth;		icobmi.biHeight = bmiColor.bmHeight + bmiMask.bmHeight;		icobmi.biPlanes = info1.bmiHeader.biPlanes;		icobmi.biBitCount = bmiColor.bmBitsPixel;		icobmi.biSizeImage = 0;		store.write((char*)&icobmi, sizeof(icobmi));		store.write(bits1, info1.bmiHeader.biSizeImage);		store.write(bits2, info2.bmiHeader.biSizeImage);		DeleteDC(hDC);		delete[] bits1;		delete[] bits2;	}	store.close();	if (ii.hbmColor) DeleteObject(ii.hbmColor);	if (ii.hbmMask) DeleteObject(ii.hbmMask);}
开发者ID:tweimer,项目名称:miranda-ng,代码行数:83,


示例11: DoAlphaBlend_internal

/*********************************************************************/*                                                                     **  BOOL DoAlphaBlend()                                                **                                                                     **  Purpose:                                                           **      Captures a copy of the source and destination areas and        **      alpha blends them into a memory surface that it displays       **      into the destination area.                                     *     *                                                                     **  Notes:                                                             **      Takes the same parameters as the AlphaBlend function except    **      that the last parameter is a source weighting value rather     **      than a BLENDFUNCTION structure.                                **                                                                     */*********************************************************************/BOOL DoAlphaBlend_internal(  HDC hdcDest,                 // Handle to destination DC.  int nXOriginDest,            // X-coord of upper-left corner.  int nYOriginDest,            // Y-coord of upper-left corner.  int nWidthDest,              // Destination width.  int nHeightDest,             // Destination height.  HDC hdcSrc,                  // Handle to source DC.  int nXOriginSrc,             // X-coord of upper-left corner.  int nYOriginSrc,             // Y-coord of upper-left corner.  int nWidthSrc,               // Source width.  int nHeightSrc,              // Source height.  DWORD dwSourceWeight)        // Source weighting (between 0 and 255).{    if(pfnSetStretchBltMode) {#ifdef PNA        pfnSetStretchBltMode = (pfnSetStretchBltMode_t) GetProcAddress(GetModuleHandle(TEXT("coredll.dll")), TEXT("SetStretchBltMode"));#else        pfnSetStretchBltMode = SetStretchBltMode;#endif    }    HDC      hdcSrc1 = NULL;    HDC      hdcSrc2 = NULL;    HDC      hdcDst  = NULL;    HBITMAP  hbmSrc1 = NULL;    HBITMAP  hbmSrc2 = NULL;    HBITMAP  hbmDst  = NULL;    BOOL     bReturn;    // Create surfaces for sources and destination images.    hbmSrc1 = Create24BPPDIBSection(hdcDest, nWidthDest,nHeightDest);    if (!hbmSrc1) goto HANDLEERROR;    hbmSrc2 = Create24BPPDIBSection(hdcDest, nWidthDest,nHeightDest);    if (!hbmSrc2) goto HANDLEERROR;    hbmDst  = Create24BPPDIBSection(hdcDest, nWidthDest,nHeightDest);    if (!hbmDst) goto HANDLEERROR;    // Create HDCs to hold our surfaces.    hdcSrc1 = CreateCompatibleDC(hdcDest);    if (!hdcSrc1) goto HANDLEERROR;    hdcSrc2 = CreateCompatibleDC(hdcDest);    if (!hdcSrc2) goto HANDLEERROR;    hdcDst  = CreateCompatibleDC(hdcDest);    if (!hdcDst) goto HANDLEERROR;    // Prepare the surfaces for drawing.    SelectObject(hdcSrc1, hbmSrc1);    SelectObject(hdcSrc2, hbmSrc2);    SelectObject(hdcDst,  hbmDst);    if(pfnSetStretchBltMode) {        pfnSetStretchBltMode(hdcSrc1, COLORONCOLOR);        pfnSetStretchBltMode(hdcSrc2, COLORONCOLOR);    }    // Capture a copy of the source area.    if (!StretchBlt(hdcSrc1, 0,0,nWidthDest,nHeightDest,                    hdcSrc,  nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,                    SRCCOPY))         goto HANDLEERROR;    // Capture a copy of the destination area.    if (!StretchBlt(hdcSrc2, 0,0,nWidthDest,nHeightDest,                    hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,                    SRCCOPY))         goto HANDLEERROR;    // Blend the two source areas to create the destination image.    bReturn = BlendImages(hbmSrc1, hbmSrc2, hbmDst, dwSourceWeight);    // Clean up objects you do not need any longer.    // You cannot delete an object that's selected into an    // HDC so delete the HDC first.    DeleteDC(hdcSrc1);    DeleteDC(hdcSrc2);    DeleteObject(hbmSrc1);//.........这里部分代码省略.........
开发者ID:SergioDaSilva82,项目名称:LK8000,代码行数:101,


示例12: BlendApplicationImage

HRESULT BlendApplicationImage(HWND hwndApp){    LONG cx, cy;    HRESULT hr;    // Read the default video size    hr = pWC->GetNativeVideoSize(&cx, &cy, NULL, NULL);    if (FAILED(hr))    {        Msg(TEXT("GetNativeVideoSize FAILED!  hr=0x%x/r/n"), hr);        return hr;    }    // Load the bitmap to alpha blend from the resource file    HBITMAP hbm = LoadBitmap(ghInst, MAKEINTRESOURCE(IDR_TICKER));    // Create a device context compatible with the current window    HDC hdc = GetDC(hwndApp);    HDC hdcBmp = CreateCompatibleDC(hdc);    ReleaseDC(hwndApp, hdc);    // Select our bitmap into the device context and save the old one    BITMAP bm;    HBITMAP hbmOld;    GetObject(hbm, sizeof(bm), &bm);    hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);    // Configure the VMR's bitmap structure    VMR9AlphaBitmap bmpInfo;    ZeroMemory(&bmpInfo, sizeof(bmpInfo) );    bmpInfo.dwFlags = VMRBITMAP_HDC;    bmpInfo.hdc = hdcBmp;    // Remember the width of this new bitmap    g_nImageWidth = bm.bmWidth;    // Save the ratio of the bitmap's width to the width of the video file.    // This value is used to reposition the bitmap in composition space.    g_fBitmapCompWidth = (float)g_nImageWidth / (float)cx;    // Display the bitmap in the bottom right corner.    // rSrc specifies the source rectangle in the GDI device context     // rDest specifies the destination rectangle in composition space (0.0f to 1.0f)    SetRect(&bmpInfo.rSrc, 0, 0, g_nImageWidth, bm.bmHeight);    bmpInfo.rDest.left   = 1.0f;    bmpInfo.rDest.right  = 1.0f + g_fBitmapCompWidth;    bmpInfo.rDest.top    = (float)(cy - bm.bmHeight) / (float)cy - EDGE_BUFFER;    bmpInfo.rDest.bottom = 1.0f - EDGE_BUFFER;    // Copy initial settings to global memory for later modification    g_rDest = bmpInfo.rDest;    // Transparency value 1.0 is opaque, 0.0 is transparent.    bmpInfo.fAlpha = TRANSPARENCY_VALUE;    // Set the COLORREF so that the bitmap outline will be transparent    SetColorRef(bmpInfo);    // Give the bitmap to the VMR for display    hr = pBMP->SetAlphaBitmap(&bmpInfo);    if (FAILED(hr))    {        Msg(TEXT("SetAlphaBitmap FAILED!  hr=0x%x/r/n/r/n%s/0"),            hr, STR_VMR_DISPLAY_WARNING);    }    // Select the initial object back into our device context    DeleteObject(SelectObject(hdcBmp, hbmOld));    // Clean up resources    DeleteObject(hbm);    DeleteDC(hdcBmp);    return hr;}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:75,


示例13: BlendApplicationText

HRESULT BlendApplicationText(HWND hwndApp, TCHAR *szNewText){    LONG cx, cy;    HRESULT hr;    // Read the default video size    hr = pWC->GetNativeVideoSize(&cx, &cy, NULL, NULL);    if (FAILED(hr))      return hr;    // Create a device context compatible with the current window    HDC hdc = GetDC(hwndApp);    HDC hdcBmp = CreateCompatibleDC(hdc);    // Write with a known font by selecting it into our HDC    HFONT hOldFont = (HFONT) SelectObject(hdcBmp, g_hFont);    // Determine the length of the string, then determine the    // dimensions (in pixels) of the character string using the    // currently selected font.  These dimensions are used to create    // a bitmap below.    int nLength, nTextBmpWidth, nTextBmpHeight;    SIZE sz={0};    nLength = (int) _tcslen(szNewText);    GetTextExtentPoint32(hdcBmp, szNewText, nLength, &sz);    nTextBmpHeight = sz.cy;    nTextBmpWidth  = sz.cx;    // Create a new bitmap that is compatible with the current window    HBITMAP hbm = CreateCompatibleBitmap(hdc, nTextBmpWidth, nTextBmpHeight);    ReleaseDC(hwndApp, hdc);    // Select our bitmap into the device context and save the old one    BITMAP bm;    HBITMAP hbmOld;    GetObject(hbm, sizeof(bm), &bm);    hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);    // Set initial bitmap settings    RECT rcText;    SetRect(&rcText, 0, 0, nTextBmpWidth, nTextBmpHeight);    SetBkColor(hdcBmp, RGB(255, 255, 255)); // Pure white background    SetTextColor(hdcBmp, g_rgbColors);      // Write text with requested color    // Draw the requested text string onto the bitmap    TextOut(hdcBmp, 0, 0, szNewText, nLength);    // Configure the VMR's bitmap structure    VMR9AlphaBitmap bmpInfo;    ZeroMemory(&bmpInfo, sizeof(bmpInfo) );    bmpInfo.dwFlags = VMRBITMAP_HDC;    bmpInfo.hdc = hdcBmp;  // DC which has selected our bitmap    // Remember the width of this new bitmap    g_nImageWidth = bm.bmWidth;    // Save the ratio of the bitmap's width to the width of the video file.    // This value is used to reposition the bitmap in composition space.    g_fBitmapCompWidth = (float)g_nImageWidth / (float)cx;    // Display the bitmap in the bottom right corner.    // rSrc specifies the source rectangle in the GDI device context     // rDest specifies the destination rectangle in composition space (0.0f to 1.0f)    bmpInfo.rDest.left  = 1.0f;    bmpInfo.rDest.right = 1.0f + g_fBitmapCompWidth;    bmpInfo.rDest.top = (float)(cy - bm.bmHeight) / (float)cy - EDGE_BUFFER;    bmpInfo.rDest.bottom = 1.0f - EDGE_BUFFER;    bmpInfo.rSrc = rcText;    // Copy initial settings to global memory for later modification    g_rDest = bmpInfo.rDest;    // Transparency value 1.0 is opaque, 0.0 is transparent.    bmpInfo.fAlpha = TRANSPARENCY_VALUE;    // Set the COLORREF so that the bitmap outline will be transparent    SetColorRef(bmpInfo);    // Give the bitmap to the VMR for display    hr = pBMP->SetAlphaBitmap(&bmpInfo);    if (FAILED(hr))        Msg(TEXT("SetAlphaBitmap FAILED!  hr=0x%x/r/n/r/n%s/0"), hr,            STR_VMR_DISPLAY_WARNING);    // Select the initial objects back into our device context    DeleteObject(SelectObject(hdcBmp, hbmOld));    SelectObject(hdc, hOldFont);    // Clean up resources    DeleteObject(hbm);    DeleteDC(hdcBmp);    return hr;}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:94,


示例14: switch

void *wxGetClipboardData(wxDataFormat dataFormat, long *len){    void *retval = NULL;    switch ( dataFormat )    {#ifndef __WXWINCE__        case wxDF_BITMAP:            {                BITMAP bm;                HBITMAP hBitmap = (HBITMAP) GetClipboardData(CF_BITMAP);                if (!hBitmap)                    break;                HDC hdcMem = CreateCompatibleDC((HDC) NULL);                HDC hdcSrc = CreateCompatibleDC((HDC) NULL);                HBITMAP old = (HBITMAP) ::SelectObject(hdcSrc, hBitmap);                GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);                HBITMAP hNewBitmap = CreateBitmapIndirect(&bm);                if (!hNewBitmap)                {                    SelectObject(hdcSrc, old);                    DeleteDC(hdcMem);                    DeleteDC(hdcSrc);                    break;                }                HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hNewBitmap);                BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight,                       hdcSrc, 0, 0, SRCCOPY);                // Select new bitmap out of memory DC                SelectObject(hdcMem, old1);                // Clean up                SelectObject(hdcSrc, old);                DeleteDC(hdcSrc);                DeleteDC(hdcMem);                // Create and return a new wxBitmap                wxBitmap *wxBM = new wxBitmap;                wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap);                wxBM->SetWidth(bm.bmWidth);                wxBM->SetHeight(bm.bmHeight);                wxBM->SetDepth(bm.bmPlanes);                retval = wxBM;                break;            }#endif        case wxDF_METAFILE:        case CF_SYLK:        case CF_DIF:        case CF_TIFF:        case CF_PALETTE:        case wxDF_DIB:            wxLogError(_("Unsupported clipboard format."));            return NULL;        case wxDF_OEMTEXT:            dataFormat = wxDF_TEXT;            // fall through        case wxDF_TEXT:            {                HANDLE hGlobalMemory = ::GetClipboardData(dataFormat);                if (!hGlobalMemory)                    break;                DWORD hsize = ::GlobalSize(hGlobalMemory);                if (len)                    *len = hsize;                char *s = new char[hsize];                if (!s)                    break;                LPSTR lpGlobalMemory = (LPSTR) GlobalLock(hGlobalMemory);                memcpy(s, lpGlobalMemory, hsize);                GlobalUnlock(hGlobalMemory);                retval = s;                break;            }        default:            {                HANDLE hGlobalMemory = ::GetClipboardData(dataFormat);                if ( !hGlobalMemory )                    break;                DWORD size = ::GlobalSize(hGlobalMemory);                if ( len )                    *len = size;                void *buf = malloc(size);//.........这里部分代码省略.........
开发者ID:madnessw,项目名称:thesnow,代码行数:101,


示例15: Test_Rectangle

void Test_Rectangle(void){    HDC hdc;    HBITMAP hBmp;    BOOL ret;    HBRUSH hBrush;    HPEN hPen;    COLORREF color;        hdc = CreateCompatibleDC(NULL);    ok(hdc != NULL, "Failed to create the DC!/n");    hBmp = CreateCompatibleBitmap(hdc, 4, 4);    ok(hBmp != NULL, "Failed to create the Bitmap!/n");    hBmp = SelectObject(hdc, hBmp);    ok(hBmp != NULL, "Failed to select the Bitmap!/n");        hBrush = CreateSolidBrush(RGB(0, 0, 0));    ok(hBrush != NULL, "Failed to create a solid brush!/n");    hBrush = SelectObject(hdc, hBrush);    ok(hBrush != NULL, "Failed to select the brush!/n");        /* Blank the bitmap */    ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);    ok(ret, "BitBlt failed to blank the bitmap!/n");        /* Try inverted rectangle coordinates */    ret = Rectangle(hdc, 0, 2, 2, 0);    ok(ret, "Rectangle failed!");    color = GetPixel(hdc, 0, 0);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 0, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 0);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 1, 1);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);    ok(ret, "BitBlt failed to blank the bitmap!/n");    /* Try well ordered rectangle coordinates */    ret = Rectangle(hdc, 0, 0, 2, 2);    ok(ret, "Rectangle failed!");    color = GetPixel(hdc, 0, 0);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 0, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 0);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 1, 1);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);        /* tests with NULL pen */    hPen = SelectObject(hdc, GetStockObject(NULL_PEN));        /* Blank the bitmap */    ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);    ok(ret, "BitBlt failed to blank the bitmap!/n");        ret = Rectangle(hdc, 0, 0, 3, 3);    ok(ret, "Rectangle failed!");    color = GetPixel(hdc, 0, 0);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 0, 2);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 0);    ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 1, 1);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);        SelectObject(hdc, hPen);        /* Same tests with GM_ADVANCED */    ok(SetGraphicsMode(hdc, GM_ADVANCED) == GM_COMPATIBLE, "Default mode for the DC is not GM_COMPATIBLE./n");        /* Blank the bitmap */    ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);    ok(ret, "BitBlt failed to blank the bitmap!/n");        /* Try inverted rectangle coordinates */    ret = Rectangle(hdc, 0, 2, 2, 0);    ok(ret, "Rectangle failed!");    color = GetPixel(hdc, 0, 0);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 2);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 0, 2);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 2, 0);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    color = GetPixel(hdc, 1, 1);    ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x/n", (UINT)color);    ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);    ok(ret, "BitBlt failed to blank the bitmap!/n");    //.........这里部分代码省略.........
开发者ID:GYGit,项目名称:reactos,代码行数:101,


示例16: D3DXCreateFontIndirectW

/*********************************************************************** *           D3DXCreateFontIndirectW    ([email
C++ CreateCompressedGuidString22函数代码示例
C++ CreateCompatibleBitmap函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。