direct2d

Direct2D : Unhandled Exception In WM_RESIZE switch case

老子叫甜甜 提交于 2019-12-04 03:42:06
问题 I am creating a Simple Direct2D Application. Unfortunately it is giving an unhandled exception. The function where it is taking place: void DemoApp::OnResize(UINT width, UINT height) { if (m_pRenderTarget) <----|****The exception occurs here.....**** { // Note: This method can fail, but it's okay to ignore the // error here, because the error will be returned again // the next time EndDraw is called. m_pRenderTarget->Resize(D2D1::SizeU(width, height)); } } And the code snippet calling

Pixels in Direct2D

点点圈 提交于 2019-12-03 17:50:04
问题 The dark gray lines are supposed to be black and 1 pixel wide: pRT->DrawLine(Point2F(100, 120), Point2F(300, 120), blackbrush, 1); The light gray lines are supposed to be black and 0.5 pixel wide: pRT->DrawLine(Point2F(120, 130), Point2F(280, 130), blackbrush, 0.5); Instead, they are both 2 pixels wide. If I ask for 2 pixels wide, the line is black, but naturally 2 pixels wide. The render target has the same size as the client area of the window. I would like pixel accuracy like in GDI, one

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

Pixels in Direct2D

依然范特西╮ 提交于 2019-12-03 06:29:28
The dark gray lines are supposed to be black and 1 pixel wide: pRT->DrawLine(Point2F(100, 120), Point2F(300, 120), blackbrush, 1); The light gray lines are supposed to be black and 0.5 pixel wide: pRT->DrawLine(Point2F(120, 130), Point2F(280, 130), blackbrush, 0.5); Instead, they are both 2 pixels wide. If I ask for 2 pixels wide, the line is black, but naturally 2 pixels wide. The render target has the same size as the client area of the window. I would like pixel accuracy like in GDI, one coordinate = one pixel and pure colors... Thanks. Direct2D is rendering correctly. When you give it a

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

Resizing Render Target Direct2D after WM_SIZE

天大地大妈咪最大 提交于 2019-12-02 09:18:00
Quick question guys... I am currently working with Directx3D and 2D and I was wondering if I have to recreate the render target when the Windows is resized or does Direct2D automatically detects this, since it's bound to the DXGISurface(back-buffer of the swapchain) when I created it. Here is the code that I used to bind the render targets together: ComPtr<IDXGISurface1> dxgibackBuffer; hr = m_pDxSwapchain->GetBuffer(0, IID_PPV_ARGS(&dxgibackBuffer)); D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1( D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW, D2D1:

Mapping corners to arbitrary positions using Direct2D

我的梦境 提交于 2019-12-02 04:38:27
问题 I'm using WIC and Direct2D (via SharpDX) to composite photos into video frames. For each frame I have the exact coordinates where each corner will be found. While the photos themselves are a standard aspect ratio (e.g. 4:3 or 16:9) the insertion points are not -- they may be rotated, scaled, and skewed. Now I know in Direct2D I can apply matrix transformations to accomplish this... but I'm not exactly sure how. The examples I've seen are more about applying specific transformations (e.g.

How to save a ID2D1Bitmap to a file using WIC?

假如想象 提交于 2019-12-02 03:43:51
I have a problem with saving a bitmap into a file. I'm using How to save ID2D1Bitmap to PNG file as a reference, but I have a different error than the one posted in that. I get error 0x88990015 HRESULT, which means: The resource used was created by a render target in a different resource domain. Here's my code: void Wnd::SavePng(LPCWSTR Path,ID2D1Bitmap* pBit) { CComPtr<ID2D1RenderTarget> pRT; CComPtr<IWICBitmap> pB; CComPtr<IWICBitmapEncoder> pEncoder; CComPtr<IWICBitmapFrameEncode> pFrame; CComPtr<IWICStream> pStream; WICPixelFormatGUID format = GUID_WICPixelFormat32bppPBGRA; HRESULT Hr = m

Mapping corners to arbitrary positions using Direct2D

我的梦境 提交于 2019-12-01 23:18:32
I'm using WIC and Direct2D (via SharpDX) to composite photos into video frames. For each frame I have the exact coordinates where each corner will be found. While the photos themselves are a standard aspect ratio (e.g. 4:3 or 16:9) the insertion points are not -- they may be rotated, scaled, and skewed. Now I know in Direct2D I can apply matrix transformations to accomplish this... but I'm not exactly sure how. The examples I've seen are more about applying specific transformations (e.g. rotate 30 degrees) than trying to match an exact destination. Given that I know the exact coordinates (A,B

ID2D1HwndRenderTarget always having black background instead of transparent

本小妞迷上赌 提交于 2019-12-01 17:50:02
问题 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