Welcome Guest Search | Active Topics | Members

skew an image Options
pxg
Posted: Thursday, March 23, 2006 11:35:05 AM
Rank: Member
Groups: Member

Joined: 3/23/2006
Posts: 2
Points: 0
is it possible to skew an image either horizontal or vertical from a fixed end point
Dmitry
Posted: Thursday, March 23, 2006 9:32:21 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 587
Points: 591
Hello,

You can implement skew transformation using ApplyMatrixTransform. The basic idea is to specify corners of source image as source points and corner points of skewed image as destination points of transformation. Here is a code sample which illustrates this idea:
Code:
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:/1.jpg");

int skew = 100;

System.Drawing.PointF [] srcPoints = new System.Drawing.PointF[3];
System.Drawing.PointF [] destPoints = new System.Drawing.PointF[3];

srcPoints[0].X = 0;
srcPoints[0].Y = 0;
srcPoints[1].X = bitmap.Width - 1;
srcPoints[1].Y = 0;
srcPoints[2].X = 0;
srcPoints[2].Y = bitmap.Height - 1;

destPoints[0].X = srcPoints[0].X + skew;
destPoints[0].Y = srcPoints[0].Y = 0;
destPoints[1].X = srcPoints[1].X + skew;
destPoints[1].Y = srcPoints[1].Y;
destPoints[2].X = srcPoints[2].X;
destPoints[2].Y = srcPoints[2].Y;

Aurigma.GraphicsMill.Transforms.ApplyMatrixTransform transform = new Aurigma.GraphicsMill.Transforms.ApplyMatrixTransform();
Aurigma.GraphicsMill.Transforms.Matrix matrix = Aurigma.GraphicsMill.Transforms.Matrix.FromAffinePoints(srcPoints, destPoints);

transform.Transform = matrix;
transform.ApplyTransform(bitmap);

bitmap.Save(@"c:/1.png");


Sincerely yours,
Dmitry Sevostyanov.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.