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

Bitmap.SetPixel メソッド

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

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

Public Sub SetPixel ( _
    x As Integer, _
    y As Integer, _
    color As Color _
)
Dim instance As Bitmap
Dim x As Integer
Dim y As Integer
Dim color As Color

instance.SetPixel(x, y, color)
public void SetPixel (
    int x,
    int y,
    Color color
)
public:
void SetPixel (
    int x, 
    int y, 
    Color color
)
public void SetPixel (
    int x, 
    int y, 
    Color color
)
public function SetPixel (
    x : int, 
    y : int, 
    color : Color
)

パラメータ

x

設定するピクセルx 座標

y

設定するピクセルy 座標

color

指定ピクセル割り当てる色を表す Color 構造体

戻り値
このメソッドは値を返しません。

例外例外
使用例使用例

次の例は、Windows フォームでの使用意図してデザインされており、Paint イベント ハンドラパラメータである PaintEventArgs の e が必要です。このコード次のアクション実行します

Public Sub SetPixel_Example(ByVal
 e As PaintEventArgs)

    ' Create a Bitmap object from a file.
    Dim myBitmap As New
 Bitmap("Grapes.jpg")

    ' Draw myBitmap to the screen.
    e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width, _
    myBitmap.Height)

    ' Set each pixel in myBitmap to black.
    Dim Xcount As Integer
    For Xcount = 0 To myBitmap.Width - 1
        Dim Ycount As Integer
        For Ycount = 0 To myBitmap.Height -
 1
            myBitmap.SetPixel(Xcount, Ycount, Color.Black)
        Next Ycount
    Next Xcount

    ' Draw myBitmap to the screen again.
    e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0, myBitmap.Width, _
        myBitmap.Height)
End Sub
public void SetPixel_Example(PaintEventArgs
 e)
{
             
    // Create a Bitmap object from a file.
    Bitmap myBitmap = new Bitmap("Grapes.jpg");
             
    // Draw myBitmap to the screen.
    e.Graphics.DrawImage(myBitmap, 0, 0, myBitmap.Width,
        myBitmap.Height);
             
    // Set each pixel in myBitmap to black.
    for (int Xcount = 0; Xcount < myBitmap.Width;
 Xcount++)
    {
        for (int Ycount = 0; Ycount < myBitmap.Height;
 Ycount++)
        {
            myBitmap.SetPixel(Xcount, Ycount, Color.Black);
        }
    }
             
    // Draw myBitmap to the screen again.
    e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0,
        myBitmap.Width, myBitmap.Height);
}
public:
   void SetPixel_Example( PaintEventArgs^ e )
   {
      // Create a Bitmap object from a file.
      Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" );

      // Draw myBitmap to the screen.
      e->Graphics->DrawImage( myBitmap, 0, 0, myBitmap->Width, myBitmap->Height
 );

      // Set each pixel in myBitmap to black.
      for ( int Xcount = 0; Xcount < myBitmap->Width;
 Xcount++ )
      {
         for ( int Ycount = 0; Ycount <
 myBitmap->Height; Ycount++ )
         {
            myBitmap->SetPixel( Xcount, Ycount, Color::Black );
         }
      }

      // Draw myBitmap to the screen again.
      e->Graphics->DrawImage( myBitmap, myBitmap->Width, 0, myBitmap->Width,
 myBitmap->Height );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS