Stretch Method

Applies to TestComplete 15.63, last modified on April 23, 2024

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

function 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");
}

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

Sub Test1
  ' 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

procedure Test1;
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

function 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");
}

See Also

Picture.Size

Highlight search results