Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Code: _ResizeTransform = New Aurigma.GraphicsMill.Transforms.Resize(CSng(_bitmap.Width * dblresRatio), CSng(_bitmap.Height * dblresRatio), Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality)
AddHandler _ResizeTransform.Stopped, AddressOf _ResizeTransform_Stopped
_ResizeTransform.Priority = Threading.ThreadPriority.BelowNormal
_ResizeTransform.SynchronizationMode = Aurigma.GraphicsMill.SynchronizationMode.Sync
_ResizeTransform.CropEnabled = True
_ResizeTransform.CropRectangle = cropRectangle
_ResizeTransform.ApplyTransform(_bitmap)
?cropRectangle {X = 0 Y = 0 Width = 2592 Height = 1944} Bottom: 1944 Empty: {X = 0 Y = 0 Width = 0 Height = 0} Height: 1944 IsEmpty: False Left: 0 Location: {X = 0 Y = 0} Right: 2592 Size: {Width = 2592 Height = 1944} Top: 0 Width: 2592 X: 0 Y: 0 ?_bitmap.Width 2592 ?_bitmap.Height 1944 ?dblresRatio0.83361111111111108 A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in Aurigma.GraphicsMill.dllArgument 'CropRectangle' is out of range (Coordinates of all points of crop rect must be inside source image.). Hi, I am having code as above, during debug time, I try to double check on the value, but seems like everything are okay. The only possibility will be the image size will be smaller after the resize, thus the cropRectangle will not be within the image. But, from the help, seems like the system will run the crop before the resize (or, it will only resize the "cropped" area. Please advice.
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Hi, Found the solution. Seems like i need to * dblresRatio to the CropRectangle as well. The Rectangle Suppose to be within the size after resize and not before resize.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
Hello, Crop and resize works not the way you described. It does crop and resize at the same time, it allows to avoid edge effects. The crop rectangle should be defined in coordinates of resized image. Let's consider the following example: Code:
using (Aurigma.GraphicsMill.Bitmap bmp =
new Aurigma.GraphicsMill.Bitmap(
100,
100,
Aurigma.GraphicsMill.PixelFormat.Format24bppRgb))
{
Aurigma.GraphicsMill.Transforms.Resize resize = new
Aurigma.GraphicsMill.Transforms.Resize();
resize.Width = 75;
resize.Height = 75;
resize.CropRectangle = new System.Drawing.Rectangle(0, 0, 50, 50);
resize.CropEnabled = true;
resize.ApplyTransform(bmp);
bmp.Save("c:/temp/1.jpg");
}
So we have the original image 100x100, when we resize it, it is 75x75 and then we crop the rectangle (0, 0, 50, 50). The destination image will be 50x50. |
|
|
|
|
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.