gdi

SetBkMode(hdc, TRANSPARENT) doesn't work

泪湿孤枕 提交于 2020-01-15 11:51:36
问题 When I use SetBkMode(hdc, TRANSPARENT); in the code below, I got the following effect when I resize the main window (and hence when the child receives the WM_PAINT message): The problem is : When I resize the main window, The old area of "Find:" shoule be erased, I guess. But it just remains there. If I don't use SetBkMode(hdc, TRANSPARENT); , I don't have this problem. It looks like: , i.e it has white background. Furthermore, if I use SetBkMode(hdc, TRANSPARENT); , it looks like the same as

StretchDIBits failed, sometimes it draw nothing,

你。 提交于 2020-01-15 05:05:11
问题 I am using gdi c++, StretchDIBits function sometimes failed if I draw large Images such as 7000*5000. It draw nothing. GetLastError() says no enough system resource. Can anyone explain why StretchDIBits need resource even The DC is prepared successfully. 回答1: It may be that StretchDIBits expands the source image into a temporary bitmap of the same dimensions as the destination bitmap, and then copies the temporary into the destination as the final step. So even if you have enough memory to

VC GDI双缓冲机制绘图防屏幕闪烁实现步骤

≡放荡痞女 提交于 2020-01-15 00:01:17
在OnDraw(CDC* pDC) 中添加如下代码 CDC MemDC; //首先定义一个显示设备对象   CBitmap MemBitmap;//定义一个位图对象   //随后建立与屏幕显示兼容的内存显示设备   MemDC.CreateCompatibleDC(NULL);   //这时还不能绘图,因为没有地方画 ^_^   //下面建立一个与屏幕显示兼容的位图,至于位图的大小嘛,可以用窗口的大小,也可以自己定义(如:有滚动条时就要大于当前窗口的大小,在BitBlt时决定拷贝内存的哪部分到屏幕上)   MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);   //将位图选入到内存显示设备中   //只有选入了位图的内存显示设备才有地方绘图,画到指定的位图上   CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);   //先用背景色将位图清除干净,这里我用的是白色作为背景   //你也可以用自己应该用的颜色   MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(255,255,255));   //绘图   MemDC.MoveTo(……);   MemDC.LineTo(……);   //将内存中的图拷贝到屏幕上进行显示   pDC-

Thread type for background drawing to a bitmap in MFC

牧云@^-^@ 提交于 2020-01-14 13:38:07
问题 I have a MFC document/view C++ graphics application that does all its drawing to an off screen bitmap, and then copys that to the supplied CDC pointer in the OnDraw method. Over the last couple of days I've been looking to place the drawing component in a seperate worker thread, so it doesn't stall the GUI. I seem to get a fair number of MFC GDI related asserts firing when I do this, e,g, VERIFY(::MoveToEx(m_hAttribDC, x, y, &point) So a few questions; Are there any problems with using worker

c++ how to send Hbitmap over socket

a 夏天 提交于 2020-01-13 07:08:03
问题 My GetScreen function looks like: void GetScreen(int clientSocket, const char *filename) { HDC hDC = NULL; int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); HWND hDesktopWnd = GetDesktopWindow(); HDC hDesktopDC = GetDC(hDesktopWnd); HDC hCaptureDC = CreateCompatibleDC(hDesktopDC); HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight); SelectObject(hCaptureDC,hCaptureBitmap); BitBlt(hCaptureDC,0,0,nScreenWidth

c++ how to send Hbitmap over socket

非 Y 不嫁゛ 提交于 2020-01-13 07:06:10
问题 My GetScreen function looks like: void GetScreen(int clientSocket, const char *filename) { HDC hDC = NULL; int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); HWND hDesktopWnd = GetDesktopWindow(); HDC hDesktopDC = GetDC(hDesktopWnd); HDC hCaptureDC = CreateCompatibleDC(hDesktopDC); HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight); SelectObject(hCaptureDC,hCaptureBitmap); BitBlt(hCaptureDC,0,0,nScreenWidth

Winforms: How to speed up Invalidate()?

时光总嘲笑我的痴心妄想 提交于 2020-01-09 19:08:54
问题 I'm developing a retained mode drawing application in GDI+. The application can draw simple shapes to a canvas and perform basic editing. The math that does this is optimized to the last byte and is not an issue. I'm drawing on a panel that is using the built-in Controlstyles.DoubleBuffer. Now, my problem arises if I run my app maximized on a big monitor (HD in my case). If I try to draw a line from one corner of the (big) canvas to the diagonally opposite other, it will start to lag and the

Custom richtextbox control kerning issues

泪湿孤枕 提交于 2020-01-06 06:56:25
问题 Okay, so I have been working on something for a little while and I have gotten to the point where I am planning the Text rendering part. I can already draw strings of text in two ways; DrawString and TextRenderer.DrawText. I prefer DrawText since measuring text is more accurate when using TextRenderer.Measure text. I have a class: public class Character { public string character {get; set; } public Font font {get; set; } public Point position {get; set; } } And a list of all characters

How to construct a GDI+ Bitmap object from a Device-Dependent HBITMAP

泪湿孤枕 提交于 2020-01-06 05:24:06
问题 I want to use GDI+ method Image::Save() to save a DDB to a file in the following scenario: HBITMAP hBitmap = CreateCompatibleBitmap(hDC, 200, 200) ; ... //hBitmap is a DDB so I need to pass an HPALETTE Gdiplus::Bitmap(hBitmap, ???HPALETTE??? ).Save(L"file.png", ...) ; The problem is that Bitmap constructor asks for an HPALETTE when the bitmap is not a device-independent bitmap. Where do I get the necessary HPALETTE from? FOLLOWUP: One of the answers suggests passing NULL as the HPALETTE

BITMAPV5HEADER getting RGBA keep A at 255

怎甘沉沦 提交于 2020-01-06 02:37:13
问题 I am obtaining a byte array of a screenshot by the following, this is done in ctypes, there is no issues with the ctypes, if I gave this a ctypes tag the ctypes folks would be confused, so I simplified out all the error checking etc to show you the procedure. CreateDC('DISPLAY', null, null, null); nWidth = GetDeviceCaps(hdcScreen, HORZRES); // 1280 // numbers are always divisilbe by 4 nHeight = GetDeviceCaps(hdcScreen, ostypes.CONST.VERTRES); // 1024 nBPP = GetDeviceCaps(hdcScreen, BITSPIXEL)