Bitmap.GetPixel メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As Bitmap Dim x As Integer Dim y As Integer Dim returnValue As Color returnValue = instance.GetPixel(x, y)
戻り値
指定したピクセルの色を表す Color 構造体。


次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードでは、ビットマップのピクセルの色を取得し、その色で四角形を塗りつぶします。
Public Sub GetPixel_Example(ByVal e As PaintEventArgs) ' Create a Bitmap object from an image file. Dim myBitmap As New Bitmap("Grapes.jpg") ' Get the color of a pixel within myBitmap. Dim pixelColor As Color = myBitmap.GetPixel(50, 50) ' Fill a rectangle with pixelColor. Dim pixelBrush As New SolidBrush(pixelColor) e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100) End Sub
public void GetPixel_Example(PaintEventArgs e) { // Create a Bitmap object from an image file. Bitmap myBitmap = new Bitmap("Grapes.jpg"); // Get the color of a pixel within myBitmap. Color pixelColor = myBitmap.GetPixel(50, 50); // Fill a rectangle with pixelColor. SolidBrush pixelBrush = new SolidBrush(pixelColor); e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100); }
public: void GetPixel_Example( PaintEventArgs^ e ) { // Create a Bitmap object from an image file. Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" ); // Get the color of a pixel within myBitmap. Color pixelColor = myBitmap->GetPixel( 50, 50 ); // Fill a rectangle with pixelColor. SolidBrush^ pixelBrush = gcnew SolidBrush( pixelColor ); e->Graphics->FillRectangle( pixelBrush, 0, 0, 100, 100 ); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBitmap.GetPixel メソッドを検索する場合は、下記のリンクをクリックしてください。

- Bitmap.GetPixel メソッドのページへのリンク