{"id":478416,"date":"2026-05-03T22:28:07","date_gmt":"2026-05-03T22:28:07","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=478416"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=478416","title":{"rendered":"Direct 2D #9 \u041e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430\u0445"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 WIC \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u0432 Direct3D, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e DXGI-\u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0436\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u0430\u044f, \u043d\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 &#8212; \u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u043a \u0441\u043b\u043e\u0432\u0443, \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043e\u0439:<\/p>\n<p>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 &#8212; \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c (\u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438 &#8212; \u044d\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430).<\/p>\n<p>\u0421\u043f\u0440\u0430\u0439\u0442 &#8212; \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0435\u0451 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c, \u0438 \u0442.\u043f. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0432\u044b \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0435\u0442\u0435 \u043a \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/direct2d\/supported-pixel-formats-and-alpha-modes\" rel=\"noopener noreferrer nofollow\">\u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 Direct2D. <\/a><\/p>\n<p>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c &#8212; \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u041a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0440\u0430\u043d\u0435\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 #8, \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0431\u0440\u0438\u043a\u0435 WICIWICImagingFactory* pWicFactory;CoCreateInstance(CLSID_WICImagingFactory, ...);2. \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043bIWICBitmapDecoder* pDecoder;pWicFactory-&gt;CreateDecoderFromFilename(L\"image.png\", ..., &amp;pDecoder);3. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043a\u0430\u0434\u0440IWICBitmapFrameDecode* pFrame;pDecoder-&gt;GetFrame(0, &amp;pFrame);4. \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Direct2D \u0444\u043e\u0440\u043c\u0430\u0442IWICFormatConverter* pConverter;pWicFactory-&gt;CreateFormatConverter(&amp;pConverter);pConverter-&gt;Initialize(pFrame, GUID_WICPixelFormat32bppPBGRA, ...);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"cpp\">ID2D1Bitmap* pBitmap;pRenderTarget-&gt;CreateBitmapFromWicBitmap(pConverter, nullptr, &amp;pBitmap);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0431\u0438\u0442\u043c\u0430\u043f\u043e\u043c:  <\/p>\n<ol>\n<li>\n<p>D2D1_SIZE_F GetSize() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c DPI.<\/p>\n<\/li>\n<li>\n<p>D2D1_SIZE_U GetPixelSize() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 DPI<\/p>\n<\/li>\n<li>\n<p>D2D1_PIXEL_FORMAT GetPixelFormat() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>void GetDpi(FLOAT* dpiX, FLOAT* dpiY) &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f DPI, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0431\u0438\u0442\u043c\u0430\u043f.<\/p>\n<\/li>\n<li>\n<p>HRESULT CopyFromMemory(const D2D1_RECT_U* dstRect, const void* srcData, UINT32 pitch) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0431\u0438\u0442\u043c\u0430\u043f. dstRect &#8212; \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432 \u0431\u0438\u0442\u043c\u0430\u043f\u0435, \u043a\u0443\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c (\u0435\u0441\u043b\u0438 nullptr, \u0442\u043e \u0432\u043e \u0432\u0435\u0441\u044c \u0431\u0438\u0442\u043c\u0430\u043f). srcData &#8212; \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, pitch &#8212; \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>HRESULT CopyFromBitmap(const D2D1_POINT_2U* destPoint, ID2D1Bitmap* bitmap, const D2D1_RECT_U* srcRect) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b CopyFromMemory.<\/p>\n<\/li>\n<li>\n<p>HRESULT CopyFromRenderTarget(const D2D1_POINT_2U* destPoint, ID2D1RenderTarget* renderTarget, const D2D1_RECT_U* srcRect) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0441 \u0440\u0435\u043d\u0434\u0435\u0440-\u0442\u0430\u0440\u0433\u0435\u0442\u0430. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b CopyFromBitmap.<\/p>\n<\/li>\n<li>\n<p>HRESULT CreateBitmapBrush(ID2D1Bitmap* bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES* bitmapBrushProperties, const D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1BitmapBrush** bitmapBrush) &#8212; \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u0438\u0441\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. bitmapBrushProperties &#8212; \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u0438\u0441\u0442\u0438 (\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c nullptr \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), brushProperties &#8212; \u043e\u0431\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0442.\u043f.).<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0439\u0434\u0451\u043c \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. \u041a \u0441\u043b\u043e\u0432\u0443, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Windows 8 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ID2D1Bitmap1, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<ol>\n<li>\n<p>HRESULT Map(D2D1_MAP_OPTIONS options, D2D1_MAPPED_RECT* mappedRect) &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u043a\u0430 \u0431\u0438\u0442\u043c\u0430\u043f \u0437\u0430\u043c\u0430\u043f\u043b\u0435\u043d, \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f. options &#8212; \u043e\u043f\u0446\u0438\u0438: D2D1_MAP_OPTIONS_READ (\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u0435\u043d\u0438\u0435), D2D1_MAP_OPTIONS_WRITE (\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044c), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>HRESULT Unmap() &#8212; \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f, \u043d\u0430\u0447\u0430\u0442\u044b\u0439 Map.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435:<\/p>\n<ol>\n<li>\n<p>void DrawBitmap( ID2D1Bitmap* bitmap, const D2D1_RECT_F&amp; destinationRectangle, FLOAT opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode, const D2D1_RECT_F* sourceRectangle = nullptr ) &#8212; \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 ID2D1RenderTarget:<\/p>\n<ol>\n<li>\n<p> bitmap &#8212; \u0440\u0438\u0441\u0443\u0435\u043c\u044b\u0439 \u0431\u0438\u0442\u043c\u0430\u043f <\/p>\n<\/li>\n<li>\n<p>destinationRectangle &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0433\u0434\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c<\/p>\n<\/li>\n<li>\n<p> opacity  &#8212; \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043e\u0442 0.0 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e) \u0434\u043e 1.0 (\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e)<\/p>\n<\/li>\n<li>\n<p>interpolationMode &#8212; \u0440\u0435\u0436\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438: LINEAR (\u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435) \u0438\u043b\u0438 NEAREST_NEIGHBOR (\u0431\u0435\u0437 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f) <\/p>\n<\/li>\n<li>\n<p>sourceRectangle &#8212; \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u043c\u0430\u043f\u0430 (\u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445) \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f. nullptr &#8212; \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c .<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>void DrawBitmap( ID2D1Bitmap* bitmap, const D2D1_RECT_F* destinationRectangle, FLOAT opacity, D2D1_INTERPOLATION_MODE interpolationMode, const D2D1_RECT_F* sourceRectangle, const D2D1_MATRIX_4X4_F* perspectiveTransform ) &#8212; \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 ID2D1DeviceContext:<\/p>\n<ol>\n<li>\n<p>bitmap &#8212; \u0431\u0438\u0442\u043c\u0430\u043f <\/p>\n<\/li>\n<li>\n<p>destinationRectangle &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b<\/p>\n<\/li>\n<li>\n<p> opacity &#8212; \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p> interpolationMode &#8212; D2D1_INTERPOLATION_MODE (\u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ANISOTROPIC) <\/p>\n<\/li>\n<li>\n<p> sourceRectangle &#8212; \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435 <\/p>\n<\/li>\n<li>\n<p>perspectiveTransform &#8212; \u043c\u0430\u0442\u0440\u0438\u0446\u0430 4\u00d74 \u0434\u043b\u044f \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043c\u0430\u043f \u0441 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0438\u043b\u0438 \u0442\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b (\u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438):<\/p>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438: image.png (RGBA, 200\u00d7200). \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9eb\/3c6\/559\/9eb3c6559bb75bd2a324ee22feea16c2.png\" width=\"400\" height=\"403\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9eb\/3c6\/559\/9eb3c6559bb75bd2a324ee22feea16c2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9eb\/3c6\/559\/9eb3c6559bb75bd2a324ee22feea16c2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441  \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0444\u0430\u0439\u043b\u0435:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f9\/91e\/1af\/5f991e1af5c1480309e120b1bcb6d2e5.png\" width=\"157\" height=\"168\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/5f9\/91e\/1af\/5f991e1af5c1480309e120b1bcb6d2e5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f9\/91e\/1af\/5f991e1af5c1480309e120b1bcb6d2e5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f &#171;OK&#187; \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u043a\u043d\u0430:<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25f\/81b\/897\/25f81b89752d71660bd2a6d9ef4cff81.png\" width=\"586\" height=\"493\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/25f\/81b\/897\/25f81b89752d71660bd2a6d9ef4cff81.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25f\/81b\/897\/25f81b89752d71660bd2a6d9ef4cff81.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#define WIN32_LEAN_AND_MEAN#include &lt;windows.h&gt;#include &lt;d2d1.h&gt;#include &lt;d2d1_1.h&gt;        \/\/ ID2D1Bitmap1#include &lt;wincodec.h&gt;#include &lt;cstdio&gt;#include &lt;comdef.h&gt;        #pragma comment(lib, \"d2d1.lib\")#pragma comment(lib, \"windowscodecs.lib\")#pragma comment(lib, \"ole32.lib\")ID2D1Factory* g_pD2DFactory = nullptr;ID2D1HwndRenderTarget* g_pRT = nullptr;ID2D1Bitmap* g_pBitmap = nullptr;   ID2D1Bitmap* g_pCopyBitmap = nullptr;   ID2D1BitmapBrush* g_pBrush = nullptr;   IWICImagingFactory* g_pWICFactory = nullptr;HWND g_hwnd;\/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0447\u0435\u0440\u0435\u0437 WICHRESULT LoadBitmapFromFile(ID2D1RenderTarget* pRT, const wchar_t* filename, ID2D1Bitmap** ppBitmap){    IWICBitmapDecoder* pDecoder = nullptr;    HRESULT hr = g_pWICFactory-&gt;CreateDecoderFromFilename(        filename, nullptr, GENERIC_READ,        WICDecodeMetadataCacheOnLoad, &amp;pDecoder);    if (FAILED(hr)) return hr;    IWICBitmapFrameDecode* pFrame = nullptr;    hr = pDecoder-&gt;GetFrame(0, &amp;pFrame);    pDecoder-&gt;Release();    if (FAILED(hr)) return hr;    IWICFormatConverter* pConverter = nullptr;    hr = g_pWICFactory-&gt;CreateFormatConverter(&amp;pConverter);    if (SUCCEEDED(hr))    {        hr = pConverter-&gt;Initialize(            pFrame,            GUID_WICPixelFormat32bppPBGRA,            WICBitmapDitherTypeNone,            nullptr, 0.f,            WICBitmapPaletteTypeMedianCut);    }    pFrame-&gt;Release();    if (FAILED(hr)) return hr;    hr = pRT-&gt;CreateBitmapFromWicBitmap(pConverter, nullptr, ppBitmap);    pConverter-&gt;Release();    return hr;}\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Direct2D \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432HRESULT InitD2D(HWND hWnd){    HRESULT hr;    \/\/ 1. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 Direct2D    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &amp;g_pD2DFactory);    if (FAILED(hr)) {        MessageBox(hWnd, L\"Failed to create D2D factory\", L\"Error\", MB_ICONERROR);        return hr;    }    \/\/ 2. WIC-\u0444\u0430\u0431\u0440\u0438\u043a\u0430    hr = CoCreateInstance(        CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER,        IID_PPV_ARGS(&amp;g_pWICFactory));    if (FAILED(hr)) {        MessageBox(hWnd, L\"Failed to create WIC factory\", L\"Error\", MB_ICONERROR);        return hr;    }    \/\/ 3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 HWND render target    RECT rc;    GetClientRect(hWnd, &amp;rc);    D2D1_SIZE_U size = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);    hr = g_pD2DFactory-&gt;CreateHwndRenderTarget(        D2D1::RenderTargetProperties(),        D2D1::HwndRenderTargetProperties(hWnd, size),        &amp;g_pRT);    if (FAILED(hr)) {        MessageBox(hWnd, L\"Failed to create render target\", L\"Error\", MB_ICONERROR);        return hr;    }    \/\/ 4. \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b    hr = LoadBitmapFromFile(g_pRT, L\"image.png\", &amp;g_pBitmap);    if (FAILED(hr)) {        wchar_t buf[256];        wsprintf(buf, L\"Failed to load image.png\\nHRESULT: 0x%08X\", hr);        MessageBox(hWnd, buf, L\"Error\", MB_ICONERROR);        return hr;    }    \/\/ ------------------- GetSize \/ GetPixelSize \/ GetPixelFormat \/ GetDpi ------------------    D2D1_SIZE_F dipSize = g_pBitmap-&gt;GetSize();    D2D1_SIZE_U pxSize = g_pBitmap-&gt;GetPixelSize();    D2D1_PIXEL_FORMAT fmt = g_pBitmap-&gt;GetPixelFormat();    FLOAT dpiX, dpiY;    g_pBitmap-&gt;GetDpi(&amp;dpiX, &amp;dpiY);    char msg[256];    sprintf_s(msg, \"Size (DIP): %.1f x %.1f\\nPixel size: %u x %u\\nFormat: %u, Alpha: %u\\nDPI: %.0f x %.0f\",        dipSize.width, dipSize.height, pxSize.width, pxSize.height, fmt.format, fmt.alphaMode, dpiX, dpiY);    MessageBoxA(hWnd, msg, \"Bitmap Info\", MB_OK);    \/\/ ------------------- CopyFromMemory ------------------    UINT w = pxSize.width, h = pxSize.height;    \/\/ \u041f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 100x100    BYTE* redData = new BYTE[w * h * 4];    for (UINT y = 0; y &lt; h; ++y)        for (UINT x = 0; x &lt; w; ++x)        {            UINT idx = (y * w + x) * 4;            redData[idx + 0] = 0;        \/\/ B            redData[idx + 1] = 0;        \/\/ G            redData[idx + 2] = 255;      \/\/ R            redData[idx + 3] = 128;      \/\/ A        }    D2D1_RECT_U dstRect = D2D1::RectU(0, 0, 100, 100);    g_pBitmap-&gt;CopyFromMemory(&amp;dstRect, redData, w * 4);    delete[] redData;    \/\/ ------------------- CopyFromBitmap ------------------    D2D1_BITMAP_PROPERTIES bmpProps = D2D1::BitmapProperties(g_pBitmap-&gt;GetPixelFormat());    g_pRT-&gt;CreateBitmap(pxSize, bmpProps, &amp;g_pCopyBitmap);    g_pCopyBitmap-&gt;CopyFromBitmap(nullptr, g_pBitmap, nullptr);    \/\/ ------------------- CopyFromRenderTarget ------------------    ID2D1BitmapRenderTarget* pBmpRT = nullptr;    g_pRT-&gt;CreateCompatibleRenderTarget(D2D1::SizeF((FLOAT)w, (FLOAT)h), &amp;pBmpRT);    pBmpRT-&gt;BeginDraw();    pBmpRT-&gt;Clear(D2D1::ColorF(D2D1::ColorF::LimeGreen));    pBmpRT-&gt;EndDraw();    D2D1_POINT_2U destPoint = { 0, 100 };    D2D1_RECT_U srcRect = D2D1::RectU(0, 0, 100, 100);    g_pBitmap-&gt;CopyFromRenderTarget(&amp;destPoint, pBmpRT, &amp;srcRect);    pBmpRT-&gt;Release();    \/\/ ------------------- Map \/ Unmap (ID2D1Bitmap1) ------------------    ID2D1Bitmap1* pBitmap1 = nullptr;    hr = g_pBitmap-&gt;QueryInterface(IID_PPV_ARGS(&amp;pBitmap1));    if (SUCCEEDED(hr))    {        D2D1_MAPPED_RECT mapped;        hr = pBitmap1-&gt;Map(D2D1_MAP_OPTIONS_WRITE, &amp;mapped);        if (SUCCEEDED(hr))        {            \/\/ \u0417\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 (100,0)-(200,100)            for (UINT y = 0; y &lt; 100; ++y)            {                BYTE* pixel = mapped.bits + y * mapped.pitch + 100 * 4;                for (UINT x = 100; x &lt; 200; ++x)                {                    pixel[0] = 255;  \/\/ B                    pixel[1] = 0;    \/\/ G                    pixel[2] = 0;    \/\/ R                    pixel[3] = 255;  \/\/ A                    pixel += 4;                }            }            pBitmap1-&gt;Unmap();        }        pBitmap1-&gt;Release();    }    \/\/ ------------------- CreateBitmapBrush ------------------    D2D1_BITMAP_BRUSH_PROPERTIES brushProps = D2D1::BitmapBrushProperties(        D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP,        D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);    g_pRT-&gt;CreateBitmapBrush(g_pCopyBitmap, brushProps, &amp;g_pBrush);    D2D1_MATRIX_3X2_F translate = D2D1::Matrix3x2F::Translation(50.0f, 50.0f);    g_pBrush-&gt;SetTransform(translate);    return S_OK;}void Render(){    g_pRT-&gt;BeginDraw();    g_pRT-&gt;Clear(D2D1::ColorF(D2D1::ColorF::White));    \/\/ \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u043c\u0430\u043f (\u0441 \u0442\u0440\u0435\u043c\u044f \u0446\u0432\u0435\u0442\u043d\u044b\u043c\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430\u043c\u0438)    g_pRT-&gt;DrawBitmap(g_pBitmap, D2D1::RectF(10, 10, 210, 210));    \/\/ \u041a\u043e\u043f\u0438\u044f    g_pRT-&gt;DrawBitmap(g_pCopyBitmap, D2D1::RectF(220, 10, 420, 210));    \/\/ \u042d\u043b\u043b\u0438\u043f\u0441, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u043e\u0439 \u043a\u0438\u0441\u0442\u044c\u044e    D2D1_ELLIPSE ellipse = D2D1::Ellipse(D2D1::Point2F(350.0f, 350.0f), 150.0f, 100.0f);    g_pRT-&gt;FillEllipse(ellipse, g_pBrush);    g_pRT-&gt;EndDraw();}void Cleanup(){    if (g_pBrush)       g_pBrush-&gt;Release();    if (g_pCopyBitmap)  g_pCopyBitmap-&gt;Release();    if (g_pBitmap)      g_pBitmap-&gt;Release();    if (g_pRT)          g_pRT-&gt;Release();    if (g_pWICFactory)  g_pWICFactory-&gt;Release();    if (g_pD2DFactory)  g_pD2DFactory-&gt;Release();}LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){    switch (msg)    {    case WM_PAINT:        Render();        ValidateRect(hWnd, nullptr);        return 0;    case WM_DESTROY:        Cleanup();        PostQuitMessage(0);        return 0;    }    return DefWindowProc(hWnd, msg, wParam, lParam);}int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int nCmdShow){    \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f COM \u0434\u043b\u044f WIC    CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);    WNDCLASS wc = {};    wc.lpfnWndProc = WndProc;    wc.hInstance = hInstance;    wc.lpszClassName = L\"BitmapDemo\";    RegisterClass(&amp;wc);    g_hwnd = CreateWindow(        wc.lpszClassName, L\"ID2D1Bitmap Methods Demo\",        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 600, 500,        nullptr, nullptr, hInstance, nullptr);    HRESULT hr = InitD2D(g_hwnd);    if (FAILED(hr))    {        wchar_t buf[128];        wsprintf(buf, L\"Initialization failed! HRESULT: 0x%08X\", hr);        MessageBox(g_hwnd, buf, L\"Fatal Error\", MB_ICONERROR);        CoUninitialize();        return 1;    }    ShowWindow(g_hwnd, nCmdShow);    UpdateWindow(g_hwnd);    MSG msg;    while (GetMessage(&amp;msg, nullptr, 0, 0))    {        TranslateMessage(&amp;msg);        DispatchMessage(&amp;msg);    }    CoUninitialize();    return (int)msg.wParam;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \ud83d\ude00 \u0414\u0430, \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u2014 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e \u0447\u0451\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c. \u041a \u0441\u043b\u043e\u0432\u0443, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435.  <\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \ud83d\ude00 \u0414\u0430, \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u0440\u0430\u0439\u0442\u044b &#8212; \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e \u0447\u0451\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c. \u041a \u0441\u043b\u043e\u0432\u0443, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435.  <\/p>\n<p>\u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438\u00a0\u2014 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437\u00a0<a href=\"https:\/\/yoomoney.ru\/fundraise\/1FC5LM5GP86.260118\" rel=\"noopener noreferrer nofollow\">\u0441\u0431\u043e\u0440 \u0432 \u042e\u041c\u0430\u043d\u0438<\/a>\u00a0.  <\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1030942\/\">https:\/\/habr.com\/ru\/articles\/1030942\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 WIC \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.\u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u0432 Direct3D, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e DXGI-\u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0436\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u0430\u044f, \u043d\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 &#8212; \u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u043a \u0441\u043b\u043e\u0432\u0443, \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438.\u041a\u0441\u0442\u0430\u0442\u0438, \u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043e\u0439:\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 &#8212; \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u044c (\u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438 &#8212; \u044d\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430).\u0421\u043f\u0440\u0430\u0439\u0442 &#8212; \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0435\u0451 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c, \u0438 \u0442.\u043f. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0432\u044b \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0435\u0442\u0435 \u043a \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c.\u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 Direct2D. \u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c &#8212; \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u041a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0440\u0430\u043d\u0435\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 #8, \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434:1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0431\u0440\u0438\u043a\u0435 WICIWICImagingFactory* pWicFactory;CoCreateInstance(CLSID_WICImagingFactory, &#8230;);2. \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043bIWICBitmapDecoder* pDecoder;pWicFactory-&gt;CreateDecoderFromFilename(L&#187;image.png&#187;, &#8230;, &amp;pDecoder);3. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043a\u0430\u0434\u0440IWICBitmapFrameDecode* pFrame;pDecoder-&gt;GetFrame(0, &amp;pFrame);4. \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Direct2D \u0444\u043e\u0440\u043c\u0430\u0442IWICFormatConverter* pConverter;pWicFactory-&gt;CreateFormatConverter(&amp;pConverter);pConverter-&gt;Initialize(pFrame, GUID_WICPixelFormat32bppPBGRA, &#8230;);\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b:ID2D1Bitmap* pBitmap;pRenderTarget-&gt;CreateBitmapFromWicBitmap(pConverter, nullptr, &amp;pBitmap);\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0431\u0438\u0442\u043c\u0430\u043f\u043e\u043c:  D2D1_SIZE_F GetSize() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c DPI.D2D1_SIZE_U GetPixelSize() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 DPID2D1_PIXEL_FORMAT GetPixelFormat() &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439.void GetDpi(FLOAT* dpiX, FLOAT* dpiY) &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f DPI, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0431\u0438\u0442\u043c\u0430\u043f.HRESULT CopyFromMemory(const D2D1_RECT_U* dstRect, const void* srcData, UINT32 pitch) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0431\u0438\u0442\u043c\u0430\u043f. dstRect &#8212; \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432 \u0431\u0438\u0442\u043c\u0430\u043f\u0435, \u043a\u0443\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c (\u0435\u0441\u043b\u0438 nullptr, \u0442\u043e \u0432\u043e \u0432\u0435\u0441\u044c \u0431\u0438\u0442\u043c\u0430\u043f). srcData &#8212; \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, pitch &#8212; \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.HRESULT CopyFromBitmap(const D2D1_POINT_2U* destPoint, ID2D1Bitmap* bitmap, const D2D1_RECT_U* srcRect) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b CopyFromMemory.HRESULT CopyFromRenderTarget(const D2D1_POINT_2U* destPoint, ID2D1RenderTarget* renderTarget, const D2D1_RECT_U* srcRect) &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0441 \u0440\u0435\u043d\u0434\u0435\u0440-\u0442\u0430\u0440\u0433\u0435\u0442\u0430. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b CopyFromBitmap.HRESULT CreateBitmapBrush(ID2D1Bitmap* bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES* bitmapBrushProperties, const D2D1_BRUSH_PROPERTIES* brushProperties, ID2D1BitmapBrush** bitmapBrush) &#8212; \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u0438\u0441\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. bitmapBrushProperties &#8212; \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u0438\u0441\u0442\u0438 (\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c nullptr \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), brushProperties &#8212; \u043e\u0431\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0442.\u043f.).\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0439\u0434\u0451\u043c \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. \u041a \u0441\u043b\u043e\u0432\u0443, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Windows 8 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ID2D1Bitmap1, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:HRESULT Map(D2D1_MAP_OPTIONS options, D2D1_MAPPED_RECT* mappedRect) &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0432 \u0432\u0438\u0434\u0435\u043e\u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u043a\u0430 \u0431\u0438\u0442\u043c\u0430\u043f \u0437\u0430\u043c\u0430\u043f\u043b\u0435\u043d, \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f. options &#8212; \u043e\u043f\u0446\u0438\u0438: D2D1_MAP_OPTIONS_READ (\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u0435\u043d\u0438\u0435), D2D1_MAP_OPTIONS_WRITE (\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044c), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f.HRESULT Unmap() &#8212; \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f, \u043d\u0430\u0447\u0430\u0442\u044b\u0439 Map.\u0422\u0435\u043f\u0435\u0440\u044c \u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435:void DrawBitmap( ID2D1Bitmap* bitmap, const D2D1_RECT_F&amp; destinationRectangle, FLOAT opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode, const D2D1_RECT_F* sourceRectangle = nullptr ) &#8212; \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 ID2D1RenderTarget: bitmap &#8212; \u0440\u0438\u0441\u0443\u0435\u043c\u044b\u0439 \u0431\u0438\u0442\u043c\u0430\u043f destinationRectangle &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0433\u0434\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c opacity  &#8212; \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043e\u0442 0.0 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e) \u0434\u043e 1.0 (\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e)interpolationMode &#8212; \u0440\u0435\u0436\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438: LINEAR (\u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435) \u0438\u043b\u0438 NEAREST_NEIGHBOR (\u0431\u0435\u0437 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f) sourceRectangle &#8212; \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u043c\u0430\u043f\u0430 (\u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445) \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f. nullptr &#8212; \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c .void DrawBitmap( ID2D1Bitmap* bitmap, const D2D1_RECT_F* destinationRectangle, FLOAT opacity, D2D1_INTERPOLATION_MODE interpolationMode, const D2D1_RECT_F* sourceRectangle, const D2D1_MATRIX_4X4_F* perspectiveTransform ) &#8212; \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 ID2D1DeviceContext:bitmap &#8212; \u0431\u0438\u0442\u043c\u0430\u043f destinationRectangle &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b opacity &#8212; \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c interpolationMode &#8212; D2D1_INTERPOLATION_MODE (\u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ANISOTROPIC)  sourceRectangle &#8212; \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435 perspectiveTransform &#8212; \u043c\u0430\u0442\u0440\u0438\u0446\u0430 4\u00d74 \u0434\u043b\u044f \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043c\u0430\u043f \u0441 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0438\u043b\u0438 \u0442\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b (\u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438):\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438: image.png (RGBA, 200\u00d7200). \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435:\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441  \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0444\u0430\u0439\u043b\u0435:\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f &#171;OK&#187; \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u043a\u043d\u0430:\u041a\u043e\u0434#define WIN32_LEAN_AND_MEAN#include &lt;windows.h&gt;#include &lt;d2d1.h&gt;#include &lt;d2d1_1.h&gt;        \/\/ ID2D1Bitmap1#include &lt;wincodec.h&gt;#include &lt;cstdio&gt;#include &lt;comdef.h&gt;        #pragma comment(lib, &#171;d2d1.lib&#187;)#pragma comment(lib, &#171;windowscodecs.lib&#187;)#pragma comment(lib, &#171;ole32.lib&#187;)ID2D1Factory* g_pD2DFactory = nullptr;ID2D1HwndRenderTarget* g_pRT = nullptr;ID2D1Bitmap* g_pBitmap = nullptr;   ID2D1Bitmap* g_pCopyBitmap = nullptr;   ID2D1BitmapBrush* g_pBrush = nullptr;   IWICImagingFactory* g_pWICFactory = nullptr;HWND g_hwnd;\/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0438\u0442\u043c\u0430\u043f\u0430 \u0447\u0435\u0440\u0435\u0437 WICHRESULT LoadBitmapFromFile(ID2D1RenderTarget* pRT, const wchar_t* filename, ID2D1Bitmap** ppBitmap){    IWICBitmapDecoder* pDecoder = nullptr;    HRESULT hr = g_pWICFactory-&gt;CreateDecoderFromFilename(        filename, nullptr, GENERIC_READ,        WICDecodeMetadataCacheOnLoad, &amp;pDecoder);    if (FAILED(hr)) return hr;    IWICBitmapFrameDecode* pFrame = nullptr;    hr = pDecoder-&gt;GetFrame(0, &amp;pFrame);    pDecoder-&gt;Release();    if (FAILED(hr)) return hr;    IWICFormatConverter* pConverter = nullptr;    hr = g_pWICFactory-&gt;CreateFormatConverter(&amp;pConverter);    if (SUCCEEDED(hr))    {        hr = pConverter-&gt;Initialize(            pFrame,            GUID_WICPixelFormat32bppPBGRA,            WICBitmapDitherTypeNone,            nullptr, 0.f,            WICBitmapPaletteTypeMedianCut);    }    pFrame-&gt;Release();    if (FAILED(hr)) return hr;    hr = pRT-&gt;CreateBitmapFromWicBitmap(pConverter, nullptr, ppBitmap);    pConverter-&gt;Release();    return hr;}\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Direct2D \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432HRESULT InitD2D(HWND hWnd){    HRESULT hr;    \/\/ 1. \u0424\u0430\u0431\u0440\u0438\u043a\u0430 Direct2D    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &amp;g_pD2DFactory);    if (FAILED(hr)) {        MessageBox(hWnd, L&#187;Failed to create D2D factory&#187;, L&#187;Error&#187;, MB_ICONERROR);        return hr;    }    \/\/ 2. WIC-\u0444\u0430\u0431\u0440\u0438\u043a\u0430    hr = CoCreateInstance(        CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER,        IID_PPV_ARGS(&amp;g_pWICFactory));    if (FAILED(hr)) {        MessageBox(hWnd, L&#187;Failed to create WIC factory&#187;, L&#187;Error&#187;, MB_ICONERROR);        return hr;    }    \/\/ 3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 HWND render target    RECT rc;    GetClientRect(hWnd, &amp;rc);    D2D1_SIZE_U size = D2D1::SizeU(rc.right &#8212; rc.left, rc.bottom &#8212; rc.top);    hr = g_pD2DFactory-&gt;CreateHwndRenderTarget(        D2D1::RenderTargetProperties(),        D2D1::HwndRenderTargetProperties(hWnd, size),        &amp;g_pRT);    if (FAILED(hr)) {        MessageBox(hWnd, L&#187;Failed to create render target&#187;, L&#187;Error&#187;, MB_ICONERROR);        return hr;    }    \/\/ 4. \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b    hr = LoadBitmapFromFile(g_pRT, L&#187;image.png&#187;, &amp;g_pBitmap);    if (FAILED(hr)) {        wchar_t buf[256];        wsprintf(buf, L&#187;Failed to load image.png\\nHRESULT: 0x%08X&#187;, hr);        MessageBox(hWnd, buf, L&#187;Error&#187;, MB_ICONERROR);        return hr;    }    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- GetSize \/ GetPixelSize \/ GetPixelFormat \/ GetDpi &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    D2D1_SIZE_F dipSize = g_pBitmap-&gt;GetSize();    D2D1_SIZE_U pxSize = g_pBitmap-&gt;GetPixelSize();    D2D1_PIXEL_FORMAT fmt = g_pBitmap-&gt;GetPixelFormat();    FLOAT dpiX, dpiY;    g_pBitmap-&gt;GetDpi(&amp;dpiX, &amp;dpiY);    char msg[256];    sprintf_s(msg, &#171;Size (DIP): %.1f x %.1f\\nPixel size: %u x %u\\nFormat: %u, Alpha: %u\\nDPI: %.0f x %.0f&#187;,        dipSize.width, dipSize.height, pxSize.width, pxSize.height, fmt.format, fmt.alphaMode, dpiX, dpiY);    MessageBoxA(hWnd, msg, &#171;Bitmap Info&#187;, MB_OK);    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- CopyFromMemory &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    UINT w = pxSize.width, h = pxSize.height;    \/\/ \u041f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 100&#215;100    BYTE* redData = new BYTE[w * h * 4];    for (UINT y = 0; y &lt; h; ++y)        for (UINT x = 0; x &lt; w; ++x)        {            UINT idx = (y * w + x) * 4;            redData[idx + 0] = 0;        \/\/ B            redData[idx + 1] = 0;        \/\/ G            redData[idx + 2] = 255;      \/\/ R            redData[idx + 3] = 128;      \/\/ A        }    D2D1_RECT_U dstRect = D2D1::RectU(0, 0, 100, 100);    g_pBitmap-&gt;CopyFromMemory(&amp;dstRect, redData, w * 4);    delete[] redData;    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- CopyFromBitmap &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    D2D1_BITMAP_PROPERTIES bmpProps = D2D1::BitmapProperties(g_pBitmap-&gt;GetPixelFormat());    g_pRT-&gt;CreateBitmap(pxSize, bmpProps, &amp;g_pCopyBitmap);    g_pCopyBitmap-&gt;CopyFromBitmap(nullptr, g_pBitmap, nullptr);    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- CopyFromRenderTarget &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    ID2D1BitmapRenderTarget* pBmpRT = nullptr;    g_pRT-&gt;CreateCompatibleRenderTarget(D2D1::SizeF((FLOAT)w, (FLOAT)h), &amp;pBmpRT);    pBmpRT-&gt;BeginDraw();    pBmpRT-&gt;Clear(D2D1::ColorF(D2D1::ColorF::LimeGreen));    pBmpRT-&gt;EndDraw();    D2D1_POINT_2U destPoint = { 0, 100 };    D2D1_RECT_U&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-478416","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/478416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=478416"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/478416\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=478416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=478416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=478416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}