gdi

Direct2D - Emulating Color Keyed Transparent Bitmaps

戏子无情 提交于 2019-12-03 08:34:08
I'm currently updating a Windows GDI application to use Direct2D rendering and I need to support "transparent" bitmaps via color-keying for backwards compatibility. Right now I'm working with a HWND render target and a converted WIC bitmap source (to GUID_WICPixelFormat32bppPBGRA). My plan so far is to create a IWICBitmap from the converted bitmap, Lock() it, and then process each pixel setting it's alpha value to 0 if it matches the color key. This seems a bit "brute force" - Is this the best method of approaching this or is there a better way? Edit: In the interests of completeness here's an

Win32: Does a window have the same HDC for its entire lifetime?

有些话、适合烂在心里 提交于 2019-12-03 08:18:17
Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my control's window, but is that allowed? When Windows sends me a WM_PAINT message, i am supposed to call BeginPaint / EndPaint to properly acknowledge that i've painted it, and to internally clear the invalid region: BeginPaint(hWnd, {out}paintStruct); try //Do my painting finally EndPaint(hWnd, paintStruct); end; But calling BeginPaint also returns me

Looking for a faster-than-GDI solution for rendering dynamic data plots

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've written a simple GDI-based data plotter using C++/CLI but it's not particularly fast (some basic profiling indicates it's the rendering to screen that's the problem). Is there any way to enable hardware acceleration for a UserControl or is there a .net interface for direct3D? ...or are there some other options I could consider. We're using managed code so the solution really needs to be CLI compatible if at all possible. [Edit] In case it helps, I'm rending strips (128 data points) of rectangles which are each 2x2 pixels using

how to fill gradient for roundrect in pure gdi (not gdi+)

依然范特西╮ 提交于 2019-12-03 07:32:46
just in pure gdi. thoughts or code are all welcome. Create a rounded rect as a path, select the path as the clipping path, then do a gradient fill of the same rectangle. Code with MFC would look like this: int top = 10; int left = 10; int right = 200; int bottom = 200; int radius = 20; pDC->BeginPath(); pDC->RoundRect(left, top, right, bottom, radius, radius); pDC->EndPath(); pDC->SelectClipPath(RGN_COPY); TRIVERTEX vertices[2]; vertices[0].x = left; vertices[0].y = top; vertices[0].Red = 0xffff; vertices[0].Green = 0; vertices[0].Blue = 0; vertices[0].Alpha = 0xffff; vertices[1].x = right;

How to color blend (colorize by specified alpha value) the canvas area using pure GDI?

不羁岁月 提交于 2019-12-03 06:35:25
I'd like to color blend (colorize by specified alpha value) the area of a canvas using pure Windows GDI (so without GDI+, DirectX or similar, no OpenGL, no assembler or a 3rd party libraries). I've created the following function and I'd like to know if there is a more efficient or easier way to do this: procedure ColorBlend(const ACanvas: HDC; const ARect: TRect; const ABlendColor: TColor; const ABlendValue: Integer); var DC: HDC; Brush: HBRUSH; Bitmap: HBITMAP; BlendFunction: TBlendFunction; begin DC := CreateCompatibleDC(ACanvas); Bitmap := CreateCompatibleBitmap(ACanvas, ARect.Right - ARect

Is TDirect2DCanvas slow or am I doing something wrong?

ぃ、小莉子 提交于 2019-12-03 05:45:48
问题 While looking for alternatives to replace GDI, I was trying to test Delphi's 2010 TDirect2DCanvas performance in Windows 7. I tested it by drawing a huge polyline using Direct2D and the result was absurdly slow, even with 500 times less data than the amount I've ran the same test using GDI (and I didn't even use a bitmap as backbuffer in GDI, I just drew to the form canvas directly). So I guess either: a) Direct2D is slower than GDI; b) TDirect2DCanvas is slow; c) I'm doing something wrong

How to find out DC's dimensions?

血红的双手。 提交于 2019-12-03 05:28:18
Let's say I have a handle to device context (naturally, in Windows environment): HDC hdc; How can I get the width and height of it? A device context (DC) is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. By width and height I'm guessing you are referring to the bitmap painted ? If so then i guess you can try the following : BITMAP structBitmapHeader; memset( &structBitmapHeader, 0, sizeof(BITMAP) ); HGDIOBJ hBitmap = GetCurrentObject(hDC, OBJ_BITMAP); GetObject(hBitmap, sizeof(BITMAP), &structBitmapHeader); /

How to get list of GDI handles

心已入冬 提交于 2019-12-03 03:53:32
I'm trying to write, using DLL injection method, application which displays bitmaps used by another program and I want to get for this specific process list of GDI Handles which it is using (list like in GDIView.exe utility). I found article about NtQuerySystemInformation function, but this description only works with handles to Kernel Objects. Can somebody help? Here is a console application code that dumps all GDI handles out for a given process identifier. It should compile and work fine for 32 or 64-bit applications, as well as 32-bit application running on 64-bit OSes. It uses a lot of

Is it possible to BitBlt directly from a GDI+ bitmap?

巧了我就是萌 提交于 2019-12-03 03:40:54
Is it possible to use BitBlt to copy directly out of a GDI+ bitmap without using GetHBitmap? GetHBitmap is slow because it makes a new copy of the whole image, in addition to and slower than the BitBlt copy, and the given HBITMAP must be disposed. The image is large. Is there a way to point BitBlt to use the pixel data of the original GDI+ image? EDIT: I can get a pointer to where the GDI+ bitmap pixel data is in the memory. Can I create an HBITMAP that points to the GDI+ bitmap pixel data to avoid the extra copy, and BitBlt from that? jnm2 After searching for days, it suddenly hit me that the

“Exclusive” DirectDraw palette isn't actually exclusive

橙三吉。 提交于 2019-12-03 03:40:54
We're maintaining an old video game that uses a full-screen 256-color graphics mode with DirectDraw. The problem is, some applications running in the background sometimes try to change the system palette while the game is running, which results in corrupted graphics. We can (sometimes) detect when this happens by processing the WM_PALETTECHANGED message. A few update versions ago we added logging (just log the window title/class/process name), which helped users identify offending applications and close them. MSN Live Messenger was a common culprit. The problem got worse when we found out that