Bitmap.GetPixel メソッドとは? わかりやすく解説

Bitmap.GetPixel メソッド

この Bitmap指定したピクセルの色を取得します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

例外例外
例外種類条件

ArgumentOutOfRangeException

x が 0 未満か、または Width上です。

または

y が 0 未満か、または Height上です。

Exception

操作失敗しました

使用例使用例

次の例は、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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からBitmap.GetPixel メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBitmap.GetPixel メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBitmap.GetPixel メソッドを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Bitmap.GetPixel メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Bitmap.GetPixel メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS