HighTechTalks DotNet Forums  

Re: Shear image

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Re: Shear image in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
n!
 
Posts: n/a

Default Re: Shear image - 02-06-2007 , 05:54 AM






Quote:
When you use the Shear method, the 2 corners of the image are moved
together
and the image becomes a parallelogram. But how to shear the image by
moving
only a corner of the image? Or is there another method which do the job?
You can create a TextureBrush from your image, then build a polygon of the
shape you desire and use FillPolygon.

for example:

protected override void OnPaint( PaintEventArgs e )
{
Image image = image.FromFile( "myImage.jpg" );
TextureBrush textureBrush = new TextureBrush( image );

Point[] points = new Point[ 4 ];

// Code assumes an image of 256x256 pixels...
points[ 0 ] = new Point( 32, 32 );
points[ 1 ] = new Point( 32 + 256 + 256, 32 ); // Move this one
corner
points[ 2 ] = new Point( 32 + 256, 32 + 256 );
points[ 3 ] = new Point( 32, 32 + 256 );

e.Graphics.FillPolygon( textureBrush, points );

base.OnPaint( e );
}

I'm assuming that's what you want, and I know this code would be incredibly
slow ;o Just an example.

n!




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.