- Special cases
- Drawing with management of opacity
- dStartDrawing, zoom and automatic scrollbars
In french: dDébutDessin
// Start drawing in the "IMG_ImageDrawing" control
ResDrawing = dStartDrawing(IMG_ImageDrawing)
// Drawings performed in the "IMG_ImageDrawing" control
// End of drawing in the "IMG_ImageDrawing" control
dFont("Arial", 12, iNormal, 0)
dText(4, 0, "I am writing my text in an Image control!")
Starting a drawing in an Image control Hide the details
<Result> = dStartDrawing(<Image control> [, <Options>])
<Result>: System integer
- Memory DC (device context) of the Image control,
- 0 if an error occurs. This parameter can be used to call system routines (functions of Windows API). In this case, we recommend that you use a system integer.
- 1 if successful,
- 0 if an error occurs.
<Image control>: Control name
Name of Image control where the drawing will be performed.
<Options>: Optional Integer constant (or combination of constants)
Versions 17 and later New in version 17
- dStartDrawing must be called before the other drawing functions. dStartDrawing is used to define the element (Image control or Image variable) onto which the drawing functions will be applied.
- When drawing in an Image control:
- the drawing functions operate on a copy ("bitmap") of image. You can use the drawing functions of Windows (via API or CallDLL32) but these Windows functions must use the DC (Device Context) returned by dStartDrawing.
- dEndDrawing and dStartDrawing must not be called in the same process. The drawing will not be displayed if dEndDrawing and dStartDrawing are called in the same process: it will be automatically erased.
Drawing with management of opacity
Creating a drawing with management of opacity is used to easily save the images in PNG format with management of Alpha layer.
To save a PNG drawing with management of Alpha layer:
- Use the function dStartDrawing. This function is used to define, if necessary, the element onto which the drawing functions will be applied as well as the drawing mode. The dWithOpacity constant is used to indicate that the drawing will manage the opacity. The dGridlinesOpacity constant is used to display gridlines underneath the different drawing areas.
- Configure the opacity of your drawings with the following functions:
|dBackground||Declares the background color and its opacity for the next drawings.|
|dPoint||Declares the color of the points and their opacity for the next drawings.|
|dPen||Declares the color of the lines and their opacity for the next drawings.|
Remark: dPixelOpacity is used to find out the opacity of a point.
- Use dSaveImagePNG to save your drawing in PNG format with management of alpha layer (opacity).
: In "Management of opacity" mode, dText
is limited to the use of True Type fonts.
dStartDrawing, zoom and automatic scrollbars
The option "Automatic scrollbars and zoom", which is available on Image controls, is not compatible with dStartDrawing
. If this option is used on the Image control, dStartDrawing
freezes the image. The zoom and the scrollbars are also frozen. The standard behavior is restored during the call to dEndDrawing
Unit examples (WINDEV): The drawing functions
This page is also available for…
Click [Add] to post a comment