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

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

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

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

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

示例1: main

int main(){// Create a normal DC and a memory DC for the entire screen. The// normal DC provides a "snapshot" of the screen contents. The// memory DC keeps a copy of this "snapshot" in the associated// bitmap.HDC hdcScreen, hdcCompatible;HBITMAP hbmScreen;SYSTEMTIME time;char* filename;char* filepath;char* regSubKeyBase = "Software//PJBSoftware//ScreenShooter";bool isRegVersion = false;filepath = (char*)malloc(100 * sizeof(char));if (!filepath) return 1;HKEY progKey;//Get the screenshot location from the registry, else stuff 'em in "My Documents"if (RegOpenKeyEx(HKEY_CURRENT_USER,regSubKeyBase,0,KEY_QUERY_VALUE,&progKey) == ERROR_SUCCESS){    DWORD buffsize = 100;    DWORD type;    if (RegQueryValueEx(progKey,"ScreenshotPath",NULL,&type,(LPBYTE)filepath,&buffsize) != ERROR_SUCCESS) return 1; }else{    char* username = (char*) malloc(25 * sizeof(char));    if (! username) return 1;    DWORD buffsize = 25;    BOOL st = GetUserName(username,&buffsize);    if (!st) return 1;    sprintf(filepath,"C://Documents and Settings//%s//My Documents",username);    free (username);}// Get the timeGetLocalTime((LPSYSTEMTIME)&time);hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);hdcCompatible = CreateCompatibleDC(hdcScreen);// Create a compatible bitmap for hdcScreen.hbmScreen = CreateCompatibleBitmap(hdcScreen,                     GetDeviceCaps(hdcScreen, HORZRES),                     GetDeviceCaps(hdcScreen, VERTRES));if (hbmScreen == 0)    printf("Could not create bitmap/n");// Select the bitmaps into the compatible DC.if (!SelectObject(hdcCompatible, hbmScreen))    printf("Could not select bitmap/n");         //Copy color data for the entire display into a         //bitmap that is selected into a compatible DC.        if (!BitBlt(hdcCompatible,               0,0,               GetDeviceCaps(hdcScreen, HORZRES), GetDeviceCaps(hdcScreen, VERTRES),               hdcScreen,               0,0,               SRCCOPY))         printf("Screen to Compat Blt Failed/n");    filename = (char*)malloc(150 * sizeof(char));    if (!filename) return 1;    sprintf(filename,"%s//screenshot-%04u-%02u-%02u-%02u%02u%02u.bmp",filepath,time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond);    free(filepath);    CreateBMPFile(filename,CreateBitmapInfoStruct(hbmScreen),hbmScreen,hdcCompatible);    free(filename); 	return 0;}
开发者ID:peejaybee,项目名称:ScreenShooter,代码行数:89,


示例2: readscreen

static void readscreen(void){#if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN)  HDC		hScrDC;		/* screen DC */  HDC		hMemDC;		/* memory DC */  HBITMAP	hBitmap;	/* handle for our bitmap */  HBITMAP	hOldBitmap;	/* handle for previous bitmap */  BITMAP	bm;		/* bitmap properties */  unsigned int	size;		/* size of bitmap */  char		*bmbits;	/* contents of bitmap */  int		w;		/* screen width */  int		h;		/* screen height */  int		y;		/* y-coordinate of screen lines to grab */  int		n = 16;		/* number of screen lines to grab at a time */  if (GetVersion() >= 0x80000000 || !OPENSSL_isservice())    return;  /* Create a screen DC and a memory DC compatible to screen DC */  hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);  hMemDC = CreateCompatibleDC(hScrDC);  /* Get screen resolution */  w = GetDeviceCaps(hScrDC, HORZRES);  h = GetDeviceCaps(hScrDC, VERTRES);  /* Create a bitmap compatible with the screen DC */  hBitmap = CreateCompatibleBitmap(hScrDC, w, n);  /* Select new bitmap into memory DC */  hOldBitmap = SelectObject(hMemDC, hBitmap);  /* Get bitmap properties */  GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);  size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;  bmbits = OPENSSL_malloc(size);  if (bmbits) {    /* Now go through the whole screen, repeatedly grabbing n lines */    for (y = 0; y < h-n; y += n)    	{	unsigned char md[MD_DIGEST_LENGTH];	/* Bitblt screen DC to memory DC */	BitBlt(hMemDC, 0, 0, w, n, hScrDC, 0, y, SRCCOPY);	/* Copy bitmap bits from memory DC to bmbits */	GetBitmapBits(hBitmap, size, bmbits);	/* Get the hash of the bitmap */	MD(bmbits,size,md);	/* Seed the random generator with the hash value */	RAND_add(md, MD_DIGEST_LENGTH, 0);	}    OPENSSL_free(bmbits);  }  /* Select old bitmap back into memory DC */  hBitmap = SelectObject(hMemDC, hOldBitmap);  /* Clean up */  DeleteObject(hBitmap);  DeleteDC(hMemDC);  DeleteDC(hScrDC);#endif /* !OPENSSL_SYS_WINCE */}
开发者ID:LucidOne,项目名称:Rovio,代码行数:68,


示例3: GetDC

//Loosely based on writeWindowText() @ 0x0041F2B0void Bitmap::blitKoreanChar(const char *ch, int &x, int &y, u8 fontSize, u8 color) {  static HFONT gulim_8pt = NULL, gulim_9pt = NULL, gulim_10pt = NULL, gulim_11pt = NULL;  static HDC bufferDc = NULL;  static HBITMAP bufferBmp = NULL; //Temporary bitmap to draw the character    //Load Korean fonts  if (!gulim_9pt) {    HDC screenDc = GetDC(NULL);    LOGFONT lFont = {};    strcpy(lFont.lfFaceName, "±
C++ CreateCompatibleDC函数代码示例
C++ CreateChildren函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。