Bagikan melalui


ImageAttributes.SetRemapTable Metode

Definisi

Mengatur tabel color-remap.

Overload

SetRemapTable(ColorMap[])

Mengatur tabel color-remap untuk kategori default.

SetRemapTable(ReadOnlySpan<ColorMap>)
SetRemapTable(ReadOnlySpan<ValueTuple<Color,Color>>)
SetRemapTable(ColorAdjustType, ReadOnlySpan<ColorMap>)
SetRemapTable(ColorAdjustType, ReadOnlySpan<ValueTuple<Color,Color>>)
SetRemapTable(ColorMap[], ColorAdjustType)

Mengatur tabel color-remap untuk kategori tertentu.

SetRemapTable(ColorMap[])

Sumber:
ImageAttributes.cs
Sumber:
ImageAttributes.cs
Sumber:
ImageAttributes.cs

Mengatur tabel color-remap untuk kategori default.

public:
 void SetRemapTable(cli::array <System::Drawing::Imaging::ColorMap ^> ^ map);
public:
 void SetRemapTable(... cli::array <System::Drawing::Imaging::ColorMap ^> ^ map);
public void SetRemapTable (System.Drawing.Imaging.ColorMap[] map);
public void SetRemapTable (params System.Drawing.Imaging.ColorMap[] map);
member this.SetRemapTable : System.Drawing.Imaging.ColorMap[] -> unit
Public Sub SetRemapTable (map As ColorMap())
Public Sub SetRemapTable (ParamArray map As ColorMap())

Parameter

map
ColorMap[]

Array pasangan warna jenis ColorMap. Setiap pasangan warna berisi warna yang ada (nilai pertama) dan warna yang akan dipetakan ke (nilai kedua).

Contoh

Contoh kode berikut dirancang untuk digunakan dengan Formulir Windows, dan memerlukan PaintEventArgse, yang merupakan parameter penanganan Paint aktivitas. Kode melakukan tindakan berikut:

  1. Membuat gambar (lingkaran merah), menyimpannya sebagai Circle2.jpg, membuka gambar tersebut, dan menggambarnya ke layar.

  2. Membuat peta warna yang memetakan warna merah ke warna hijau.

  3. Menggambar gambar yang dibuat sebelumnya ke layar lagi, tetapi kali ini menggunakan peta warna.

private:
   void SetRemapTableExample( PaintEventArgs^ e )
   {
      // Create a filled, red image, and save it to Circle2.jpg.
      Bitmap^ myBitmap = gcnew Bitmap( 50,50 );
      Graphics^ g = Graphics::FromImage( myBitmap );
      g->Clear( Color::White );
      g->FillEllipse( gcnew SolidBrush( Color::Red ), Rectangle(0,0,50,50) );
      myBitmap->Save( "Circle2.jpg" );

      // Create an Image object from the Circle2.jpg file, and draw it to
      // the screen.
      Image^ myImage = Image::FromFile( "Circle2.jpg" );
      e->Graphics->DrawImage( myImage, 20, 20 );

      // Create a color map.
      array<ColorMap^>^myColorMap = gcnew array<ColorMap^>(1);
      myColorMap[ 0 ] = gcnew ColorMap;
      myColorMap[ 0 ]->OldColor = Color::Red;
      myColorMap[ 0 ]->NewColor = Color::Green;

      // Create an ImageAttributes object, and then pass the
      // myColorMap object to the SetRemapTable method.
      ImageAttributes^ imageAttr = gcnew ImageAttributes;
      imageAttr->SetRemapTable( myColorMap );

      // Draw the image with the remap table set.
      Rectangle rect = Rectangle(150,20,50,50);
      e->Graphics->DrawImage( myImage, rect, 0, 0, 50, 50, GraphicsUnit::Pixel, imageAttr );
   }
private void SetRemapTableExample(PaintEventArgs e)
{
             
    // Create a filled, red image, and save it to Circle2.jpg.
    Bitmap myBitmap = new Bitmap(50, 50);
    Graphics g = Graphics.FromImage(myBitmap);
    g.Clear(Color.White);
    g.FillEllipse(new SolidBrush(Color.Red),
        new Rectangle(0, 0, 50, 50));
    myBitmap.Save("Circle2.jpg");
             
    // Create an Image object from the Circle2.jpg file, and draw it to
             
    // the screen.
    Image myImage = Image.FromFile("Circle2.jpg");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Create a color map.
    ColorMap[] myColorMap = new ColorMap[1];
    myColorMap[0] = new ColorMap();
    myColorMap[0].OldColor = Color.Red;
    myColorMap[0].NewColor = Color.Green;
             
    // Create an ImageAttributes object, and then pass the
   // myColorMap object to the SetRemapTable method.
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetRemapTable(myColorMap);
             
    // Draw the image with the remap table set.
    Rectangle rect = new Rectangle(150, 20, 50, 50);
    e.Graphics.DrawImage(myImage, rect, 0, 0, 50, 50, 
        GraphicsUnit.Pixel, imageAttr);    
}
Public Sub SetRemapTableExample(ByVal e As PaintEventArgs)

    ' Create a filled, red image and save it to Circle2.jpg.
    Dim myBitmap As New Bitmap(50, 50)
    Dim g As Graphics = Graphics.FromImage(myBitmap)
    g.Clear(Color.White)
    g.FillEllipse(New SolidBrush(Color.Red), New Rectangle(0, 0, _
    50, 50))
    myBitmap.Save("Circle2.jpg")

    ' Create an Image object from the Circle2.jpg file, and draw

    ' it to the screen.
    Dim myImage As Image = Image.FromFile("Circle2.jpg")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Create a color map.
    Dim myColorMap(0) As ColorMap
    myColorMap(0) = New ColorMap
    myColorMap(0).OldColor = Color.Red
    myColorMap(0).NewColor = Color.Green

    ' Create an ImageAttributes object, and then pass the

    ' myColorMap object to the SetRemapTable method.
    Dim imageAttr As New ImageAttributes
    imageAttr.SetRemapTable(myColorMap)

    ' Draw the image with the remap table set.
    Dim rect As New Rectangle(150, 20, 50, 50)
    e.Graphics.DrawImage(myImage, rect, 0, 0, 50, 50, _
    GraphicsUnit.Pixel, imageAttr)
    ' Image
End Sub

Keterangan

Tabel remap warna adalah array ColorMap struktur. Setiap ColorMap struktur memiliki dua Color objek: satu yang menentukan warna lama dan satu yang menentukan warna baru yang sesuai. Selama penyajian, warna apa pun yang cocok dengan salah satu warna lama dalam tabel remap diubah ke warna baru yang sesuai.

Objek ImageAttributes mempertahankan pengaturan warna dan skala abu-abu untuk lima kategori penyesuaian: default, bitmap, kuas, pena, dan teks. Misalnya, Anda dapat menentukan remap warna untuk kategori default, tabel color-remap untuk kategori bitmap, dan masih tabel remap warna yang berbeda untuk kategori pena.

Pengaturan penyesuaian warna default dan penyesuaian skala abu-abu berlaku untuk semua kategori yang tidak memiliki pengaturan penyesuaian sendiri. Misalnya, jika Anda tidak pernah menentukan pengaturan penyesuaian apa pun untuk kategori pena, pengaturan default berlaku untuk kategori pena.

Berlaku untuk

SetRemapTable(ReadOnlySpan<ColorMap>)

Sumber:
ImageAttributes.cs
public:
 void SetRemapTable(ReadOnlySpan<System::Drawing::Imaging::ColorMap ^> map);
public void SetRemapTable (ReadOnlySpan<System.Drawing.Imaging.ColorMap> map);
member this.SetRemapTable : ReadOnlySpan<System.Drawing.Imaging.ColorMap> -> unit
Public Sub SetRemapTable (map As ReadOnlySpan(Of ColorMap))

Parameter

Berlaku untuk

SetRemapTable(ReadOnlySpan<ValueTuple<Color,Color>>)

Sumber:
ImageAttributes.cs
public:
 void SetRemapTable(ReadOnlySpan<ValueTuple<System::Drawing::Color, System::Drawing::Color>> map);
public void SetRemapTable (ReadOnlySpan<(System.Drawing.Color OldColor, System.Drawing.Color NewColor)> map);
member this.SetRemapTable : ReadOnlySpan<ValueTuple<System.Drawing.Color, System.Drawing.Color>> -> unit
Public Sub SetRemapTable (map As ReadOnlySpan(Of ValueTuple(Of Color, Color)))

Parameter

Berlaku untuk

SetRemapTable(ColorAdjustType, ReadOnlySpan<ColorMap>)

Sumber:
ImageAttributes.cs
public:
 void SetRemapTable(System::Drawing::Imaging::ColorAdjustType type, ReadOnlySpan<System::Drawing::Imaging::ColorMap ^> map);
public void SetRemapTable (System.Drawing.Imaging.ColorAdjustType type, ReadOnlySpan<System.Drawing.Imaging.ColorMap> map);
member this.SetRemapTable : System.Drawing.Imaging.ColorAdjustType * ReadOnlySpan<System.Drawing.Imaging.ColorMap> -> unit
Public Sub SetRemapTable (type As ColorAdjustType, map As ReadOnlySpan(Of ColorMap))

Parameter

Berlaku untuk

SetRemapTable(ColorAdjustType, ReadOnlySpan<ValueTuple<Color,Color>>)

Sumber:
ImageAttributes.cs
public:
 void SetRemapTable(System::Drawing::Imaging::ColorAdjustType type, ReadOnlySpan<ValueTuple<System::Drawing::Color, System::Drawing::Color>> map);
public void SetRemapTable (System.Drawing.Imaging.ColorAdjustType type, ReadOnlySpan<(System.Drawing.Color OldColor, System.Drawing.Color NewColor)> map);
member this.SetRemapTable : System.Drawing.Imaging.ColorAdjustType * ReadOnlySpan<ValueTuple<System.Drawing.Color, System.Drawing.Color>> -> unit
Public Sub SetRemapTable (type As ColorAdjustType, map As ReadOnlySpan(Of ValueTuple(Of Color, Color)))

Parameter

Berlaku untuk

SetRemapTable(ColorMap[], ColorAdjustType)

Sumber:
ImageAttributes.cs
Sumber:
ImageAttributes.cs
Sumber:
ImageAttributes.cs

Mengatur tabel color-remap untuk kategori tertentu.

public:
 void SetRemapTable(cli::array <System::Drawing::Imaging::ColorMap ^> ^ map, System::Drawing::Imaging::ColorAdjustType type);
public void SetRemapTable (System.Drawing.Imaging.ColorMap[] map, System.Drawing.Imaging.ColorAdjustType type);
member this.SetRemapTable : System.Drawing.Imaging.ColorMap[] * System.Drawing.Imaging.ColorAdjustType -> unit
Public Sub SetRemapTable (map As ColorMap(), type As ColorAdjustType)

Parameter

map
ColorMap[]

Array pasangan warna jenis ColorMap. Setiap pasangan warna berisi warna yang ada (nilai pertama) dan warna yang akan dipetakan ke (nilai kedua).

type
ColorAdjustType

Elemen yang ColorAdjustType menentukan kategori di mana tabel color-remap diatur.

Contoh

Untuk contoh kode, lihat SetRemapTable(ColorMap[]) metode .

Keterangan

Tabel remap warna adalah array ColorMap struktur. Setiap ColorMap struktur memiliki dua Color objek: satu yang menentukan warna lama dan satu yang menentukan warna baru yang sesuai. Selama penyajian, warna apa pun yang cocok dengan salah satu warna lama dalam tabel remap diubah ke warna baru yang sesuai.

Objek ImageAttributes mempertahankan pengaturan warna dan skala abu-abu untuk lima kategori penyesuaian: default, bitmap, kuas, pena, dan teks. Misalnya, Anda dapat menentukan remap warna untuk kategori default, tabel color-remap untuk kategori bitmap, dan masih tabel remap warna yang berbeda untuk kategori pena.

Pengaturan penyesuaian warna default dan penyesuaian skala abu-abu berlaku untuk semua kategori yang tidak memiliki pengaturan penyesuaian sendiri. Misalnya, jika Anda tidak pernah menentukan pengaturan penyesuaian apa pun untuk kategori pena, pengaturan default berlaku untuk kategori pena.

Segera setelah Anda menentukan pengaturan penyesuaian warna atau penyesuaian skala abu-abu untuk kategori tertentu, pengaturan penyesuaian default tidak lagi berlaku untuk kategori tersebut. Misalnya, Anda menentukan kumpulan pengaturan penyesuaian untuk kategori default. Jika Anda mengatur tabel color-remap untuk kategori pena dengan meneruskan Pen ke SetRemapTable metode , tidak ada pengaturan penyesuaian default yang akan berlaku untuk pena.

Berlaku untuk