Bitmap.Clone Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Tworzy kopię sekcji zdefiniowanej Bitmap za pomocą określonego PixelFormatelementu .
Przeciążenia
| Nazwa | Opis |
|---|---|
| Clone(RectangleF, PixelFormat) |
Tworzy kopię sekcji zdefiniowanej Bitmap za pomocą określonego PixelFormat wyliczenia. |
| Clone(Rectangle, PixelFormat) |
Tworzy kopię sekcji zdefiniowanej Bitmap przez Rectangle strukturę i z określonym PixelFormat wyliczeniem. |
Clone(RectangleF, PixelFormat)
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
Tworzy kopię sekcji zdefiniowanej Bitmap za pomocą określonego PixelFormat wyliczenia.
public:
System::Drawing::Bitmap ^ Clone(System::Drawing::RectangleF rect, System::Drawing::Imaging::PixelFormat format);
public System.Drawing.Bitmap Clone(System.Drawing.RectangleF rect, System.Drawing.Imaging.PixelFormat format);
override this.Clone : System.Drawing.RectangleF * System.Drawing.Imaging.PixelFormat -> System.Drawing.Bitmap
Public Function Clone (rect As RectangleF, format As PixelFormat) As Bitmap
Parametry
- rect
- RectangleF
Definiuje część tego Bitmap elementu do skopiowania.
- format
- PixelFormat
Określa PixelFormat wyliczenie dla miejsca docelowego Bitmap.
Zwraca
Ta Bitmap metoda tworzy.
Wyjątki
rect znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość rect to 0.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:
Tworzy obiekt Bitmap na podstawie pliku.
Klonuje część tego Bitmapobiektu .
Rysuje sklonowaną część na ekranie.
private:
void Clone_Example2( PaintEventArgs^ e )
{
// Create a Bitmap object from a file.
Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" );
// Clone a portion of the Bitmap object.
RectangleF cloneRect = RectangleF(0,0,100,100);
System::Drawing::Imaging::PixelFormat format = myBitmap->PixelFormat;
Bitmap^ cloneBitmap = myBitmap->Clone( cloneRect, format );
// Draw the cloned portion of the Bitmap object.
e->Graphics->DrawImage( cloneBitmap, 0, 0 );
}
private void Clone_Example2(PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Clone a portion of the Bitmap object.
RectangleF cloneRect = new RectangleF(0, 0, 100, 100);
System.Drawing.Imaging.PixelFormat format =
myBitmap.PixelFormat;
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
// Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0);
}
Private Sub Clone_Example2(ByVal e As PaintEventArgs)
' Create a Bitmap object from a file.
Dim myBitmap As New Bitmap("Grapes.jpg")
' Clone a portion of the Bitmap object.
Dim cloneRect As New RectangleF(0, 0, 100, 100)
Dim format As PixelFormat = myBitmap.PixelFormat
Dim cloneBitmap As Bitmap = myBitmap.Clone(cloneRect, format)
' Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0)
End Sub
Dotyczy
Clone(Rectangle, PixelFormat)
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
- Źródło:
- Bitmap.cs
Tworzy kopię sekcji zdefiniowanej Bitmap przez Rectangle strukturę i z określonym PixelFormat wyliczeniem.
public:
System::Drawing::Bitmap ^ Clone(System::Drawing::Rectangle rect, System::Drawing::Imaging::PixelFormat format);
public System.Drawing.Bitmap Clone(System.Drawing.Rectangle rect, System.Drawing.Imaging.PixelFormat format);
override this.Clone : System.Drawing.Rectangle * System.Drawing.Imaging.PixelFormat -> System.Drawing.Bitmap
Public Function Clone (rect As Rectangle, format As PixelFormat) As Bitmap
Parametry
- rect
- Rectangle
Definiuje część tego Bitmap elementu do skopiowania. Współrzędne są względem tego Bitmap.
- format
- PixelFormat
Format pikseli dla nowego Bitmapelementu . Musi to określać wartość rozpoczynającą się od Format.
Zwraca
Nowa Bitmap metoda tworzona przez tę metodę.
Wyjątki
rect znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość rect to 0.
— lub —
Określono PixelFormat wartość, której nazwa nie rozpoczyna się od formatu. Na przykład określenie Gdi spowoduje , ArgumentExceptionale Format48bppRgb nie spowoduje.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:
Tworzy obiekt Bitmap na podstawie pliku.
Klonuje część tego Bitmapobiektu .
Rysuje sklonowaną część na ekranie.
private:
void Clone_Example1( PaintEventArgs^ e )
{
// Create a Bitmap object from a file.
Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" );
// Clone a portion of the Bitmap object.
Rectangle cloneRect = Rectangle(0,0,100,100);
System::Drawing::Imaging::PixelFormat format = myBitmap->PixelFormat;
Bitmap^ cloneBitmap = myBitmap->Clone( cloneRect, format );
// Draw the cloned portion of the Bitmap object.
e->Graphics->DrawImage( cloneBitmap, 0, 0 );
}
private void Clone_Example1(PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Clone a portion of the Bitmap object.
Rectangle cloneRect = new Rectangle(0, 0, 100, 100);
System.Drawing.Imaging.PixelFormat format =
myBitmap.PixelFormat;
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
// Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0);
}
Private Sub Clone_Example1(ByVal e As PaintEventArgs)
' Create a Bitmap object from a file.
Dim myBitmap As New Bitmap("Grapes.jpg")
' Clone a portion of the Bitmap object.
Dim cloneRect As New Rectangle(0, 0, 100, 100)
Dim format As PixelFormat = myBitmap.PixelFormat
Dim cloneBitmap As Bitmap = myBitmap.Clone(cloneRect, format)
' Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0)
End Sub