Bitmap.Clone Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vytvoří kopii oddílu tohoto Bitmap definovaného se zadaným PixelFormatobjektem .
Přetížení
| Name | Description |
|---|---|
| Clone(RectangleF, PixelFormat) |
Vytvoří kopii oddílu tohoto Bitmap definovaného se zadaným PixelFormat výčtem. |
| Clone(Rectangle, PixelFormat) |
Vytvoří kopii oddílu definovaného Bitmap strukturou Rectangle a se zadaným PixelFormat výčtem. |
Clone(RectangleF, PixelFormat)
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
Vytvoří kopii oddílu tohoto Bitmap definovaného se zadaným PixelFormat výčtem.
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
Definuje část této Bitmap části, která se má zkopírovat.
- format
- PixelFormat
Určuje PixelFormat výčet cíle Bitmap.
Návraty
Tato Bitmap metoda vytvoří.
Výjimky
rect je mimo hranice zdrojového rastrového obrázku.
Výška nebo šířka rect je 0.
Příklady
Následující příklad kódu je určený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny události Paint. Kód provede následující akce:
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
Platí pro
Clone(Rectangle, PixelFormat)
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
- Zdroj:
- Bitmap.cs
Vytvoří kopii oddílu definovaného Bitmap strukturou Rectangle a se zadaným PixelFormat výčtem.
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
Definuje část této Bitmap části, která se má zkopírovat. Souřadnice jsou vzhledem k tomuto Bitmap.
- format
- PixelFormat
Formát pixelu pro nový Bitmap. To musí zadat hodnotu, která začíná Formatna .
Návraty
Nová Bitmap , kterou tato metoda vytvoří.
Výjimky
rect je mimo hranice zdrojového rastrového obrázku.
Výška nebo šířka rect je 0.
nebo
Je PixelFormat zadána hodnota, jejíž název nezačíná formátem. Například zadání Gdi způsobí ArgumentException, ale Format48bppRgb nebude.
Příklady
Následující příklad kódu je určený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny události Paint. Kód provede následující akce:
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