ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Drawing functions
  • Displaying a PNG image
  • Transparent image in PNG format
  • Pattern and PHP
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Saves an image:
  • in a PNG file.
  • in memory.
This image corresponds to the image contained in a Image control.
Remarks:
  • Only the visible part of the Image control is saved.
  • The border of the Image control (if it exists) is also saved.
    Reminder: The border of the Image control is defined in the "Style" tab of the description window of control.
  • This function can only be used to save the images for screen resolutions up to 32 bits.
  • This function cannot be used with the Image controls found in the reports.
WEBDEV - Browser code In browser code, this function can only be used to save an image in memory.
Linux Caution: A specific configuration is required to use this function in Linux. For more details, see The drawings.
Example
// Saves the image found in "IMG_ImageDrawing" in "C:\Documents\Image.PNG"
ResSave = IMG_ImageDrawing.SavePNG("C:\Documents\Image.PNG")
// Saves in memory the image found in "IMG_ImageDrawing"
ResSave = IMG_ImageDrawing.SavePNG(inMemory)
Syntax
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppAndroidiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)PHPAjax

Saving an image in a PNG file Hide the details

<Result> = <Image control>.SavePNG(<File name> [, <Transparency color>])
<Result>: Boolean
  • True if the image was saved,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Image control>: Control name
  • Name of the Image, Bar Code or Web Camera control to be saved. Image controls in a report cannot be used.
  • WEBDEV - Server codeWINDEV Mobile Name of the Image or Web Camera control to be used.
  • AndroidJava Name of the Image control to be used.
<File name>: Character string
Name and full (or relative) path of PNG file. A UNC path can be used. The file extension is optional.
Caution:
  • The destination directory must exist in order for the image to be saved.
  • The existence of the PNG file is not checked. This file is automatically overwritten if it already exists.
<Transparency color>: Optional integer
Color that will be considered as being transparent in the image. This color can correspond to:If this parameter is not specified, the generated image is not transparent.
Universal Windows 10 App Syntax not available

Saving an image in memory Hide the details

<Result> = <Image control>.SavePNG(<inMemory> [, <Transparency color>])
<Result>: Buffer
Byte string containing the image in PNG format.
Then, this byte string can be assigned to an Image control, saved in a file (fSaveText), sent via a network (with the Socket functions), ...
WEBDEV - Browser code In browser code, this byte string can only be assigned to another image ("Localize the image in the _WEB directory in browser code" must be unchecked). It cannot be saved in a file to build an image file.
<Image control>: Control name
  • Name of the Image, Bar Code or Web Camera control to be saved. Image controls in a report cannot be used.
  • WEBDEV - Server codeWINDEV Mobile Name of the Image or Web Camera control to be used.
  • AndroidJava Name of the Image control to be used.
<inMemory>: Constant
inMemory: Constant used to save an image in memory.
<Transparency color>: Optional integer
Color that will be considered as being transparent in the image. This color can correspond to:If this parameter is not specified, the generated image is not transparent.
Android This parameter is ignored.
Remarks

Displaying a PNG image

Caution: If the image in PNG format is semi-transparent, the display of the image is slower.

Transparent image in PNG format

To save a transparent image in PNG format, the Image control must be filled with the transparent color beforehand.
Example used to draw a transparent line and to save it in PNG format:
IMG_Image1.StartDrawing(dWithOpacity)
IMG_Image1.ChangeMode(drawDefault)
FOR nI = 0 _TO_ IMG_Image1..Width
FOR nJ = 0 _TO_ IMG_Image1..Height
 IMG_Image1.DrawPoint(nI, nJ, RGB(255,255,255), 0)
END
END
IMG_Image1.Pen(RGB(100, 020, 200), 0,10, 100)
IMG_Image1.DrawLine(10, 10, 100, 10)
IMG_Image1.SavePNG(CompleteDir(fExeDir()) + "img.png")
PHP

Pattern and PHP

In PHP, the drawing functions are based on the graphic library GD. This library is commonly used by the PHP hosting providers and therefore it is always enabled. The version of the GD library must be version 2.0.28 (or later). This library can be downloaded from the PHP site.
To enable (if necessary) this library locally, the following elements are required:
  • PHP installed.
  • the PHP.INI file found in the Windows directory must contain the following line: "extension=php_gd2.dll" (instead of ";extension=php_gd2.dll").
  • the php_gd2.dll file must exist in the directory of PHP extensions. This directory is defined in the PHP.INI file by the "extension_dir" variable.
Component: wd290pnt.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 01/15/2024

Send a report | Local help