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
Clone(RectangleF, PixelFormat) |
Tworzy kopię sekcji zdefiniowanej Bitmap za pomocą określonego PixelFormat wyliczenia. |
Clone(Rectangle, PixelFormat) |
Tworzy kopię sekcji tej Bitmap zdefiniowanej przez Rectangle strukturę i z określoną PixelFormat wyliczeniem. |
Clone(RectangleF, PixelFormat)
- Ź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 wyliczenie PixelFormat dla miejsca docelowego Bitmap.
Zwraca
Ta Bitmap metoda tworzy.
Wyjątki
rect
znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość to rect
0.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse
parametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy obiekt Bitmap na podstawie pliku.
Klonuje część tego obiektu Bitmap.
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
Tworzy kopię sekcji tej Bitmap zdefiniowanej przez Rectangle strukturę i z określoną 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ędne 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 utworzona przez tę metodę.
Wyjątki
rect
znajduje się poza granicami źródłowej mapy bitowej.
Wysokość lub szerokość to rect
0.
-lub-
Określona PixelFormat jest wartość, której nazwa nie rozpoczyna się od formatu. Na przykład określenie Gdi spowoduje ArgumentException, ale Format48bppRgb nie spowoduje.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse
parametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy obiekt Bitmap na podstawie pliku.
Klonuje część tego obiektu Bitmap.
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
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla