direct2d

ID2D1HwndRenderTarget always having black background instead of transparent

老子叫甜甜 提交于 2019-12-01 17:27:25
I am trying to create a simple transparent window where I can draw with Direct2D. So far what I have done: Created window Set style to WS_EX_LAYERED Set alpha color key as #FFF Draw using Windows Graphics a white rectangle Now window is transparent with per-pixel alpha Then make a target out of the window and draw using Direct2D Make ALPHA _PREMULIPLIED target Clear with #FFF with 0.0f alpha Window is now black I just don't know how to make window to transparent. If you can point out my mistake, I would be obliged I don't think it's possible with directX. However GDI does work. Take a look at

Large images with Direct2D

折月煮酒 提交于 2019-11-30 23:24:08
Currently I am developing application for the Windows Store which does real time-image processing using Direct2D. It must support various sizes of images. The first problem I have faced is how to handle the situations when the image is larger than the maximum supported texture size. After some research and documentation reading I found the VirtualSurfaceImageSource as a solution. The idea was to load the image as IWICBitmap then to create render target with CreateWICBitmapRenderTarget (which as far as I know is not hardware accelerated). After some drawing operations I wanted to display the

Replace GDI+ DrawImage with PInvoked GDI and transparent PNG's

血红的双手。 提交于 2019-11-30 07:31:29
I've created an image service in C# which takes a base layer image (JPG), layers one more more transparent PNG's (32 bit), and then outputs a final JPG image. I'm trying to squeeze every last millisecond out of this function and my code is bottlenecking at the DrawImage call in GDI+. Managed code here: // Load base image and create graphics Image image = LoadImage(renderSettings.RenderedImageDirectory + baseLayer); Graphics graphics = Graphics.FromImage(image); graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graphics.InterpolationMode = System.Drawing

Can't create Direct2D DXGI Surface

人走茶凉 提交于 2019-11-29 16:56:45
I'm calling this method: http://msdn.microsoft.com/en-us/library/dd371264(VS.85).aspx The call fails with E_NOINTERFACE . The documentation is especially unhelpful as to why this may happen. I've enabled all of the DirectX 11 debug stuff and that's the best I got. I know that I have a valid IDXGISurface1* (also tried IDXGISurface ) and the other parameters are set correctly. Any ideas as to why this call may fail? Edit: I also am having problems creating D3D11 devices. If I pass nullptr as the IDXGIAdapter* argument in D3D11CreateDeviceAndSwapChain, it works fine, but if I enumerate the

How do I clear a Direct2D render target to fully transparent

白昼怎懂夜的黑 提交于 2019-11-29 10:36:24
I'm trying to draw semi-transparent rectangles on an invisible HWND . However, clearing the window with ID2D1HwndRenderTarget::Clear just makes the entire window black, so when I draw rectangles on top, they look semi-black. If I don't Clear() and don't draw, then the window is invisible, as it should be. Clear() is the culprit here; however if I don't use it then painting messes up pretty badly. Here's the code I'm using in my WindowProc: case WM_PAINT: // Begin drawing pRenderTarget->BeginDraw(); pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity()); // Clear the window pRenderTarget-

Replace GDI+ DrawImage with PInvoked GDI and transparent PNG's

两盒软妹~` 提交于 2019-11-29 10:30:00
问题 I've created an image service in C# which takes a base layer image (JPG), layers one more more transparent PNG's (32 bit), and then outputs a final JPG image. I'm trying to squeeze every last millisecond out of this function and my code is bottlenecking at the DrawImage call in GDI+. Managed code here: // Load base image and create graphics Image image = LoadImage(renderSettings.RenderedImageDirectory + baseLayer); Graphics graphics = Graphics.FromImage(image); graphics.CompositingQuality =

Windows StretchBlt API performance

拜拜、爱过 提交于 2019-11-29 08:05:05
I timed a DDB drawing operation which uses multiple StretchBlt and StretchDIBits calls. And I found that, time to complete is increase/decrease proportionally to the destination window size. With 900x600 window it takes around 5ms, but with 1920x1080 it takes as large as 55ms (source image is 1280x640). It seems Stretch.. APIs don't use any hardware acceleration features. Source image (actually this is temporary drawing canvas) is created with CreateDIBSection because I need resulting (stretched and merged) bitmap's pixel data for every frame drawn . Let's assume, Windows GDI is hopeless. Then

Smooth window resizing in Windows (using Direct2D 1.1)?

爷,独闯天下 提交于 2019-11-29 06:14:50
It annoys me that the resizing of windows in Windows is not as "smooth" as it I'd like it to be (this is the case with Windows programs in general, not just my own. Visual Studio is a good example). It makes the OS and its programs feel "flimsy" and "cheap" (yes, I care about how programs and user interfaces feel , in the same way I care about the sound and feel of closing a car door. It's a reflection of build quality), which in my view affects the overall UX and ultimately the perception of the brand. The redrawing of window contents simply does not keep up with mouse movement during resize.

How do I clear a Direct2D render target to fully transparent

你离开我真会死。 提交于 2019-11-28 03:37:08
问题 I'm trying to draw semi-transparent rectangles on an invisible HWND . However, clearing the window with ID2D1HwndRenderTarget::Clear just makes the entire window black, so when I draw rectangles on top, they look semi-black. If I don't Clear() and don't draw, then the window is invisible, as it should be. Clear() is the culprit here; however if I don't use it then painting messes up pretty badly. Here's the code I'm using in my WindowProc: case WM_PAINT: // Begin drawing pRenderTarget-

How to save ID2D1Bitmap to PNG file

懵懂的女人 提交于 2019-11-28 02:04:22
I faced a problem when trying to save ID2D1Bitmap (that created from ID2D1HwndRenderTarget) to PNG File. The output image is just empty with white color. HRESULT returned from function call EndDraw() is -2003238894. Thanks for any help. Here is my code: HRESULT CImageUtil::SaveBitmapToFile(PCWSTR uri,ID2D1Bitmap* pBitmap,ID2D1RenderTarget* pRenderTarget) { HRESULT hr = S_OK; ID2D1Factory *pD2DFactory = NULL; IWICBitmap *pWICBitmap = NULL; ID2D1RenderTarget *pRT = NULL; IWICBitmapEncoder *pEncoder = NULL; IWICBitmapFrameEncode *pFrameEncode = NULL; IWICStream *pStream = NULL; if (SUCCEEDED(hr))