{"id":3414,"date":"2018-07-11T11:36:42","date_gmt":"2018-07-11T02:36:42","guid":{"rendered":"http:\/\/soundengine.jp\/wordpress\/tips\/?p=3414"},"modified":"2018-07-11T11:40:40","modified_gmt":"2018-07-11T02:40:40","slug":"c%e3%81%aewindows%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%a2%e3%83%97%e3%83%aa%e3%81%a7direct2d","status":"publish","type":"post","link":"https:\/\/soundengine.jp\/wordpress\/tips\/try\/3414\/","title":{"rendered":"C#\u306eWindows\u30d5\u30a9\u30fc\u30e0\u30a2\u30d7\u30ea\u3067Direct2D"},"content":{"rendered":"<p>\u5c11\u3005\u8a66\u3057\u3066\u307f\u305f\u306e\u3067\u81ea\u5206\u3078\u306e\u30e1\u30e2\u7a0b\u5ea6\u306b<\/p>\n<p>\u5229\u7528\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3001SharpDX\u3068SharpDX.Direct2D1\u3068\u3044\u3046\u3082\u306e(SharpDX.DXGI\u3082\u540c\u6642\u306b\u5165\u308b\u3063\u307d\u3044)<\/p>\n<p><!--more--><\/p>\n<p>using\u306b\u306f\u4ee5\u4e0b\u3092\u6307\u5b9a\u3057\u305f\u3002<\/p>\n<pre class=\"lang:c# decode:true \">\r\nusing SharpDX;\r\nusing SharpDX.Direct2D1;\r\nusing SharpDX.DirectWrite;\r\nusing SharpDX.Mathematics.Interop;\r\n<\/pre>\n<p>\u30a6\u30a4\u30f3\u30c9\u30a6\u578b\u306eRenderTarget\u3092\u4f5c\u3063\u3066\u3001\u63cf\u753b\u6642\u306b\u30af\u30ea\u30a2\u3057\u3066\u6587\u5b57\u5217\u3092\u66f8\u304f\u307f\u305f\u3044\u306a\u3082\u306e\u3002\u4eca\u56de\u306f\u3001Panel\u306b\u63cf\u3044\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \">public partial class Form1 : Form\r\n{\r\n\tprivate WindowRenderTarget render;\r\n\r\n\tpublic Form1()\r\n\t{\r\n\t\tInitializeComponent();\r\n\r\n\t\tvar hwnd = new HwndRenderTargetProperties();\r\n\t\thwnd.Hwnd = panel1.Handle;\r\n\t\thwnd.PixelSize = new Size2(panel1.Width, panel1.Height);\r\n\t   \r\n\t\tvar factory = new SharpDX.Direct2D1.Factory();\r\n\t\trender = new SharpDX.Direct2D1.WindowRenderTarget(factory, new RenderTargetProperties(), hwnd);\r\n\t}\r\n\r\n\tprivate void Form1_Paint(object sender, PaintEventArgs e)\r\n\t{\r\n\t\trender.BeginDraw();\r\n\r\n\t\trender.Clear(new RawColor4(0.1f, 0.1f, 0.0f, 1.0f));\r\n\r\n\t\tvar fontFactory = new SharpDX.DirectWrite.Factory();\r\n\t\tvar textFormat = new TextFormat(fontFactory, \"\u30e1\u30a4\u30ea\u30aa\", 24.0f);\r\n\t\tvar textBrush = new SharpDX.Direct2D1.SolidColorBrush(render, new RawColor4(0.4f,0.6f,0.5f,1f));\r\n\t\trender.DrawText(\"\u3042\u3044\u3046\u3048\u304a\", textFormat, new RawRectangleF(10, 10, 400, 50), textBrush, DrawTextOptions.None);\r\n\r\n\t\trender.EndDraw();\r\n\t}\r\n}<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/soundengine.jp\/wordpress\/tips\/files\/2018\/07\/20180711_1.png\" alt=\"\" width=\"802\" height=\"482\" class=\"alignnone size-full wp-image-3448\" srcset=\"https:\/\/soundengine.jp\/wordpress\/tips\/files\/2018\/07\/20180711_1.png 802w, https:\/\/soundengine.jp\/wordpress\/tips\/files\/2018\/07\/20180711_1-300x180.png 300w, https:\/\/soundengine.jp\/wordpress\/tips\/files\/2018\/07\/20180711_1-768x462.png 768w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/p>\n<p>C++\u3067\u3084\u308b\u306e\u3068\u4f3c\u3066\u3044\u308b\u306e\u3067\u3001\u308f\u304b\u308c\u3070\u96e3\u3057\u304f\u306f\u306a\u3044\u306e\u3060\u308d\u3046\u3051\u3069\u3001\u30af\u30e9\u30b9\u3092\u63a2\u3057\u3066\u304f\u308b\u306e\u306b\u4e00\u82e6\u52b4\u2026\u3002\u305f\u3076\u3093\u3001C#\u3063\u3066\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u81a8\u5927\u306b\u3042\u308b\u304b\u3089\u3001\u3069\u3093\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u3082\u305d\u3046\u306a\u3093\u3067\u3057\u3087\u3046\u3051\u3069\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c11\u3005\u8a66\u3057\u3066\u307f\u305f\u306e\u3067\u81ea\u5206\u3078\u306e\u30e1\u30e2\u7a0b\u5ea6\u306b \u5229\u7528\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3001SharpDX\u3068Sh &hellip; <a href=\"https:\/\/soundengine.jp\/wordpress\/tips\/try\/3414\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[33,34],"class_list":["post-3414","post","type-post","status-publish","format-standard","hentry","category-try","tag-c","tag-34"],"_links":{"self":[{"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/posts\/3414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/comments?post=3414"}],"version-history":[{"count":9,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/posts\/3414\/revisions"}],"predecessor-version":[{"id":3450,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/posts\/3414\/revisions\/3450"}],"wp:attachment":[{"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/media?parent=3414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/categories?post=3414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soundengine.jp\/wordpress\/tips\/wp-json\/wp\/v2\/tags?post=3414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}