Forums

Welcome Guest Search | Active Topics | Members

Resize + Crop Options
undead80
Posted: Sunday, February 24, 2008 4:15:47 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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
?dblresRatio
0.83361111111111108


A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in Aurigma.GraphicsMill.dll
Argument '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.

undead80
Posted: Sunday, February 24, 2008 9:27:29 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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.
Dmitry
Posted: Wednesday, February 27, 2008 3:24:31 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 500
Points: 330
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.

Sincerely yours,
Dmitry Sevostjanov.
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.