<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Xamarin.Mac%2F%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B</id>
	<title>Xamarin.Mac/ビットマップに図形を描画する - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Xamarin.Mac%2F%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B"/>
	<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B&amp;action=history"/>
	<updated>2026-06-06T06:44:36Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B&amp;diff=8990&amp;oldid=prev</id>
		<title>2017年8月24日 (木) 07:43にimported&gt;Administratorによる</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B&amp;diff=8990&amp;oldid=prev"/>
		<updated>2017-08-24T07:43:47Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2017年8月24日 (木) 07:43時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l35&quot;&gt;35行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;35行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             // この保存は独自の拡張メソッド&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             // この保存は独自の拡張メソッド&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;            // 「Xamarin.Mac/CGImageをファイルに保存する」を参照&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             cgImage.Save(&amp;quot;/tmp/test.png&amp;quot;, MobileCoreServices.UTType.PNG);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             cgImage.Save(&amp;quot;/tmp/test.png&amp;quot;, MobileCoreServices.UTType.PNG);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;Administrator</name></author>
	</entry>
	<entry>
		<id>https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B&amp;diff=8989&amp;oldid=prev</id>
		<title>imported&gt;Administrator: ページの作成:「Core Graphicsを使ってビットマップに図形を描画したいわけだ。 よくあるCore Graphicsのサンプルだとビューに直接描画ばかりでオ...」</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Xamarin.Mac/%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97%E3%81%AB%E5%9B%B3%E5%BD%A2%E3%82%92%E6%8F%8F%E7%94%BB%E3%81%99%E3%82%8B&amp;diff=8989&amp;oldid=prev"/>
		<updated>2017-08-24T07:43:10Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「Core Graphicsを使ってビットマップに図形を描画したいわけだ。 よくあるCore Graphicsのサンプルだとビューに直接描画ばかりでオ...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Core Graphicsを使ってビットマップに図形を描画したいわけだ。&lt;br /&gt;
よくあるCore Graphicsのサンプルだとビューに直接描画ばかりでオフスクリーン（ビットマップ）への描画はあまりないようだ。そのためこの方法で正しいのかは知らない。とりあえず動いてはいる。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
            // まずオフスクリーンとなるビットマップを作る&lt;br /&gt;
            var bitmapRep = new NSBitmapImageRep(&lt;br /&gt;
                planes: IntPtr.Zero,&lt;br /&gt;
                width: 100,&lt;br /&gt;
                height: 100,&lt;br /&gt;
                bps: 8,&lt;br /&gt;
                spp: 4,&lt;br /&gt;
                alpha: true,&lt;br /&gt;
                isPlanar: false,&lt;br /&gt;
                colorSpaceName: NSColorSpace.DeviceRGB,&lt;br /&gt;
                rBytes: 0,&lt;br /&gt;
                pBits: 0&lt;br /&gt;
            );&lt;br /&gt;
&lt;br /&gt;
            // 描画コンテキストを作る&lt;br /&gt;
            using (var offscreenContext = NSGraphicsContext.FromBitmap(bitmapRep))&lt;br /&gt;
            {&lt;br /&gt;
                NSGraphicsContext.CurrentContext = offscreenContext;&lt;br /&gt;
                var cgContext = NSGraphicsContext.CurrentContext.GraphicsPort;&lt;br /&gt;
&lt;br /&gt;
                // 図形を描いてみる&lt;br /&gt;
                cgContext.BeginPath();&lt;br /&gt;
                cgContext.MoveTo(0, 0);&lt;br /&gt;
                cgContext.AddLineToPoint(bitmapRep.Size.Width, bitmapRep.Size.Height);&lt;br /&gt;
                cgContext.ClosePath();&lt;br /&gt;
                cgContext.StrokePath();&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // CGImageを取得する&lt;br /&gt;
            var cgImage = bitmapRep.CGImage;&lt;br /&gt;
&lt;br /&gt;
            // この保存は独自の拡張メソッド&lt;br /&gt;
            cgImage.Save(&amp;quot;/tmp/test.png&amp;quot;, MobileCoreServices.UTType.PNG);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 関連項目 ==&lt;br /&gt;
* [[Xamarin.Mac/CoreGraphicsの基本的な使い方]]&lt;br /&gt;
* [[Xamarin.Mac/CGImageをファイルに保存する]]&lt;br /&gt;
&lt;br /&gt;
[[category: Xamarin.Mac]]&lt;br /&gt;
[[category: Core Grpahics]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Administrator</name></author>
	</entry>
</feed>