Description
The Picture.Stretch
method lets you resize the given picture to the size specified by the Width and Height parameters. The picture is stretched according to the mode that is set by the UseHalftones parameter.
Declaration
PictureObj.Stretch(Width, Height, UseHalftones)
PictureObj | An expression, variable or parameter that specifies a reference to a Picture object | |||
Width | [in] | Required | Integer | |
Height | [in] | Required | Integer | |
UseHalftones | [in] | Optional | Boolean | Default value: False |
Result | None |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
Width
New image width.
Height
New image height.
UseHalftones
The default value is False. If it is True, the method will transform source pixels into blocks of pixels in the destination picture, at that the average color of the destination block will approximate the color of source pixels. If this parameter is False, the method will delete all eliminated lines of pixels.
Result Value
None.
Example
The following example demonstrates how you can resize an image and save it to a file:
JavaScript, JScript
{
// Creates a new empty Picture object
Pict = Utils.Picture;
// Loads the image from a file and posts it to the log
Pict.LoadFromFile("D:\\Images\\img.png");
Log.Picture(Pict);
// Resizes the image and saves it to a new file
Pict.Stretch(8, 8);
Log.Picture(Pict);
Pict.SaveToFile("D:\\Images\\new_img.png");
}
Python
def Test1():
# Creates a new empty Picture object
Pict = Utils.Picture
# Loads the image from a file and posts it to the log
Pict.LoadFromFile("D:\\Images\\img.png")
Log.Picture(Pict)
# Resizes the image and saves it to a new file
Pict.Stretch(8, 8)
Log.Picture(Pict)
Pict.SaveToFile("D:\\Images\\new_img.png")
VBScript
' Creates a new empty Picture object
Set Pict = Utils.Picture
' Loads the image from a file and posts it to the log
Call Pict.LoadFromFile("D:\Images\img.png")
Log.Picture(Pict)
' Resizes the image and saves it to a new file
Call Pict.Stretch(8, 8)
Log.Picture(Pict)
Call Pict.SaveToFile("D:\Images\new_img.png")
End Sub
DelphiScript
begin
// Creates a new empty Picture object
Pict := Utils.Picture;
// Loads the image from a file and posts it to the log
Pict.LoadFromFile('D:\Images\img.png');
Log.Picture(Pict);
// Resizes the image and saves it to a new file
Pict.Stretch(8, 8);
Log.Picture(Pict);
Pict.SaveToFile('D:\Images\new_img.png');
end;
C++Script, C#Script
{
// Creates a new empty Picture object
Pict = Utils["Picture"];
// Loads the image from a file and posts it to the log
Pict["LoadFromFile"]("D:\\Images\\img.png");
Log["Picture"](Pict);
// Resizes the image and saves it to a new file
Pict["Stretch"](8, 8);
Log["Picture"](Pict);
Pict["SaveToFile"]("D:\\Images\\new_img.png");
}