tags:

views:

266

answers:

2

Drawing a parallelgram is nicely supported with Graphics.DrawImage:

Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height);
using (Graphics gr = new Graphics.FromImage(destImage))
{
    Point[] destPts = new Point[] { new PointF(x1, y1), 
        new PointF(x2, y2), new PointF(x4, y4)};
    gr.DrawImage(srcImage, destPts);

How, do you do 4 points (obviously the following is not supported, but this is what is wanted):

Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height);
using (Graphics gr = new Graphics.FromImage(destImage))
{
    Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2),
        new PointF(x3, y3), new PointF(x4, y4)};
    gr.DrawImage(srcImage, destPts);
}
+1  A: 

Normally you would do this with a 3x3 Matrix, but the Matrix class only lets you specify 6 values instead of 9. You might be able to do this in Direct X.

Adam Tegen
A: 

Closest I can find is [http://vckicks.110mb.com/image-distortion.html][1] which is extremely laggy :(

It is also, unfortunately, not perspective correct
Neil N