GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / ResizeWidthRatio Method
GdPicture image identifier.
The new image width in pixel.
A member of the Drawing2D.InterPolationMode enumeration.
Example





In This Topic
ResizeWidthRatio Method (GdPictureImaging)
In This Topic
Resizes a GdPicture image with custom width keeping the original aspect ratio for the new height value.
Syntax
'Declaration
 
Public Function ResizeWidthRatio( _
   ByVal ImageID As Integer, _
   ByVal NewImageWidth As Integer, _
   ByVal InterpolationMode As InterpolationMode _
) As GdPictureStatus
public GdPictureStatus ResizeWidthRatio( 
   int ImageID,
   int NewImageWidth,
   InterpolationMode InterpolationMode
)
public function ResizeWidthRatio( 
    ImageID: Integer;
    NewImageWidth: Integer;
    InterpolationMode: InterpolationMode
): GdPictureStatus; 
public function ResizeWidthRatio( 
   ImageID : int,
   NewImageWidth : int,
   InterpolationMode : InterpolationMode
) : GdPictureStatus;
public: GdPictureStatus ResizeWidthRatio( 
   int ImageID,
   int NewImageWidth,
   InterpolationMode InterpolationMode
) 
public:
GdPictureStatus ResizeWidthRatio( 
   int ImageID,
   int NewImageWidth,
   InterpolationMode InterpolationMode
) 

Parameters

ImageID
GdPicture image identifier.
NewImageWidth
The new image width in pixel.
InterpolationMode
A member of the Drawing2D.InterPolationMode enumeration.

Return Value

A member of the GdPictureStatus enumeration.
Remarks
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio. If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
Example
Resizing the image making it twice the original size.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
 
    // Resize the image making its width twice larger. The height of the image will be changed in order to maintain the aspect ratio.
    int width = gdpictureImaging.GetWidth(imageID);
    gdpictureImaging.ResizeWidthRatio(imageID, width * 2, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
 
    gdpictureImaging.SaveAsPNG(imageID, "output.png");
 
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also