BitmapData.Scan0 プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BitmapData.Scan0 プロパティの意味・解説 

BitmapData.Scan0 プロパティ

ビットマップ内の最初ピクセル データアドレス取得または設定します。このデータビットマップ内の最初スキャン ライン考えることもできます

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

Dim instance As BitmapData
Dim value As IntPtr

value = instance.Scan0

instance.Scan0 = value
public IntPtr Scan0 { get; set;
 }
public:
property IntPtr Scan0 {
    IntPtr get ();
    void set (IntPtr value);
}
/** @property */
public IntPtr get_Scan0 ()

/** @property */
public void set_Scan0 (IntPtr value)
public function get Scan0
 () : IntPtr

public function set Scan0
 (value : IntPtr)

プロパティ
ビットマップ内の最初ピクセル データアドレス

使用例使用例

PixelFormat、HeightWidthScan0 の各プロパティ、LockBits メソッドと UnlockBits メソッド、および ImageLockMode 列挙体の使用方法次のコード例示します。この例は、Windows フォームでの使用意図してデザインされています。この例を実行するには、コードフォーム貼り付け、PaintEventArgs として e渡して LockUnlockBitsExample メソッド呼び出すことによって、フォームPaint イベント処理します

Private Sub LockUnlockBitsExample(ByVal
 e As PaintEventArgs)

    ' Create a new bitmap.
    Dim bmp As New Bitmap("c:\fakePhoto.jpg")

    ' Lock the bitmap's bits.  
    Dim rect As New Rectangle(0,
 0, bmp.Width, bmp.Height)
    Dim bmpData As System.Drawing.Imaging.BitmapData
 = bmp.LockBits(rect, _
        Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)

    ' Get the address of the first line.
    Dim ptr As IntPtr = bmpData.Scan0

    ' Declare an array to hold the bytes of the bitmap.
    ' This code is specific to a bitmap with 24 bits per pixels.
    Dim bytes As Integer
 = bmp.Width * bmp.Height * 3
    Dim rgbValues(bytes - 1) As Byte

    ' Copy the RGB values into the array.
    System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)

    ' Set every red value to 255.  
    For counter As Integer
 = 0 To rgbValues.Length - 1 Step 3
        rgbValues(counter) = 255
    Next

    ' Copy the RGB values back to the bitmap
    System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)

    ' Unlock the bits.
    bmp.UnlockBits(bmpData)

    ' Draw the modified image.
    e.Graphics.DrawImage(bmp, 0, 150)

End Sub
private void LockUnlockBitsExample(PaintEventArgs
 e)
{

    // Create a new bitmap.
    Bitmap bmp = new Bitmap("c:\\fakePhoto.jpg");

    // Lock the bitmap's bits.  
    Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
    System.Drawing.Imaging.BitmapData bmpData = 
        bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
        bmp.PixelFormat);
          
    // Get the address of the first line.
   IntPtr ptr = bmpData.Scan0;

    // Declare an array to hold the bytes of the bitmap.
    // This code is specific to a bitmap with 24 bits per pixels.
    int bytes = bmp.Width * bmp.Height * 3;
    byte[] rgbValues = new byte[bytes];

    // Copy the RGB values into the array.
    System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);

    // Set every red value to 255.  
    for (int counter = 0; counter < rgbValues.Length;
 counter+=3)
        rgbValues[counter] = 255;
  
    // Copy the RGB values back to the bitmap
    System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);

    // Unlock the bits.
    bmp.UnlockBits(bmpData);

    // Draw the modified image.
    e.Graphics.DrawImage(bmp, 0, 150);

}
void LockUnlockBitsExample( PaintEventArgs^ e )
{
   // Create a new bitmap.
   Bitmap^ bmp = gcnew Bitmap( "c:\\fakePhoto.jpg" );

   // Lock the bitmap's bits.  
   Rectangle rect = Rectangle(0,0,bmp->Width,bmp->Height);
   System::Drawing::Imaging::BitmapData^ bmpData = bmp->LockBits( rect, System::Drawing::Imaging::ImageLockMode::ReadWrite,
 bmp->PixelFormat );

   // Get the address of the first line.
   IntPtr ptr = bmpData->Scan0;

   // Declare an array to hold the bytes of the bitmap.
   // This code is specific to a bitmap with 24 bits per pixels.
   int bytes = bmp->Width * bmp->Height * 3;
   array<Byte>^rgbValues = gcnew array<Byte>(bytes);

   // Copy the RGB values into the array.
   System::Runtime::InteropServices::Marshal::Copy( ptr, rgbValues, 0, bytes );

   // Set every red value to 255.  
   for ( int counter = 0; counter < rgbValues->Length;
 counter += 3 )
      rgbValues[ counter ] = 255;

   // Copy the RGB values back to the bitmap
   System::Runtime::InteropServices::Marshal::Copy( rgbValues, 0, ptr, bytes );

   // Unlock the bits.
   bmp->UnlockBits( bmpData );

   // Draw the modified image.
   e->Graphics->DrawImage( bmp, 0, 150 );
}
private void LockUnlockBitsExample(PaintEventArgs
 e)
{
    // Create a new bitmap.
    Bitmap bmp = new Bitmap("c:\\fakePhoto.jpg");

    // Lock the bitmap's bits.  
    Rectangle rect = new Rectangle(0, 0, bmp.get_Width(), bmp.get_Height());
    System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, 
        System.Drawing.Imaging.ImageLockMode.ReadWrite, 
        bmp.get_PixelFormat());

    // Get the address of the first line.
    IntPtr ptr = bmpData.get_Scan0();

    // Declare an array to hold the bytes of the bitmap.
    // This code is specific to a bitmap with 24 bits per pixels.
    int bytes = bmp.get_Width() * bmp.get_Height() * 3;
    ubyte rgbValues[] = new ubyte[bytes];

    // Copy the RGB values into the array.
    System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);

    // Set every red value to 255.  
    for (int counter = 0; counter < rgbValues.get_Length();
 counter+=3) {
        rgbValues[counter] = 255;
    }

    // Copy the RGB values back to the bitmap
    System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);

    // Unlock the bits.
    bmp.UnlockBits(bmpData);

    // Draw the modified image.
    e.get_Graphics().DrawImage(bmp, 0, 150);
} //LockUnlockBitsExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BitmapData クラス
BitmapData メンバ
System.Drawing.Imaging 名前空間


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

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

辞書ショートカット

すべての辞書の索引

BitmapData.Scan0 プロパティのお隣キーワード
検索ランキング

   

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



BitmapData.Scan0 プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS