This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, August 23, 2007 1:59:00 AM(UTC)
Groups: Registered
Posts: 49
Hi,
Just check the below code snippet in that first i resize the image then pass that resized image to PerspectiveCommand and then pass that image to CombineWarp but at Run method of combinewarp i will get error invalid parameter passed but if i do this without resizing image it works fine then what is the problem with resize i am not getting.Please reply soon.
RasterImage tempRaster = new RasterImage(Image.FromFile(@"C:\Aditi K (x27)\Images\Icecreme\ATT632523.jpg"));
SizeCommand cmdSize = new SizeCommand();
cmdSize.Width = 400;
cmdSize.Height = 200;
cmdSize.Flags = RasterSizeFlags.Resample;
ColorResolutionCommand col = new ColorResolutionCommand();
cmdSize.Run(tempRaster);
Leadtools.ImageProcessing.SpecialEffects.PerspectiveCommand cmd1 = new Leadtools.ImageProcessing.SpecialEffects.PerspectiveCommand();
System.Drawing.Point[] pt = new System.Drawing.Point[4];
pt[0].X = 10;
pt[0].Y = 10;
pt[1].X = tempRaster.Width - 10;//_viewerAfter.Image.Width - 10;
pt[1].Y = 10;
pt[2].X = 10;
pt[2].Y = tempRaster.Height - 30;
pt[3].X = tempRaster.Width - 10;
pt[3].Y = tempRaster.Height - 30;
cmd1.CornerPoints = pt;
cmd1.Type = PerspectiveCommandType.Color;
cmd1.FillColor = new Leadtools.RasterColor(Color.LightGray);
cmd1.Run(tempRaster);
col.BitsPerPixel = 24;
IRasterCommand command = null;
CombineWarpCommand cmd = new CombineWarpCommand();
Point[] pts = new Point[]
{
new Point(120,80),
new Point(265,6),
new Point(350,160),
new Point(195,236)
};
cmd.SetDestinationPoints(pts);
cmd.SourceRectangle = new Rectangle(0, 0, rasterImageViewer1.Image.Width, rasterImageViewer1.Image.Height);
cmd.Flags = CombineWarpCommandFlags.Reserved1;
cmd.DestinationImage = rasterImageViewer1.Image;
col.Run(rasterImageViewer1.Image);
col.Run(tempRaster);
command = cmd;
cmd.Run(tempRaster);
rasterImageViewer1.Invalidate();
Thanks
Manju
#2
Posted
:
Friday, August 24, 2007 5:55:35 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
I'm not sure exactly what you are trying to do. If you're just trying to do the CombineWarp of one image onto another, why are you also using the PerspectiveCommand? CombineWarp does the same thing as Perspective except that it puts the source image onto the destination, so it's like you're doing the Perspective twice which makes your logic very complicated. Please explain in more detail what you are trying to do and maybe we can streamline this for you.
As for the error, it's probably due to your SourceRectangle being used in the CombineWarpCommand. You are saying that the source rectangle should be the entire destination image's dimensions. Most likely, your destination image is smaller than the source image originally, but then when you resize the source image, it is now smaller. Therefore the source rectangle is actually larger than the source image. Most likely, you should be doing this:
cmd.SourceRectangle = new Rectangle(0, 0, tempRasterWidth, tempRasterHeight);
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.