gdi

Static controls slightly flicker when main window is resized

痴心易碎 提交于 2019-12-05 10:57:34
INTRODUCTION AND RELEVANT INFORMATION: I have a complex painting to implement in my main window’s WM_PAINT handler. I have submitted a picture bellow to illustrate it: Main window has static controls, instead of buttons, which have style SS_NOTIFY . When user clicks on them, certain actions occur in program. The following picture shows where static controls in the main window are: Map on the orange panel is an EMF file ,top left and right logos are PNG files, and other pictures are bitmaps. In order to implement this task, I have decided to draw the entire picture in WM_PAINT , and to put

StretchDIBits seems slow, Is there any API faster?

纵然是瞬间 提交于 2019-12-05 10:44:12
I want to draw a dib on to a HDC, the same size. I am using : des and src are of the same size. ::StretchDIBits(hdc, des.left,des.top,des.right - des.left,des.bottom - des.top, src.left, GetHeight() - src.bottom, src.right - src.left,src.bottom - src.top, m_pImg->accessPixels(),m_pImg->getInfo(), DIB_RGB_COLORS, SRCCOPY); but I find it is slow, because the des size is the same, I just need to copy the dib onto a dc. Is there any method faster than StretchDIBits? just as StretchBlt (slow) vs Bitblt.(faster) StretchDIBits (slow ) vs ?(faster) The speed difference comes from doing any necessary

What's the fastest way to repeatedly fill a window with RGB data from an array?

ⅰ亾dé卋堺 提交于 2019-12-05 10:15:43
I'm currently writing a simple game. My graphics code runs once per frame (approximately 30 times per second), and writes RGB data to an array with 640 * 480 = 307200 entries. I have created a Win32 window with a client area exactly 640 x 480 pixels in size. What's the fastest way to get my RGB data displayed within the otherwise-empty window? The window will need to be updated every frame, so I need to avoid flickering. Should I use GDI for this? Or is there a faster approach using a different library - say, DirectDraw? Edit: Thanks for all the replies. Firstly, let me rule out Direct2D as an

Direct2D interface and blurry text issue

感情迁移 提交于 2019-12-05 08:23:37
My new application will feature a rich interface which should be resizable on-the-fly uses transparent icons/images etc. For this application I'm trying to decide on using the new Direct2D API against the good old GDI. One of the downsides is of course it does not run on XP, although I've found a bit nastier issues to decide upon: I noticed that outputting text in a Direct2D environment seems a bit blurry (although marketed as a feature). Just look at the text in Firefox 4 with hardware acceleration enabled (or IE9). It seems to be due to the fact that in Direct2D text does not adhere to the

Double Buffering? Win32 c++

不羁岁月 提交于 2019-12-05 05:49:04
I am trying to implement double buffering but it doesn't seem to work i.e. the graphic still flickers. The WM_PAINT gets called everytime when the mouse moves. (WM_MOUSEMOVE) Pasted WM_PAINT below: case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rect; GetClientRect(hWnd, &rect); int width=rect.right; int height=rect.bottom; HDC backbuffDC = CreateCompatibleDC(hdc); HBITMAP backbuffer = CreateCompatibleBitmap( hdc, width, height); int savedDC = SaveDC(backbuffDC); SelectObject( backbuffDC, backbuffer ); HBRUSH hBrush = CreateSolidBrush(RGB(255,255,255));

Should we use OpenGL for 2D graphics?

妖精的绣舞 提交于 2019-12-05 05:19:41
If we want to make an application like MS Paint, should we use OpenGL for render graphics? I want to mention about performance if using traditional GDI vs. OpenGL. And if there are exist some better libs for this purpose, please see me one. GDI, X11, OpenGL... are rendering APIs, i.e. you usually don't use them for image manipulation (you can do this, but it requires some precautions). In a drawing application like MS Paint, if it's pixel based, you'll normally manipulate some picture buffer with customary code, or a special image manipulation library, then send the full buffer to the

How to add text to icon in c#?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 04:37:33
I want to display an icon [a .ico file] in System tray with some text added to it at runtime. Is there any native WPF way to do it? or snippet for GDI+ also would be grateful. Thank you. Here is the code that worked for me, public static Icon GetIcon(string text) { //Create bitmap, kind of canvas Bitmap bitmap = new Bitmap(32, 32); Icon icon = new Icon(@"Images\PomoDomo.ico"); System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 16, FontStyle.Bold); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); System.Drawing.Graphics graphics =

What is the difference between GDI and GDI+?

强颜欢笑 提交于 2019-12-04 23:12:05
Are there any differences between those two libraries? According to the wikipedia article on GDI : With the introduction of Windows XP, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline . GDI is not object oriented and provide hardware abstraction for win32 plateform. It's written in C GDI+ is object oriented,

c++ how to send Hbitmap over socket

ⅰ亾dé卋堺 提交于 2019-12-04 21:15:12
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,nScreenHeight, hDesktopDC,0,0,SRCCOPY|CAPTUREBLT); SaveBitmap(clientSocket, "test.bmp",hCaptureBitmap)

Possible bug with .net winforms, or am I just missing something? GDI object leak

左心房为你撑大大i 提交于 2019-12-04 20:19:18
Could someone please tell me what is going wrong? After removing tons of code to find our GDI object leak (using task manager and watching the "GDI Objects" column grow to 10,000 and our app crashing) I reduced the code down to only .net code without any custom business code. We are still getting the issue. I created a test app to replicate the issue, which has the following basic behavior. Open the a form 150 times (150 is nothing special, just a number large enough to easily see "stuck" handles). A timer on the form will close the form after 1 second Run the Garbage collector (not really