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 tego Bitmap zdefiniowanej przy użyciu określonego PixelFormat.
Przeciążenia
| Clone(RectangleF, PixelFormat) |
Tworzy kopię sekcji tego Bitmap zdefiniowanej przy użyciu określonego wyliczenia PixelFormat. |
| Clone(Rectangle, PixelFormat) |
Tworzy kopię sekcji tego Bitmap zdefiniowanej przez strukturę Rectangle i z określonym wyliczeniem PixelFormat. |
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
Tworzy kopię sekcji tego Bitmap zdefiniowanej przy użyciu określonego wyliczenia PixelFormat.
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 do skopiowania.
- format
- PixelFormat
Określa wyliczenie PixelFormat dla Bitmapdocelowego .
Zwraca
Bitmap tworzone przez tę metodę.
Wyjątki
rect znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość rect wynosi 0.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:
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
Tworzy kopię sekcji tego Bitmap zdefiniowanej przez strukturę Rectangle i z określonym wyliczeniem PixelFormat.
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
- format
- PixelFormat
Format pikseli dla nowego Bitmap. Musi to określać wartość rozpoczynającą się od Format.
Zwraca
Nowa Bitmap tworzona przez tę metodę.
Wyjątki
rect znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość rect wynosi 0.
-lub-
Określono wartość PixelFormat, której nazwa nie rozpoczyna się od Format. Na przykład określenie Gdi spowoduje ArgumentException, ale Format48bppRgb nie.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:
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