Is there any way to draw an image to use 4 points rather than 3 (perspective warp)
Question
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);
}
Solution
Closest I can find is this information, which is extremely laggy.
OTHER TIPS
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.
When thinking of how 3D tools would handle it... try drawing a triangle of one half and then the other triangle for the other half. So if you have points A, B, C, & D; you would draw (with a clipping plane) A, B, C and then B, C, D, or something of the sort.
I found the following article in CodeProject: Free Image Transformation By YLS
needs some works
maybe you can use this :)