Bitmap Oluşturucular

Tanım

Bitmap sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

Bitmap(Image)

Belirtilen mevcut görüntüden sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(Stream)

Belirtilen veri akışından sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(String)

Belirtilen dosyadan sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(Image, Size)

Belirtilen mevcut görüntüden sınıfın Bitmap yeni bir örneğini başlatır ve belirtilen boyuta ölçeklendirilir.

Bitmap(Int32, Int32)

Belirtilen boyuta sahip sınıfın Bitmap yeni bir örneğini başlatır.

Bitmap(Stream, Boolean)

Belirtilen veri akışından sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(String, Boolean)

Belirtilen dosyadan sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(Type, String)

Belirtilen kaynaktan sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(Image, Int32, Int32)

Belirtilen mevcut görüntüden sınıfın Bitmap yeni bir örneğini başlatır ve belirtilen boyuta ölçeklendirilir.

Bitmap(Int32, Int32, Graphics)

Belirtilen boyuta ve belirtilen nesnenin Bitmap çözünürlüğüne sahip sınıfın yeni bir örneğini Graphics başlatır.

Bitmap(Int32, Int32, PixelFormat)

Belirtilen boyut ve biçime sahip sınıfın Bitmap yeni bir örneğini başlatır.

Bitmap(Int32, Int32, Int32, PixelFormat, IntPtr)

Belirtilen boyut, piksel biçimi ve piksel verileriyle sınıfının yeni bir örneğini Bitmap başlatır.

Bitmap(Image)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen mevcut görüntüden sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(System::Drawing::Image ^ original);
public Bitmap (System.Drawing.Image original);
new System.Drawing.Bitmap : System.Drawing.Image -> System.Drawing.Bitmap
Public Sub New (original As Image)

Parametreler

original
Image

Yeni ImageBitmapöğesinin oluşturulacağı .

Şunlara uygulanır

Bitmap(Stream)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen veri akışından sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(System::IO::Stream ^ stream);
public Bitmap (System.IO.Stream stream);
new System.Drawing.Bitmap : System.IO.Stream -> System.Drawing.Bitmap
Public Sub New (stream As Stream)

Parametreler

stream
Stream

Görüntüyü yüklemek için kullanılan veri akışı.

Özel durumlar

stream görüntü verileri içermez veya şeklindedir null.

-veya-

stream 65.535 pikselden büyük tek boyutlu bir PNG resim dosyası içerir.

Örnekler

Aşağıdaki kod örneği bir akıştan bit eşlem yüklemeyi gösterir.

Bu örnek, Windows Forms ile kullanılmak üzere tasarlanmıştır. adlı PictureBox1bir form PictureBox oluşturun. Kodu forma yapıştırın ve formun InitializeStreamBitmap oluşturucusundan veya Load olay işleme yönteminden yöntemini çağırın.

void InitializeStreamBitmap()
{
   try
   {
      System::Net::WebRequest^ request = System::Net::WebRequest::Create( "http://www.microsoft.com//h/en-us/r/ms_masthead_ltr.gif" );
      System::Net::WebResponse^ response = request->GetResponse();
      System::IO::Stream^ responseStream = response->GetResponseStream();
      Bitmap^ bitmap2 = gcnew Bitmap( responseStream );
      PictureBox1->Image = bitmap2;
   }
   catch ( System::Net::WebException^ ) 
   {
      MessageBox::Show( "There was an error opening the image file."
      "Check the URL" );
   }

}
private void InitializeStreamBitmap()
{
    try
    {
        System.Net.WebRequest request = 
            System.Net.WebRequest.Create(
            "http://www.microsoft.com//h/en-us/r/ms_masthead_ltr.gif");
        System.Net.WebResponse response = request.GetResponse();
        System.IO.Stream responseStream = 
            response.GetResponseStream();
        Bitmap bitmap2 = new Bitmap(responseStream);
        PictureBox1.Image = bitmap2;
    }
    catch(System.Net.WebException)
    {
        MessageBox.Show("There was an error opening the image file."
           + "Check the URL");
    }
}
Private Sub InitializeStreamBitmap()
    Try
        Dim request As System.Net.WebRequest = _
            System.Net.WebRequest.Create( _
            "http://www.microsoft.com//h/en-us/r/ms_masthead_ltr.gif")
        Dim response As System.Net.WebResponse = request.GetResponse()
        Dim responseStream As System.IO.Stream = response.GetResponseStream()
        Dim bitmap2 As New Bitmap(responseStream)
        PictureBox1.Image = bitmap2

    Catch ex As System.Net.WebException
        MessageBox.Show("There was an error opening the image file. Check the URL")
    End Try
End Sub

Açıklamalar

Akışın kullanım ömrü Bitmapboyunca açık tutmanız gerekir.

GDI+ kod çözücüsünün bir sınırlaması nedeniyle, System.ArgumentException 65.535 pikselden büyük tek bir boyuta sahip bir .png görüntü dosyasından bit eşlem oluşturursanız bir oluşturulur.

Ayrıca bkz.

Şunlara uygulanır

Bitmap(String)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen dosyadan sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(System::String ^ filename);
public Bitmap (string filename);
new System.Drawing.Bitmap : string -> System.Drawing.Bitmap
Public Sub New (filename As String)

Parametreler

filename
String

Bit eşlem dosyası adı ve yolu.

Özel durumlar

Belirtilen dosya bulunamadı.

Açıklamalar

Dosya adı ve yolu uygulamaya göre veya mutlak bir yol olabilir. Şu dosya biçimlerine sahip görüntüleri açmak için bu oluşturucuyu kullanın: BMP, GIF, EXIF, JPG, PNG ve TIFF. Desteklenen biçimler hakkında daha fazla bilgi için bkz . Bit Eşlem Türleri. dosya atılana Bitmap kadar kilitli kalır.

Ayrıca bkz.

Şunlara uygulanır

Bitmap(Image, Size)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen mevcut görüntüden sınıfın Bitmap yeni bir örneğini başlatır ve belirtilen boyuta ölçeklendirilir.

public:
 Bitmap(System::Drawing::Image ^ original, System::Drawing::Size newSize);
public Bitmap (System.Drawing.Image original, System.Drawing.Size newSize);
new System.Drawing.Bitmap : System.Drawing.Image * System.Drawing.Size -> System.Drawing.Bitmap
Public Sub New (original As Image, newSize As Size)

Parametreler

original
Image

Yeni ImageBitmapöğesinin oluşturulacağı .

newSize
Size

Yeni SizeBitmapöğesinin boyutunu temsil eden yapı.

Özel durumlar

İşlem başarısız oldu.

Şunlara uygulanır

Bitmap(Int32, Int32)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen boyuta sahip sınıfın Bitmap yeni bir örneğini başlatır.

public:
 Bitmap(int width, int height);
public Bitmap (int width, int height);
new System.Drawing.Bitmap : int * int -> System.Drawing.Bitmap
Public Sub New (width As Integer, height As Integer)

Parametreler

width
Int32

Yeni Bitmapöğesinin piksel cinsinden genişliği.

height
Int32

Yeni Bitmapöğesinin piksel cinsinden yüksekliği.

Özel durumlar

İşlem başarısız oldu.

Açıklamalar

Bu oluşturucu, numaralandırma değeri Format32bppArgbile bir PixelFormatBitmap oluşturur.

Şunlara uygulanır

Bitmap(Stream, Boolean)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen veri akışından sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(System::IO::Stream ^ stream, bool useIcm);
public Bitmap (System.IO.Stream stream, bool useIcm);
new System.Drawing.Bitmap : System.IO.Stream * bool -> System.Drawing.Bitmap
Public Sub New (stream As Stream, useIcm As Boolean)

Parametreler

stream
Stream

Görüntüyü yüklemek için kullanılan veri akışı.

useIcm
Boolean

true bunun Bitmapiçin renk düzeltmesi kullanmak; aksi takdirde , false.

Özel durumlar

stream görüntü verileri içermez veya şeklindedir null.

-veya-

stream 65.535 pikselden büyük tek boyutlu bir PNG resim dosyası içerir.

Açıklamalar

Akışın kullanım ömrü Bitmapboyunca açık tutmanız gerekir.

GDI+ kod çözücüsünün bir sınırlaması nedeniyle, System.ArgumentException 65.535 pikselden büyük tek bir boyuta sahip bir .png görüntü dosyasından bit eşlem oluşturursanız bir oluşturulur.

Ayrıca bkz.

Şunlara uygulanır

Bitmap(String, Boolean)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen dosyadan sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(System::String ^ filename, bool useIcm);
public Bitmap (string filename, bool useIcm);
new System.Drawing.Bitmap : string * bool -> System.Drawing.Bitmap
Public Sub New (filename As String, useIcm As Boolean)

Parametreler

filename
String

Bit eşlem dosyasının adı.

useIcm
Boolean

true bunun Bitmapiçin renk düzeltmesi kullanmak; aksi takdirde , false.

Örnekler

Aşağıdaki kod örneği, bir dosyadan yeni bir bit eşlem oluşturmayı gösterir. Örnek, görüntüyü yeniden renklendirmek için ve SetPixel yöntemlerini kullanırGetPixel. Ayrıca özelliğini kullanır PixelFormat .

Bu örnek, sırasıyla , PictureBox ve Button adlı Label1PictureBox1Button1ve içeren bir LabelWindows Formu ile kullanılmak üzere tasarlanmıştır. Kodu forma yapıştırın ve yöntemini düğmenin Click olayıyla ilişkilendirinButton1_Click.

private:
   Bitmap^ image1;
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      try
      {
         
         // Retrieve the image.
         image1 = gcnew Bitmap( "C:\\Documents and Settings\\All Users\\"
         "Documents\\My Music\\music.bmp",true );
         int x;
         int y;
         
         // Loop through the images pixels to reset color.
         for ( x = 0; x < image1->Width; x++ )
         {
            for ( y = 0; y < image1->Height; y++ )
            {
               Color pixelColor = image1->GetPixel( x, y );
               Color newColor = Color::FromArgb( pixelColor.R, 0, 0 );
               image1->SetPixel( x, y, newColor );

            }

         }
         
         // Set the PictureBox to display the image.
         PictureBox1->Image = image1;
         
         // Display the pixel format in Label1.
         Label1->Text = String::Format( "Pixel format: {0}", image1->PixelFormat );
      }
      catch ( ArgumentException^ ) 
      {
         MessageBox::Show( "There was an error."
         "Check the path to the image file." );
      }

   }
Bitmap image1;

private void Button1_Click(System.Object sender, System.EventArgs e)
{

    try
    {
        // Retrieve the image.
        image1 = new Bitmap(@"C:\Documents and Settings\All Users\" 
            + @"Documents\My Music\music.bmp", true);

        int x, y;

        // Loop through the images pixels to reset color.
        for(x=0; x<image1.Width; x++)
        {
            for(y=0; y<image1.Height; y++)
            {
                Color pixelColor = image1.GetPixel(x, y);
                Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
                image1.SetPixel(x, y, newColor);
            }
        }

        // Set the PictureBox to display the image.
        PictureBox1.Image = image1;

        // Display the pixel format in Label1.
        Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();
    }
    catch(ArgumentException)
    {
        MessageBox.Show("There was an error." +
            "Check the path to the image file.");
    }
}
Dim image1 As Bitmap

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    Try
        ' Retrieve the image.
        image1 = New Bitmap( _
            "C:\Documents and Settings\All Users\Documents\My Music\music.bmp", _
            True)

        Dim x, y As Integer

        ' Loop through the images pixels to reset color.
        For x = 0 To image1.Width - 1
            For y = 0 To image1.Height - 1
                Dim pixelColor As Color = image1.GetPixel(x, y)
                Dim newColor As Color = _
                    Color.FromArgb(pixelColor.R, 0, 0)
                image1.SetPixel(x, y, newColor)
            Next
        Next

        ' Set the PictureBox to display the image.
        PictureBox1.Image = image1

        ' Display the pixel format in Label1.
        Label1.Text = "Pixel format: " + image1.PixelFormat.ToString()

    Catch ex As ArgumentException
        MessageBox.Show("There was an error." _
            & "Check the path to the image file.")
    End Try
End Sub

Açıklamalar

Şu dosya biçimlerine sahip görüntüleri açmak için bu oluşturucuyu kullanın: BMP, GIF, EXIF, JPG, PNG ve TIFF. Desteklenen biçimler hakkında daha fazla bilgi için bkz . Bit Eşlem Türleri. dosya atılana Bitmap kadar kilitli kalır.

Ayrıca bkz.

Şunlara uygulanır

Bitmap(Type, String)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen kaynaktan sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(Type ^ type, System::String ^ resource);
public Bitmap (Type type, string resource);
new System.Drawing.Bitmap : Type * string -> System.Drawing.Bitmap
Public Sub New (type As Type, resource As String)

Parametreler

type
Type

Kaynağı ayıklamak için kullanılan sınıf.

resource
String

Kaynağın adı.

Örnekler

Aşağıdaki kod örneği, bir türden bit eşlem oluşturmayı ve yöntemini kullanmayı Save gösterir. Bu örneği çalıştırmak için kodu bir Windows Formuna yapıştırın. Formun Paint olayını işleyip yöntemini çağırın ConstructFromResourceSaveAsGife ve olarak geçirin PaintEventArgs

private:
    void ConstructFromResourceSaveAsGif(PaintEventArgs^ e)
    {
        // Construct a bitmap from the button image resource.
        Bitmap^ bmp1 = gcnew Bitmap(Button::typeid, "Button.bmp");
        String^ savePath =  
            Environment::GetEnvironmentVariable("TEMP") + "\\Button.bmp";

        try
        {
            // Save the image as a GIF.
            bmp1->Save(savePath, System::Drawing::Imaging::ImageFormat::Gif);
        }
        catch (IOException^)
        {
            // Carry on regardless
        }

        // Construct a new image from the GIF file.
        Bitmap^ bmp2 = nullptr;
        if (File::Exists(savePath))
        {
            bmp2 = gcnew Bitmap(savePath);
        }

        // Draw the two images.
        e->Graphics->DrawImage(bmp1, Point(10, 10));

        // If bmp1 did not save to disk, bmp2 may be null
        if (bmp2 != nullptr)
        {
            e->Graphics->DrawImage(bmp2, Point(10, 40));
        }

        // Dispose of the image files.
        delete bmp1;
        if (bmp2 != nullptr)
        {
            delete bmp2;
        }
    }
private void ConstructFromResourceSaveAsGif(PaintEventArgs e)
{

    // Construct a bitmap from the button image resource.
    Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");

    // Save the image as a GIF.
    bmp1.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Gif);

    // Construct a new image from the GIF file.
    Bitmap bmp2 = new Bitmap("c:\\button.gif");

    // Draw the two images.
    e.Graphics.DrawImage(bmp1, new Point(10, 10));
    e.Graphics.DrawImage(bmp2, new Point(10, 40));

    // Dispose of the image files.
    bmp1.Dispose();
    bmp2.Dispose();
}
Private Sub ConstructFromResourceSaveAsGif(ByVal e As PaintEventArgs)

    ' Construct a bitmap from the button image resource.
    Dim bmp1 As New Bitmap(GetType(Button), "Button.bmp")

    ' Save the image as a GIF.
    bmp1.Save("c:\button.gif", System.Drawing.Imaging.ImageFormat.Gif)

    ' Construct a new image from the GIF file.
    Dim bmp2 As New Bitmap("c:\button.gif")

    ' Draw the two images.
    e.Graphics.DrawImage(bmp1, New Point(10, 10))
    e.Graphics.DrawImage(bmp2, New Point(10, 40))

    ' Dispose of the image files.
    bmp1.Dispose()
    bmp2.Dispose()
End Sub

Açıklamalar

Bu oluşturucu, verilen türün ad alanını kaynağın dize adıyla birleştirir ve derleme bildiriminde eşleşme arar. Örneğin, türünü ve Button.bmp bu oluşturucuya geçirebilirsiniz Button ve adlı System.Windows.Forms.Button.bmpbir kaynak arar.

Ayrıca bkz.

Şunlara uygulanır

Bitmap(Image, Int32, Int32)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen mevcut görüntüden sınıfın Bitmap yeni bir örneğini başlatır ve belirtilen boyuta ölçeklendirilir.

public:
 Bitmap(System::Drawing::Image ^ original, int width, int height);
public Bitmap (System.Drawing.Image original, int width, int height);
new System.Drawing.Bitmap : System.Drawing.Image * int * int -> System.Drawing.Bitmap
Public Sub New (original As Image, width As Integer, height As Integer)

Parametreler

original
Image

Yeni ImageBitmapöğesinin oluşturulacağı .

width
Int32

Yeni Bitmapöğesinin piksel cinsinden genişliği.

height
Int32

Yeni Bitmapöğesinin piksel cinsinden yüksekliği.

Özel durumlar

İşlem başarısız oldu.

Şunlara uygulanır

Bitmap(Int32, Int32, Graphics)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen boyuta ve belirtilen nesnenin Bitmap çözünürlüğüne sahip sınıfın yeni bir örneğini Graphics başlatır.

public:
 Bitmap(int width, int height, System::Drawing::Graphics ^ g);
public Bitmap (int width, int height, System.Drawing.Graphics g);
new System.Drawing.Bitmap : int * int * System.Drawing.Graphics -> System.Drawing.Bitmap
Public Sub New (width As Integer, height As Integer, g As Graphics)

Parametreler

width
Int32

Yeni Bitmapöğesinin piksel cinsinden genişliği.

height
Int32

Yeni Bitmapöğesinin piksel cinsinden yüksekliği.

g
Graphics

Yeni GraphicsBitmapiçin çözünürlüğü belirten nesne.

Özel durumlar

g, null değeridir.

Açıklamalar

Bu yöntemin oluşturduğu yeniBitmap, sırasıyla ve özelliklerinden gyatay ve DpiY dikey çözünürlüğünü DpiX alır.

Şunlara uygulanır

Bitmap(Int32, Int32, PixelFormat)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen boyut ve biçime sahip sınıfın Bitmap yeni bir örneğini başlatır.

public:
 Bitmap(int width, int height, System::Drawing::Imaging::PixelFormat format);
public Bitmap (int width, int height, System.Drawing.Imaging.PixelFormat format);
new System.Drawing.Bitmap : int * int * System.Drawing.Imaging.PixelFormat -> System.Drawing.Bitmap
Public Sub New (width As Integer, height As Integer, format As PixelFormat)

Parametreler

width
Int32

Yeni Bitmapöğesinin piksel cinsinden genişliği.

height
Int32

Yeni Bitmapöğesinin piksel cinsinden yüksekliği.

format
PixelFormat

Yeni Bitmapiçin piksel biçimi. Bu, ile Formatbaşlayan bir değer belirtmelidir.

Özel durumlar

PixelFormat Adı Biçim ile başlamayan bir değer belirtilir. Örneğin, belirtilmesi Gdi bir ArgumentExceptionneden olur, ancak Format48bppRgb neden olmaz.

Şunlara uygulanır

Bitmap(Int32, Int32, Int32, PixelFormat, IntPtr)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen boyut, piksel biçimi ve piksel verileriyle sınıfının yeni bir örneğini Bitmap başlatır.

public:
 Bitmap(int width, int height, int stride, System::Drawing::Imaging::PixelFormat format, IntPtr scan0);
public Bitmap (int width, int height, int stride, System.Drawing.Imaging.PixelFormat format, IntPtr scan0);
new System.Drawing.Bitmap : int * int * int * System.Drawing.Imaging.PixelFormat * nativeint -> System.Drawing.Bitmap
Public Sub New (width As Integer, height As Integer, stride As Integer, format As PixelFormat, scan0 As IntPtr)

Parametreler

width
Int32

Yeni Bitmapöğesinin piksel cinsinden genişliği.

height
Int32

Yeni Bitmapöğesinin piksel cinsinden yüksekliği.

stride
Int32

Bir tarama çizgisinin başlangıcı ile sonraki arasındaki bayt uzaklığını belirten tamsayı. Bu genellikle piksel biçimindeki bayt sayısıdır (örneğin, piksel başına 16 bit için 2), bit eşlem genişliğiyle çarpılır. Bu parametreye geçirilen değer dörtte bir kat olmalıdır.

format
PixelFormat

Yeni Bitmapiçin piksel biçimi. Bu, ile Formatbaşlayan bir değer belirtmelidir.

scan0
IntPtr

nativeint

Piksel verilerini içeren bir bayt dizisinin işaretçisi.

Özel durumlar

PixelFormat Adı Biçim ile başlamayan bir değer belirtilir. Örneğin, belirtilmesi Gdi bir ArgumentExceptionneden olur, ancak Format48bppRgb neden olmaz.

Örnekler

Aşağıdaki kod örneğinde oluşturucunun nasıl kullanılacağı gösterilmektedir Bitmap(Int32, Int32, Int32, PixelFormat, IntPtr) . Bu örnek, Windows Forms ile kullanılacak şekilde tasarlanmıştır ve olayın parametresi olan bir parametre Paint gerektirirPaintEventArgs.

private void BitmapConstructorEx(PaintEventArgs e)
{

    // Create a bitmap.
    Bitmap bmp = new Bitmap("c:\\fakePhoto.jpg");
    
   // Retrieve the bitmap data from the bitmap.
    System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), 
        ImageLockMode.ReadOnly, bmp.PixelFormat);

    //Create a new bitmap.
    Bitmap newBitmap = new Bitmap(200, 200, bmpData.Stride, bmp.PixelFormat, bmpData.Scan0);

    bmp.UnlockBits(bmpData);

    // Draw the new bitmap.
    e.Graphics.DrawImage(newBitmap, 10, 10);
}
Private Sub BitmapConstructorEx(ByVal e As PaintEventArgs)

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

    ' Retrieve the bitmap data from the bitmap.
    Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), _
        ImageLockMode.ReadOnly, bmp.PixelFormat)

    'Create a new bitmap.
    Dim newBitmap As New Bitmap(200, 200, bmpData.Stride, bmp.PixelFormat, bmpData.Scan0)

    bmp.UnlockBits(bmpData)

    ' Draw the new bitmap.
    e.Graphics.DrawImage(newBitmap, 10, 10)

End Sub

Açıklamalar

Çağıran, parametresi tarafından belirtilen bellek bloğunu ayırmaktan ve boşaltmaktan scan0 sorumludur. Ancak, bellek ilgili Bitmap serbest bırakılana kadar serbest bırakılmamalıdır.

Şunlara uygulanır