Nasıl yapılır: Görüntüleri Döndürme, Yansıtma ve Eğme

Özgün görüntünün sol üst, sağ üst ve sol alt köşeleri için hedef noktaları belirterek görüntüyü döndürebilir, yansıtabilirsiniz ve çarpıtabilirsiniz. Üç hedef nokta, özgün dikdörtgen görüntüyü paralel bir grafikle eş alan bir affine dönüşümü belirler.

Örnek

Örneğin, özgün görüntünün (0, 0), sağ üst köşede (100, 0) ve (0, 50) sol alt köşesi olan bir dikdörtgen olduğunu varsayalım. Şimdi bu üç noktayla hedef noktaları aşağıdaki gibi eşleyebilirsiniz.

Özgün nokta Hedef nokta
Sol üst (0, 0) (200, 20)
Sağ üst (100, 0) (110, 100)
Sol alt (0, 50) (250, 30)

Aşağıdaki çizimde özgün görüntü ve parallelogram ile eşlenmiş görüntü gösterilmiştir. Özgün görüntü çarpıtıldı, yansıtıldı, döndürülmüş ve çevrildi. Özgün görüntünün üst kenarı boyunca x ekseni (200, 20) ve (110, 100) boyunca çalışan çizgiyle eşlenmiş. Özgün görüntünün sol kenarı boyunca y ekseni ( 200, 20) ve (250, 30) boyunca çalışan çizgiyle eşlenmiş.

The original image and the image mapped to the parallelogram.

Aşağıdaki çizimde, bir fotoğraf görüntüsüne uygulanan benzer bir dönüşüm gösterilmiştir:

The picture of a climber and the picture mapped to the parallelogram.

Aşağıdaki çizimde bir meta dosyaya uygulanan benzer bir dönüşüm gösterilmiştir:

Illustration of shapes and text and that mapped to the parallelogram.

Aşağıdaki örnek, ilk çizimde gösterilen görüntüleri üretir.

    Point[] destinationPoints = {
new Point(200, 20),   // destination for upper-left point of
                      // original
new Point(110, 100),  // destination for upper-right point of
                      // original
new Point(250, 30)};  // destination for lower-left point of
    // original

    Image image = new Bitmap("Stripes.bmp");

    // Draw the image unaltered with its upper-left corner at (0, 0).
    e.Graphics.DrawImage(image, 0, 0);

    // Draw the image mapped to the parallelogram.
    e.Graphics.DrawImage(image, destinationPoints);
' New Point(200, 20)  = destination for upper-left point of original
' New Point(110, 100) = destination for upper-right point of original
' New Point(250, 30)  = destination for lower-left point of original
Dim destinationPoints As Point() = { _
    New Point(200, 20), _
    New Point(110, 100), _
    New Point(250, 30)}

Dim image As New Bitmap("Stripes.bmp")

' Draw the image unaltered with its upper-left corner at (0, 0).
e.Graphics.DrawImage(image, 0, 0)

' Draw the image mapped to the parallelogram.
e.Graphics.DrawImage(image, destinationPoints)

Kod Derleniyor

Yukarıdaki örnek, Windows Forms ile kullanım için tasarlanmıştır ve olay PaintEventArgse işleyicinin bir parametresi Paint olan 'i gerektirir. yerine sisteminiz Stripes.bmp üzerinde geçerli olan bir görüntünün yolunu değiştir'i seçin.

Ayrıca bkz.