{"id":3480,"date":"2012-06-04T09:57:27","date_gmt":"2012-06-03T15:57:27","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/3480"},"modified":"2012-06-04T11:50:43","modified_gmt":"2012-06-04T02:50:43","slug":"win8-surfaceimagesource-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%80%81metro-%e3%82%a2%e3%83%97%e3%83%aa%e3%81%ab%e9%83%a8%e5%88%86%e7%9a%84%e3%81%ab-directx-%e6%8f%8f%e7%94%bb%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/3480","title":{"rendered":"[win8] SurfaceImageSource \u3092\u4f7f\u3063\u3066\u3001metro \u30a2\u30d7\u30ea\u306b\u90e8\u5206\u7684\u306b DirectX \u63cf\u753b\u3059\u308b"},"content":{"rendered":"<p>[win8] \u753b\u50cf\u52a0\u5de5\u3092DirectX\u306b\u4efb\u305b\u3066\u3001UI\u306fC#\u306b\u3059\u308b\u6280 | Moonmile Solutions Blog<br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/archives\/3454\">http:\/\/www.moonmile.net\/blog\/archives\/3454<\/a><\/p>\n<p>\u306a\u3068\u3053\u308d\u3067\u3001metro \u30a2\u30d7\u30ea\u3067 DirectX \u3092\u4f7f\u304a\u3046\u3068\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3082\u3063\u3068\u826f\u3044\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3057\u305f\u3002\u65e2\u306b\u3001SurfaceImageSource \u3068\u3044\u3046\u3053\u3068\u3067 DirectX \u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u7528\u610f\u304c\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u306d\u3002<\/p>\n<p>\u308f\u3093\u304f\u307e\u5927\u962a#49\u306e\u8cc7\u6599<br \/>\n<a href=\"http:\/\/jyurimaru.info\/data\/20120602wankuma_osaka49\/20120602_sao.pdf\">http:\/\/jyurimaru.info\/data\/20120602wankuma_osaka49\/20120602_sao.pdf<\/a><br \/>\nSurfaceImageSource<br \/>\n<a href=\"http:\/\/blogs.msdn.com\/b\/windowsappdev_ja\/archive\/2012\/03\/22\/xaml-directx.aspx\">http:\/\/blogs.msdn.com\/b\/windowsappdev_ja\/archive\/2012\/03\/22\/xaml-directx.aspx<\/a><br \/>\nDirectX and XAML interop (Metro style apps using C++ and DirectX) (Preliminary)<br \/>\n<a href=\"http:\/\/64.4.10.18\/ja-jp\/library\/hh825871.aspx\">http:\/\/64.4.10.18\/ja-jp\/library\/hh825871.aspx<\/a><\/p>\n<p>\u306a\u3068\u3053\u308d\u306b\u3001SurfaceImageSource \u3092\u4f7f\u3063\u3066\u3001DirectX \u3067\u63cf\u753b\u3067\u304d\u307e\u3059\u3002\u3068\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nSurfaceImageSource^ surfaceImageSource =\r\n    ref new SurfaceImageSource(rectangle1-&gt;Width, rectangle1-&gt;Height, true);\r\nImageBrush^ brush = ref new ImageBrush();\r\nbrush-&gt;ImageSource = surfaceImageSource;\r\nrectangle1-&gt;Fill = brush;\r\n<\/pre>\n<p>ImageBrush \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u8a2d\u5b9a\u3057\u3066\u3001XAML \u306e UI \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\uff08\u3053\u3053\u3067\u306f\u3001Rectangle \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\uff09\u306e Fill \u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u7c21\u5358\u306b\u8a00\u3048\u3070\u3001\u80cc\u666f\u3067\u4f7f\u3046 bitmap \u578b\u306e\u30d6\u30e9\u30b7\u3092\u4f5c\u3063\u3066 rectangle \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u8a33\u3067\u3059\u3002bitmap \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306e\u63cf\u753b\u3092 DirectX \u3067\u3084\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u63cf\u753b\u3001\u3068\u306f\u9055\u3046\u306e\u3067\u3059\u304c\u3001\u307e\u3041\u666e\u901a\u306e\u753b\u50cf\u3092\u63cf\u753b\u3059\u308b\u3060\u3051\u306a\u3089\u3070\u3053\u308c\u3067\u5341\u5206\u3067\u3059\u3002\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u540c\u58eb\u306e\u91cd\u306a\u308a\u3084\u3001\u900f\u660e\u5ea6\u3082\u6307\u5b9a\u3067\u304d\u308b\u306e\u3067\u76f8\u5f53\u6c4e\u7528\u7684\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u304c&#8230;\u554f\u984c\u306f\u3067\u3059\u306d\u3001\u3053\u306e surfaceImageSource \u3063\u3066\u306e\u306b\u3069\u3046\u3084\u3063\u3066\u63cf\u753b\u3059\u308b\u3093\u3067\u3059\u304b\uff1f\u3068\u3044\u3046\u306e\u304c\u3001\u306a\u304b\u306a\u304b\u3076\u3061\u5f53\u305f\u308a\u307e\u305b\u3093\u3002\u3064\u30fc\u304b\u3001\u300c\u7701\u7565\u300d\u3057\u3066\u308b\u3060\u308d\u30c3!!!\uff08\u610f\u56f3\u7684\u304b\u7121\u610f\u8b58\u7684\u304b\u308f\u304b\u308a\u307e\u305b\u3093\u304c\uff09\u3063\u3066\u306a\u5177\u5408\u3067\u3059\u3002DirectX \u306b\u8a73\u3057\u3051\u308c\u3070 ok \u306a\u3093\u3060\u3051\u3069\u3001\u8a73\u3057\u304f\u306a\u3044\u3068\u9014\u7aef\u306b\u5206\u304b\u3089\u3093\u3068\u3044\u3046\uff08\u79c1\u3092\u542b\u3080\uff09\u6709\u69d8 orz<\/p>\n<p>\u25a0\u3069\u3046\u3084\u3063\u3066\u3001SurfaceImageSource \u306b\u63cf\u753b\u3059\u308b\u306e\u304b\uff1f<\/p>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001<\/p>\n<p>Direct2D Quickstart for Windows 8 Release Preview<br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/hh780340(v=vs.85).aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/hh780340(v=vs.85).aspx<\/a><\/p>\n<p>\u3042\u305f\u308a\u306b\u66f8\u3044\u3066\u3042\u308a\u307e\u3057\u305f\u3002\u76f4\u63a5\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u300cStep 3: Create an ID2D1Device and an ID2D1DeviceContext\u300d\u306e\u300cID2D1DeviceContext::CreateBitmapFromDxgiSurface\u300d\u306e\u8a18\u8ff0\u304c\u809d\u3067\u3059\u3002<br \/>\nSurfaceImageSource \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u3001\u63cf\u753b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\uff08ID2D1DeviceContext\uff09\u306b\u7d50\u3073\u3064\u3051\u308b\u305f\u3081\u306b\u3001CreateBitmapFromDxgiSurface \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u8a33\u3067\u3059\u306d\u3002\u306a\u308b\u307b\u3069\u3002\u77e5\u3089\u306a\u3044\u3068\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u306a orz<\/p>\n<p>\u7d50\u3073\u3064\u3051\u308b\u5148\u306f\u3001bitmap \u3067\u306a\u304f\u3066\u3082\u826f\u3044\u3089\u3057\u304f\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u3063\u3066\u3044\u308b\u30b5\u30f3\u30d7\u30eb\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001ComPtr&lt;ID2D1Bitmap1&gt; \u3092\u4f7f\u3046\u306e\u304c\u4e00\u756a\u697d\u3063\u307d\u3044\u306e\u3067\u3001\u3053\u3093\u306a\u98a8\u306b\u66f8\u304d\u307e\u3059\u3002<br \/>\nNative \u306e surface \u3067\u3001BeginDraw\/EndDraw \u3092\u4f7f\u3046\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u9593\u306b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u65b9\u306e BeginDraw\/EndDraw \u3092\u7a81\u3063\u8fbc\u3081\u3070 ok &#8230; \u3068\u3044\u3046\u304b\u3001\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u4f7f\u3063\u305f\u63cf\u753b\u90e8\u5206\u306f\u5225\u306b\u3001surface \u306e\u63cf\u753b\u306e\u4e2d\u306b\u3042\u308b\u5fc5\u8981\u306f\u306a\u304f\u3063\u3066\u3001bitmap \u306b\u66f8\u304d\u8fbc\u3093\u3067\u3042\u308b\u306e\u3067\u5225\u306e\u3068\u3053\u308d\u3067\u63cf\u753b\u3057\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002\u305d\u306e\u3042\u305f\u308a\u306f\u5f8c\u7a0b\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tComPtr&lt;IDXGISurface&gt; surface;\r\n\tRECT updateRect = { 0,0,400,300 };\r\n\tPOINT offset = { 0,0 };\r\n\r\n\tHRESULT beginDrawHR = m_sisNative-&gt;BeginDraw(updateRect, &amp;surface, &amp;offset);\r\n\t\/\/ draw to IDXGISurface (the surface paramater)\r\n\r\n\tComPtr&lt;ID2D1Bitmap1&gt; bitmap;\r\n\tm_d2dContext-&gt;CreateBitmapFromDxgiSurface( surface.Get(), NULL, &amp;bitmap );\r\n\tm_d2dContext-&gt;SetTarget( bitmap.Get());\r\n\r\n\tm_d2dContext-&gt;BeginDraw();\r\n\tm_d2dContext-&gt;Clear(D2D1::ColorF(D2D1::ColorF::Green));\r\n\t\r\n\tPlatform::String^ text = &amp;quot;\u65e5\u672c\u8a9e&amp;quot;;\r\n    IDWriteTextFormat *pTextFormat = NULL;\r\n    ID2D1SolidColorBrush *pBlackBrush = NULL;\r\n\r\n\t\t\/\/ static const WCHAR sc_fontName&#x5B;] = L&amp;quot;Calibri&amp;quot;;\r\n\t\tstatic const WCHAR sc_fontName&#x5B;] = L&amp;quot;HGP\u660e\u671dE&amp;quot;;\r\n        static const FLOAT sc_fontSize = 32;\r\n\r\n        m_dwriteFactory-&gt;CreateTextFormat(\r\n            sc_fontName,\r\n            NULL,\r\n            DWRITE_FONT_WEIGHT_NORMAL,\r\n            DWRITE_FONT_STYLE_NORMAL,\r\n            DWRITE_FONT_STRETCH_NORMAL,\r\n            sc_fontSize,\r\n            L&amp;quot;&amp;quot;, \/\/locale\r\n            &amp;pTextFormat\r\n            );\r\n\r\n        m_d2dContext-&gt;CreateSolidColorBrush(\r\n            D2D1::ColorF(D2D1::ColorF::Black),\r\n            &amp;pBlackBrush\r\n            );\r\n\r\n        m_d2dContext-&gt;DrawText(\r\n\t\t\ttext-&gt;Data(),\r\n\t\t\ttext-&gt;Length(),\r\n            pTextFormat,\r\n            D2D1::RectF(0, 0, 400,300),\r\n            pBlackBrush);\r\n\t\r\n\tm_d2dContext-&gt;EndDraw();\r\n\r\n\tm_sisNative-&gt;EndDraw();\r\n\t\/\/ The SurfaceImageSource object&#039;s underlying ISurfaceImageSourceNative object contains the completed bitmap.\r\n\tImageBrush^ brush = ref new ImageBrush();\r\n\tbrush-&gt;ImageSource = surfaceImageSource;\r\n\r\n\t\/\/ fill;\r\n\trect1-&gt;Fill = brush;\r\n<\/pre>\n<p>\u3053\u308c\u3060\u3068\u3001\u518d\u63cf\u753b\u3059\u308b\u305f\u3073\u306b bitmap \u3092\u4f5c\u6210\u3059\u308b\u306e\u3067\u51e6\u7406\u306e\u7121\u99c4\u3067\u3059\u3088\u306d\u3002\u3042\u3089\u304b\u3058\u3081\u5225\u306e\u3068\u3053\u308d\u3067 bitmap \u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u306e\u304c\u30d9\u30bf\u30fc\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/06\/wpid-dworkblogimage20120604_02org.jpg\"><img decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/06\/wpid-dworkblogimage20120604_02thum.jpg\" border=\"0\" \/><\/a><\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u3053\u3093\u306a\u98a8\u306b\u6271\u3048\u307e\u3059\u3002\u304d\u3061\u3093\u3068\u900f\u660e\u5ea6\uff08Opacity\uff09\u3082\u5b9f\u884c\u3067\u304d\u3066\u3044\u308b\u3057\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306ez-index\uff08\u63cf\u753b\u9806\u5e8f\uff09\u3082\u6709\u52b9\u306a\u306e\u3067\u3001\u304b\u306a\u308a\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u3055\u3066\u3001\u30b0\u30e9\u30d5\u63cf\u753b\u306e\u3088\u3046\u306a\u9759\u7684\u306a\u753b\u50cf\u306f\u3053\u308c\u3067\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u5c11\u3057\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3069\u3046\u306a\u308b\u306e\u304b\uff1f\u304c\u554f\u984c\u3067\u3059\u3088\u306d\u3002\u3053\u306e\u3042\u305f\u308a\u306f\u3001\u5f8c\u3067\u8abf\u3079\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\n\u5b9a\u671f\u7684\u306b ImageBrush \u306e\u4e2d\u8eab\u3092\u5909\u3048\u3066\u3001\u518d\u63cf\u753b\u3092\u3059\u308c\u3070\u5909\u308f\u308b\u3088\u3046\u306a\u6c17\u3082\u3059\u308b\u3051\u3069&#8230;\u3069\u3046\u306a\u306e\u304b\u306a\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[win8] \u753b\u50cf\u52a0\u5de5\u3092DirectX\u306b\u4efb\u305b\u3066\u3001UI\u306fC#\u306b\u3059\u308b\u6280 | Moonmile Solutions Blog http:\/\/www.moonmile.net\/blog\/archives\/3454 \u306a\u3068\u3053\u308d\u3067\u3001m &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/3480\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[46,44],"tags":[],"class_list":["post-3480","post","type-post","status-publish","format-standard","hentry","category-ccx","category-windows-8"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=3480"}],"version-history":[{"count":3,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3480\/revisions"}],"predecessor-version":[{"id":3481,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3480\/revisions\/3481"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=3480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=3480"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=3480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}