'+--------------------------------------------------------------------------+
'|                                                                          |
'|                               GDImage.dll                                |
'|             Graphic control compatible GDI, GDIPLUS, OpenGL              |
'|                                                                          |
'|                              Version 5.03                                |
'+--------------------------------------------------------------------------+
'|                                                                          |
'|                         Author Patrice TERRIER                           |
'|                                                                          |
'|                         copyright(c) 2005-2009                           |
'|                                                                          |
'|                Patrice Terrier http://www.zapsolution.com                |
'|                                                                          |
'+--------------------------------------------------------------------------+
'|                  Project started on : 10-16-2005 (MM-DD-YYYY)            |
'|                        Last revised : 05-31-2009 (MM-DD-YYYY)            |
'+--------------------------------------------------------------------------+
'
'****************************************************************************
' CONSTANTS
'
  $GDIPLUSIMG        = ".DIB.EMF.GIF.JPG.JPEG.PNG.TIF.TIFF.WMF."
  $GDIPLUSEXT        = $GDIPLUSIMG + "BMP.ICO."
'
  $zLim              = "|"
  $Anti              = "\"
  $Dot               = "."
  $GDImageClassName  = "ZIMAGECTRL"  ' Class name for GDImage standard control.
  $GLImageClassName  = "ZOPENGLCTRL" ' Class name for OpenGL control.

' Internal GDImage structure being used to store details about each sprite object.
  %METADATA_SIZE   = 2048 '//See it in GDImage.inc
  TYPE ZOBJECT
      hWnd        AS LONG
      objType     AS LONG
      metacount   AS LONG
      metadata    AS STRING * %METADATA_SIZE

      useFont     AS ASCIIZ * 64'128 '//5.03
      extrabyte   AS STRING * 64     '//5.03 Reserved for future extension

      useSize     AS LONG
      fontFam     AS LONG
      curFont     AS LONG
      strFormat   AS LONG
      useARGB     AS LONG
      use3D       AS LONG
      x1          AS LONG ' x top coordinate
      y1          AS LONG ' y top coordinate
      x2          AS LONG ' object width
      y2          AS LONG ' object height
      visible     AS LONG
      order       AS LONG
      locked      AS BYTE

      ID          AS LONG      '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< SIZEOF(ZOBJECT) - 131 + 1
      Style       AS LONG
      Bitmap      AS LONG
      Region      AS LONG
      objLabel    AS STRING * 64
      xCapture    AS INTEGER   ' WORD   '//4.04
      yCapture    AS INTEGER   ' WORD   '//4.04
      opacity     AS BYTE      ' PNG variable opacity
      scale       AS SINGLE    '//2.10
      clone       AS LONG      '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< SIZEOF(ZOBJECT) - 42 + 1
      xP          AS INTEGER   ' WORD   '//4.04 '//2.11
      yP          AS INTEGER   ' WORD   '//4.04 '//2.11
      angle       AS WORD      '//2.11
      quality     AS BYTE      '//2.11
      flipmode    AS BYTE      '//3.00
      userotate   AS BYTE      '//3.00
      selected    AS BYTE      '//3.02
      hidden      AS BYTE      '//3.56

      brightness  AS BYTE      '//4.05
      contrast    AS BYTE      '//4.05
      red         AS BYTE      '//4.05
      green       AS BYTE      '//4.05
      blue        AS BYTE      '//4.05
      hue         AS BYTE      '//4.05

      FrameCount  AS BYTE      '//4.16
      FrameToUse  AS BYTE      '//4.16

      anchor      AS BYTE      '//5.00
      nLeft       AS INTEGER   '//5.00
      nTop        AS INTEGER   '//5.00
      nRight      AS INTEGER   '//5.00
      nBottom     AS INTEGER   '//5.00
      centerx     AS INTEGER   '//5.00
      centery     AS INTEGER   '//5.00

      linked      AS LONG      '//5.03 Link multiple sprite objects together     

      reserved    AS STRING * 2' 19 ' 27' 28 ' 26
  END TYPE ' 2368 bytes
'//   WARNING in case of change into the ZOBJECT structure that would impact its size,
'//   don't forget to update the "zItemFromID" and "zCloneFromID" functions!!!

  TYPE POINTS
      x AS INTEGER
      y AS INTEGER
  END TYPE
'
'****************************************************************************
' Version 1.00
' --------------------
' Load the GDImage.dll
' --------------------
' Must be done in the WinMain section BEFORE USING any of the GDImage function.
' Parameter: None
  DECLARE FUNCTION RegisterGDImageClass LIB "GDIMAGE.DLL" ALIAS "RegisterGDImageClass" () AS LONG
' Return:
' 0 = means failure, any other value means registered.
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Default function to create a GDImage control
' (Alias zCreateImageCtrl)
  DECLARE FUNCTION ZI_CreateWindow LIB "GDIMAGE.DLL" ALIAS "ZI_CreateWindow" ( _
  BYVAL hParent AS LONG, _  ' The Window/Dialog container
  BYVAL x AS LONG, _        ' The control top left corner horizontal location
  BYVAL y AS LONG, _        ' The control top left corner vertical location
  BYVAL xW AS LONG, _       ' The control width
  BYVAL yH AS LONG, _       ' The control height
  BYVAL ControlID AS LONG _ ' The control unique IDentifier
  ) AS LONG
' Return:
' The handle of the newly created control
'
' --------------------------------------
' Alternate methode using CreateWindowEx
' --------------------------------------
' Style   = %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER
' StyleEx = 0
' CALL CreateWindowEx(StyleEx, _
'                    "ZIMAGECTRL", _                 ' window class name
'                    "e:\pictures\image.png<fit>", _ ' Optional FullPathName to picture
'                     Style, _                       ' window style
'                     10, _                          ' initial x position
'                     10, _                          ' initial y position
'                     150, _                         ' Calculate Window Width
'                     150, _                         ' Calculate Window Height
'                     hMain, _                       ' parent window handle
'                     %ID_THUMBCTRL, _               ' ControlID
'                     GetModuleHandle(""), _         ' program instance handle
'                     BYVAL 0)                       ' creation parameters
'
' ---------------------------------------
' Alternate methode using DDT CONTROL ADD
' ---------------------------------------
'  CONTROL ADD "ZIMAGECTRL", _
'              hDlg, _
'              %IDC_CUSTOMCONTROL, _
'              "e:\picture.jpg", _
'              10, 10, 640, 480, _
'              %WS_CHILD OR %WS_VISIBLE OR %WS_HSCROLL OR %WS_VSCROLL, _
'              %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
'
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Display the common file selector dialog using thumbnail preview for the supported graphic format.
' (Alias zImageLoadDialog)
  DECLARE FUNCTION ZI_LoadDialog LIB "GDIMAGE.DLL" ALIAS "ZI_LoadDialog" ( _
  BYVAL hParent AS LONG _              ' The parent window handle.
  ) AS STRING
' Return:
' The FullPathName of the selected picture
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Display the common save to file dialog providing a valid hGDImageCtrl handle
' (Alias zImageSaveDialog)
  DECLARE FUNCTION ZI_SaveDialog LIB "GDIMAGE.DLL" ALIAS "ZI_SaveDialog" ( _
  BYVAL hParent AS LONG, _             ' The parent window handle.
  BYVAL hGDImageCtrl AS LONG _         ' The GDImage control handle.
  ) AS LONG
' Return:
' Successfull ErrCode = 0
' Error       ErrCode
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Save the content of a GDImage control to any of the supported graphic format
' Must be a supported graphic format, see $GDIPLUSEXT.
  DECLARE FUNCTION ZI_SaveToFile LIB "GDIMAGE.DLL" ALIAS "ZI_SaveToFile" ( _
  zFullPathName AS ASCIIZ, _           ' Full path name of the graphic file to save.
  BYVAL hGDImageCtrl AS LONG, _        ' The GDimage control handle.
  OPTIONAL BYVAL JpegQuality AS LONG _ ' Optional JPEG encoding quality 1-100:
  ) AS LONG                            ' Default 0 = QalityMax = 100
' Return:
' Successfull ErrCode = 0
' Error       ErrCode
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Set the image file to use with the control.
' Must be a supported graphic format, see $GDIPLUSEXT.
' (Alias zSetImageFromFile)
  DECLARE SUB ZI_SetFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_SetFromFile" ( _
  BYVAL hGDImageCtrl AS LONG, _  ' The GDimage control handle.
  zFullPathName AS ASCIIZ _      ' Full path name to the graphic file to display
  )
' This function is the same than using :
' CALL SendMessage (hCtrl, %WM_SETTEXT, 0, STRPTR(FullPathName$))
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Set property of a GDImage control
' (Alias zGetProperty)
  DECLARE FUNCTION ZI_GetProperty LIB "GDIMAGE.DLL" ALIAS "ZI_GetProperty" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL nProperty AS LONG _     ' A %ZI_ predefined constant (see the list below)
  ) AS LONG
' Return:
' The matching property value
'
' Get property from a GDImage control
' (Alias zSetProperty)
  DECLARE SUB ZI_SetProperty LIB "GDIMAGE.DLL" ALIAS "ZI_SetProperty" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The control handle.
  BYVAL nProperty AS LONG, _    ' A %ZI_ predefined constant (see the list below)
  BYVAL Parameter AS LONG _     ' A parameter matching the type of property to set.
  )
'
' See below the list of GDImage properties:
' Note: Constants prefixed with %ZI_ are for IMAGE control
  %ZI_DC             = 1  ' Internal DC
  %ZI_Bitmap         = 2  ' Memory Bitmap
  %ZI_Horizontal     = 3  ' Horizontal scrolling position
  %ZI_Vertical       = 4  ' Vertical scrolling position
  %ZI_GradientTop    = 5  ' Top gradiant color backgroud
  %ZI_GradientBottom = 6  ' Bottom gradiant color backgroud

  %ZI_FitToWindow    = 7  ' Resize the image to fit the view port
                          ' And use any of this constant as Parameter
                           %ZI_QualityDefault = -1
                           %ZI_QualityGood    = 1  ' Best performance
                           %ZI_QualityHigh    = 2  ' Best rendering quality
' DO NOT use or alter these properties!
  %ZI_PaintDC        = 8  ' Internal DC
  %ZI_PaintBitmap    = 9  ' Memory Bitmap
  %ZI_Reserved       = 10 ' Animated frame parameters : LOWRD = FrameWidth, HIWRD = FrameCount

  %ZI_ZoomWindow     = 11 ' Version 1.41
  %ZI_ZoomFactor     = 12 ' Version 1.41
  %ZI_Orientation    = 13 ' Version 1.41

  %ZI_FlagByte       = 14 ' Version 2.00 4 bytes reserved for flag
      %TOOL_CROP     = 1          ' Stored in the first byte
      %TOOL_CUTTER   = 2          ' Stored in the first byte
      %TOOL_PENCIL   = 4          ' Stored in the first byte
      %TOOL_FLOOD    = 8          ' Stored in the first byte
      %TOOL_AIRBRUSH = 16         ' Stored in the first byte
      %TOOL_PIPE     = 32         ' Stored in the first byte
      %TOOL_MOUSE    = 64         ' Stored in the first byte
      %TOOL_UNKNOWN  = 128        ' Stored in the first byte

  %Extend_cbWndExtra = %ZI_FlagByte ' %ZI_Orientation ' %ZI_Reserved

  %ZI_GDIPLUSHANDLE  = 1  ' Load GDIPLUS Image handle

  %ZD_MAPCOLORFROM   = &h807F80   ' Maping color for 32-bit alphablending
  %ZI_MAPCOLORFROM   = &hFF807F80 ' Maping color for 32-bit alphablending
  %ZI_MAPCOLORTO     = &hFF808080 ' Maping color for 32-bit alphablending
  %ZI_MAPCOLORNULL   = &h00807F80 ' Maping color for 32-bit alphablending
  %ZI_MAPTRANSCOLOR  = &h807F80   ' Transparent maped color for 32-bit alphablending
'
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Paint the background of a GDImage control
' see property %ZI_GradientTop
' and property %ZI_GradientBottom
' (Alias zGradientPaintDC)
  DECLARE SUB ZI_GradientPaintDC LIB "GDIMAGE.DLL" ALIAS "ZI_GradientPaintDC" ( _
  BYVAL hDC AS LONG, _      ' A Windows DC (do not use ZI_GetDC except if you want to paint over the image)
  BYVAL x AS LONG, _        ' The top left corner horizontal location
  BYVAL y AS LONG, _        ' The top left corner vertical location
  BYVAL xW AS LONG, _       ' The width
  BYVAL yH AS LONG, _       ' The height
  BYVAL TopRGB AS LONG, _   ' The RGB color to use for the top
  BYVAL BottomRGB AS LONG _ ' The RGB color to use for the bottom
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Retrieve bitmap size from a supported GDI+ disk file (do not load the image)
' (Alias zGetImageSize)
  DECLARE SUB ZI_GetImageSizeFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_GetImageSizeFromFile" ( _
  zFullPathName AS ASCIIZ, _      ' The name of the graphic file to detect size
  imgWidth AS LONG, _             ' Width of the picture
  imgHeight AS LONG _             ' Height of the picture
  )
' See: ZI_AdjustWindowRect to adjust the client size of a GDImage control.
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Get the private DC of GDImage control
  DECLARE FUNCTION ZI_GetDC LIB "GDIMAGE.DLL" ALIAS "ZI_GetDC" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' The private DC of the GDImage control
' You can use this DC to draw on the GDImage memory bitmap using standard GDI command.
'
' DO NOT release this DC and AVOID to use DELETEDC on it!
'****************************************************************************
'
'****************************************************************************
' Version 1.04
' Get the GDImage.dll internal version number
' (Alias zGDImageVersion)
  DECLARE FUNCTION ZI_Version LIB "GDIMAGE.DLL" ALIAS "ZI_Version" () AS STRING
' Return:
' The version number of the form "#.#"
'****************************************************************************
'
'****************************************************************************
' Version 1.04
' Copy image to clipboard.
' (Alias zClipboardCopy)
  DECLARE FUNCTION ZI_ClipboardCopy LIB "GDIMAGE.DLL" ALIAS "ZI_ClipboardCopy" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.04
' Paste image from clipboard.
' (Alias zClipboardPaste)
  DECLARE FUNCTION ZI_ClipboardPaste LIB "GDIMAGE.DLL" ALIAS "ZI_ClipboardPaste" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.05
' Compute the client size for a specific GDImage control
' that will match exactly the picture size
  DECLARE SUB ZI_AdjustWindowRect LIB "GDIMAGE.DLL" ALIAS "ZI_AdjustWindowRect" ( _
  BYVAL StyleEx AS LONG, _ ' The CreateWindowEx Extended Style.
  imgW AS LONG, _          ' Width of the image.
  imgH AS LONG, _          ' Height of the image.
  BYVAL Style AS LONG _    ' The CreateWindowEx Style.
  )
' See: ZI_GetImageSizeFromFile to get an image size without loading it.
'****************************************************************************
'
'****************************************************************************
' Version 1.05
' Set the value for the alpha channel of GDImage layered window.
' Note: A layered window MUST use the POPUP style.
  DECLARE FUNCTION ZI_SetLayeredAlpha LIB "GDIMAGE.DLL" ALIAS "ZI_SetLayeredAlpha" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL TransLevel AS BYTE _    ' The translucency level ranging from 0 to 255
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.06
' Create a window using a transparent color to build a region on the fly
' You can use this command with either a POPUP or CHILD window .
  DECLARE FUNCTION ZI_CreateWindowFromImage LIB "GDIMAGE.DLL" ALIAS "ZI_CreateWindowFromImage" ( _
  BYVAL Style AS LONG, _           ' The CreateWindowEx Style.
  zFullImagePath AS ASCIIZ, _      ' The name of an image file.
  BYVAL x AS LONG, _               ' The top left corner horizontal location
  BYVAL y AS LONG, _               ' The top left corner vertical location
  BYVAl hParent AS LONG, _         ' The main window parent handle
  BYVAL UseID AS LONG, _           ' Warning, DO NOT use an ID when using the %WS_POPUP style.
  BYVAL StyleEx AS LONG, _         ' The CreateWindowEx Extended Style.
  BYVAL UseTransColor AS LONG _    ' The transparent color that will be used to create the region.
  ) AS LONG
' Return:
' The new window handle or NULL if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.07
' To retrieve the image size of specific GDimage control
  DECLARE SUB ZI_GetImageSizeFromControl LIB "GDIMAGE.DLL" ALIAS "ZI_GetImageSizeFromControl" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  imgW AS LONG, _               ' Width of the picture.
  imgH AS LONG _                ' Height of the picture.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.07
' To force immediate refresh of a GDImage control display
  DECLARE SUB ZI_UpdateWindow LIB "GDIMAGE.DLL" ALIAS "ZI_UpdateWindow" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL EraseFlag AS LONG _     ' Boolean flag to erase first the background.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.11
' To anchor a GDImage control to a specific location when resizing parent window
' See: ANCHOR.GIF
  DECLARE FUNCTION ZI_SetAnchorMode LIB "GDIMAGE.DLL" ALIAS "ZI_SetAnchorMode" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL AnchorMode AS LONG _    ' The anchor mode (see below)
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'
' Version 1.12
' The function has been enhanced to anchor any type of control:
' button, static, edit, listbox, etc.
'
' ANCHOR Flags:
  %ANCHOR_NONE                = 0
  %ANCHOR_LEFT                = %ANCHOR_NONE
  %ANCHOR_WIDTH               = 1
  %ANCHOR_RIGHT               = 2
  %ANCHOR_CENTER_HORZ         = 3
  %ANCHOR_HEIGHT              = 4
  %ANCHOR_HEIGHT_WIDTH        = 5
  %ANCHOR_HEIGHT_RIGHT        = 6
  %ANCHOR_BOTTOM              = 7
  %ANCHOR_BOTTOM_WIDTH        = 8
  %ANCHOR_BOTTOM_RIGHT        = 9
  %ANCHOR_CENTER_HORZ_BOTTOM  = 10
  %ANCHOR_CENTER_VERT         = 11
  %ANCHOR_CENTER_VERT_RIGHT   = 12
  %ANCHOR_CENTER              = 13
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Convert COLOR to 256 shade of GRAY
  DECLARE FUNCTION ZI_ConvertToGray LIB "GDIMAGE.DLL" ALIAS "ZI_ConvertToGray" ( _
  BYVAL hGDImageDC AS LONG _  ' A GDImage DC (ZI_GetDC) or any DC using an associated memory bitmap
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Replace a RGB color with another RGB color, using a Device Context handle
  DECLARE SUB ZI_ReplaceRGBColor LIB "GDIMAGE.DLL" ALIAS "ZI_ReplaceRGBColor" ( _
  BYVAL hGDImageDC AS LONG, _  ' A GDImage DC (ZI_GetDC) or any DC using an associated memory bitmap
  BYVAL WasRGBColor AS LONG, _ ' The RGB color to replace
  BYVAL NewRGBColor AS LONG _  ' The new RGB color to use
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Compute the number of unique color(s) of an image shown in a GDImage control.
  DECLARE FUNCTION ZI_ColorCount LIB "GDIMAGE.DLL" ALIAS "ZI_ColorCount"( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle
  ) AS LONG
' Return:
' The number of unique color(s) being used in the image.
' Note: Overlay objects are not considered in the computation.
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Print image only, self centered on the paper sheet.
' Print will fit the paper size
  DECLARE FUNCTION ZI_PrintImage LIB "GDIMAGE.DLL" ALIAS "ZI_PrintImage" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Print image + annotation, self centered on the paper sheet.
' Print will fit the paper size
  DECLARE FUNCTION ZI_PrintFull LIB "GDIMAGE.DLL" ALIAS "ZI_PrintFull" ( _
  BYVAL hGDImageCtrl AS LONG _
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.15
' Read image from a provided text buffer (STREAMING)
  DECLARE FUNCTION ZI_LoadImageFromStream LIB "GDIMAGE.DLL" ALIAS "ZI_LoadImageFromStream" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL pBufferData AS BYTE PTR, _     ' Pointer to buffer holding data.
  BYVAL BufferSize AS LONG _           ' Size of the buffer.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' To load any of the supported graphic format as a program resource
' directly to a GDImage control as background.
  DECLARE FUNCTION ZI_LoadFromResource LIB "GDIMAGE.DLL" ALIAS "ZI_LoadFromResource" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  zResourceName AS ASCIIZ _            ' The resource name identifier.
  ) AS LONG
' Return:
' IF the GDImage control handle is omited the returned parameter is a Bitmap handle.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' To GET the Width and Height of a STANDARD BITMAP
  DECLARE SUB ZI_GetBitmapSize LIB "GDIMAGE.DLL" ALIAS "ZI_GetBitmapSize" ( _
  BYVAL hBitmap AS LONG, _   ' Handle to a standard bitmap.
  BitmapWidth AS LONG, _     ' The width of the bitmap.
  BitmapHeight AS LONG _     ' The Height of the bitmap.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Create a valid GDI BITMAP handle from FILE using any of the supported GDImage format.
  DECLARE FUNCTION ZI_CreateBitmapFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_CreateBitmapFromFile" ( _
  zFullImagePath AS ASCIIZ, _      ' The name of an image file.
  BitmapWidth AS LONG, _           ' The width of the bitmap.
  BitmapHeight AS LONG _           ' The Height of the bitmap.
  ) AS LONG
' Return:
' A valid GDI bitmap handle (do not confuse GDI bitmap handle and GDI+ Image handle).
' Important:
' You must use DeleteObject(GDIBitmapHandle) when you do not need it anymore.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' To load the specified bitmap resource from the module's executable file.
' The resource can use any of the supported GDImage graphic format.
' (See RESOURCE.RC example)
  DECLARE FUNCTION ZI_LoadBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_LoadBitmap" ( _
  zResourceName AS ASCIIZ _            ' The resource name identifier.
  ) AS LONG
' Return:
' A valid GDI bitmap handle (do not confuse GDI bitmap handle and GDI+ Image handle).
' Important:
' You must use DeleteObject(GDIBitmapHandle) when you do not need it anymore.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Create a valid GDIPLUS Image handle from FILE using any of the supported GDImage format.
  DECLARE FUNCTION ZI_CreateImageFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_CreateImageFromFile" ( _
  zFullPathName AS ASCIIZ, _           ' Full path name to the graphic file to load.
  imageWidth AS LONG, _                ' The image width.
  imageHeight AS LONG, _               ' The image height.
  BYVAL RemoveARGBColor AS LONG, _     ' Boolean flag use %TRUE to remove ARGBColorToRemove.
  BYVAL ARGBColorToRemove AS LONG _    ' The ARGB color to remove.
  ) AS LONG
' Return:
' A valid GDIPLUS Image handle (do not confuse with a GDI Bitmap handle),
' or NULL if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Create an empty image background (Bitmap) into a GDImage control.
' Use it to perform direct drawing, everything lying out of it (overlay objects) would be clipped.
  DECLARE FUNCTION ZI_CreateImageBackground LIB "GDIMAGE.DLL" ALIAS "ZI_CreateImageBackground" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL BitmapWidth AS LONG, _         ' The width of the bitmap.
  BYVAL BitmapHeight AS LONG _         ' The Height of the bitmap.
  ) AS LONG
' Return:
' A valid GDImage DC (ZI_GetDC) you can use to draw in.
' Note: After drawing into the provided DC, use ZI_UpdateWindow to refresh the display.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Remove a GDIPLUS Image object from memory.
  DECLARE SUB ZI_DeleteImageObject LIB "GDIMAGE.DLL" ALIAS "ZI_DeleteImageObject" ( _
  hImage AS LONG _                     ' A valid GDIPLUS Image handle
  )
' Comment:
' Use it as you would do with DeleteObject for a standard BITAMP handle.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Perform image rotation in the specified DC, using a GDIPLUS Image handle.
  DECLARE SUB ZI_RotateImage LIB "GDIMAGE.DLL" ALIAS "ZI_RotateImage" ( _
  BYVAL hDC AS LONG, _                 ' A valid Device Context
  BYVAL hImage AS LONG, _              ' A valid GDIPLUS Image handle
  BYVAL x AS LONG, _                   ' The X coordinate
  BYVAL y AS LONG, _                   ' The Y coordinate
  BYVAL AngleDegree AS LONG, _         ' The rotation angle in degree to use
  BYVAL UseAlpha AS LONG _             ' The Alpha channel value (use 255 for standard opaque mode)
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Render GDIPLUS Image rotation into a specific GDImage control.
  DECLARE SUB ZI_RenderImageRotationToWindow LIB "GDIMAGE.DLL" ALIAS "ZI_RenderImageRotationToWindow" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL hImage AS LONG, _              ' A valid GDIPLUS Image handle.
  BYVAL x AS LONG, _                   ' The X coordinate.
  BYVAL y AS LONG, _                   ' The Y coordinate.
  BYVAL AngleDegree AS LONG, _         ' The rotation angle in degree to use.
  BYVAL UseAlpha AS LONG _             ' The Alpha channel value (use 255 for standard opaque mode).
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.18
' Use a Bitmap to paint a tiled background in a specific GDImage control.
' Bitmap can provide from file or resource using any of the GDImage supported graphic format.
  DECLARE FUNCTION ZI_SetTiledBackground LIB "GDIMAGE.DLL" ALIAS "ZI_SetTiledBackground" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL UseBitmap AS LONG _
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.18
' Retrieve the Bitmap handle being used to tile a background in a specific GDImage control.
  DECLARE FUNCTION ZI_GetTiledBackground LIB "GDIMAGE.DLL" ALIAS "ZI_GetTiledBackground" ( _
  BYVAL hGDImageCtrl AS LONG _         ' The GDImage control handle.
  ) AS LONG
' Return:
' The background Bitmap handle, or NULL if there is no tiled background.
'****************************************************************************
'
'****************************************************************************
' Version 1.19
' Retrieve a copy of the entire bitmap for the selected GDImageDC,
' using a 2 dimensions array of the form (x,y) pointing directly to pixel.
' You can use the array coordinates as you would do with a standard DC,
' because pixel 0,0 is at coordinate Array(0,0).
' Once your are done with the array, the bitmap is replaced using ZI_SetDIBits.
' (see ZI_SetDIBits)
  DECLARE FUNCTION ZI_GetDIBits LIB "GDIMAGE.DLL" ALIAS "ZI_GetDIBits" ( _
  BYVAL hGDImageDC AS LONG, _              ' Any memory bitmap Device Context (like ZI_GetDC).
  PixelArray() AS LONG _                   ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  ) AS LONG
' Return:
' Null if error, else success.
' Comment:
' Each pixel use ARGB color of the form Alpha, Red, Blue, Green (reading from left to right).
'****************************************************************************
'
'****************************************************************************
' Version 1.19
' Replace a copy of a bitmap that was retrieved as a device-independent bitmap.
' (see ZI_GetDIBits)
  DECLARE FUNCTION ZI_SetDIBits LIB "GDIMAGE.DLL" ALIAS "ZI_SetDIBits" ( _
  BYVAL hGDImageDC AS LONG, _              ' Any memory bitmap Device Context (like ZI_GetDC).
  PixelArray() AS LONG, _                  ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  OPTIONAL BYVAL DoNotClearArray AS LONG _ ' Boolean flag, %TRUE = DO NOT clear the array
  )AS LONG
' Return:
' Null if error, else success.
'****************************************************************************
'
'****************************************************************************
' Version 1.22
' Delete the memory bitmap and device context associated to a GDImage control.
  DECLARE FUNCTION ZI_DeleteControlBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_DeleteControlBitmap" ( _
  BYVAL hGDImageCtrl AS LONG _        ' The GDImage control handle.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Load a graphic file and Resize it on the fly to create a Bitmap matching a specific size.
' Version 1.26
  DECLARE FUNCTION ZI_FitImageFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_FitImageFromFile" ( _
  zFullPathName AS ASCIIZ, _      ' The name of the graphic file.
  BYVAL BoundWidth AS LONG, _     ' The bounding width.
  BYVAL BoundHeight AS LONG _     ' The bounding height.
  ) AS LONG
' Note:
' The image will be stretched to match the bounding size, however keeping the original aspect ratio
' between width and height.
' Return:
' A valid GDI bitmap handle (do not confuse GDI bitmap handle and GDI+ Image handle).
'****************************************************************************
'
'****************************************************************************
' Version 1.36
' To render a GDIPLUS image rotation into a provided bitmap handle.
  DECLARE FUNCTION ZI_RenderRotationFromImageToBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_RenderRotationFromImageToBitmap" ( _
  BYVAL SrceBitmap AS LONG, _  ' A valid GDImage bitmap handle.
  BYVAL Img AS LONG, _         ' A valid GDImage - GDIPLUS handle.
  BYVAL AngleDegree AS LONG, _ ' The angle rotation in degree.
  BYVAL UseAlpha AS LONG _     ' The alpha channel value in the range (0-255).
  ) AS LONG
' Return:
' A new bitmap handle that combines the GDImage Bitmap and the GDIPLUS Image handle together.
'****************************************************************************
'
'****************************************************************************
' Version 1.37
' Display an image using a grayed mask to perform gradient translucency
  DECLARE SUB ZI_DrawAlphaBlend LIB "GDIMAGE.DLL" ALIAS "ZI_DrawAlphaBlend" ( _
  BYVAL hDCDest AS LONG, _    ' A valid Device Context.
  BYVAL x AS LONG, _          ' The X coordinate.
  BYVAL y AS LONG, _          ' The Y coordinate.
  zImage AS ASCIIZ, _         ' Full path name to the graphic file to load.
  zMask AS ASCIIZ _           ' Full path name to the grayed mask graphic file.
  )
'****************************************************************************
'
'****************************************************************************
' Version 2.06 & 4.10
' Save a memory Bitmap to any of the supported graphic format
' Must be a supported graphic format, see $GDIPLUSEXT.
  DECLARE FUNCTION ZI_SaveBitmapToFile LIB "GDIMAGE.DLL" ALIAS "ZI_SaveBitmapToFile" ( _
  zFullPathName AS ASCIIZ, _           ' Full path name of the graphic file to save.
  BYVAL hBitmap AS LONG, _             ' Bitmap handle.
  OPTIONAL BYVAL JpegQuality AS LONG _ ' Optional JPEG encoding quality 1-100:
  ) AS LONG                            ' Default 0 = QalityMax = 100
' Return:
' Successfull ErrCode = 0
' Error       ErrCode
'****************************************************************************
'
'****************************************************************************
'****************************************************************************
'****************************************************************************
'***                                                                      ***
'***                           DRAWING FUNCTIONS                          ***
'***                                                                      ***
'****************************************************************************
'****************************************************************************
'
' CONSTANTS prefixed with %ZD_ apply to DRAWING functions
  %ZD_TRANSCOLOR = &HFF00FF   ' Magenta color that is the default GDImage transparent color
  %ZD_TOPLEFTCOLOR = -1       ' Pixel color at location 0,0
'
' ZD_DrawText constants
  %ZD_TextHorzUp = 0          ' Horizontal text orientation
  %ZD_TextVertUp = 4          ' Vertical text orientation from bottom to top
  %ZD_TextVertDn = 8          ' Vertical text orientation from top to bottom
  %ZD_HIDE       = &H0        ' FALSE
  %ZD_SHOW       = &H1        ' TRUE

' GDImage overlay Generic STYLE must be a 2^
  %ZS_HIDDEN     = %ZD_HIDE
  %ZS_VISIBLE    = %ZD_SHOW   ' VISIBLE, same as %WS_VISIBLE
  %ZS_SCROLL     = &H2        ' MOVE with scroll bars, default is FIX (do not scroll)
  %ZS_DRAFT      = &H4        ' Draft drawing mode

' GDImage Drawing STYLE         For all ZD_Drawxxx functions
  %ZD_DRAW_OUTLINE  = 1
  %ZD_DRAW_FILLED   = 2
  %ZD_DRAW_3DIN     = 3
  %ZD_DRAW_3DOUT    = 4
  %ZD_DRAW_OPEN     = 5
'
  %ZD_DRAW_REDRAW   = -1      ' Forces immediate redraw of parent object
  %ZD_DRAW_DEFERRED = 0       ' Defers redraw of parent object
'
'****************************************************************************
' Version 1.00
' Fills a rectangle using a specific RGB color.
  DECLARE SUB ZD_FillRect LIB "GDIMAGE.DLL" ALIAS "ZD_FillRect" ( _
  BYVAL hGDImageDC AS LONG, _ ' The GDImage DC (ZI_GetDC)
  BYVAL x AS LONG, _          ' The top left horizontal coordinate of the rectangle
  BYVAL y AS LONG, _          ' The top left vertical coordinate of the rectangle
  BYVAL xW AS LONG, _         ' The rectangle width
  BYVAL yH AS LONG, _         ' The rectangle height
  BYVAL RGBcolor AS LONG _    ' The RGB color to use
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.09
' Draw a text using a True Type Font, ARGB color, optional 3D effect and orientation
  DECLARE FUNCTION ZD_DrawTextToDC LIB "GDIMAGE.DLL" ALIAS "ZD_DrawTextToDC" ( _
  BYVAL hGDImageDC AS LONG, _          ' The GDImage DC (ZI_GetDC)
  zUseText AS ASCIIZ, _                ' The text to display
  BYVAL x AS LONG, _                   ' The X seed coordinate
  BYVAL y AS LONG, _                   ' The Y seed coordinate
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use
  zUseFont AS ASCIIZ, _                ' The "Tue Type Font" name to use
  BYVAL UseSize AS LONG, _             ' The size of the font in pixel
  OPTIONAL BYVAL UseShadow AS LONG, _  ' The shadow 3D offset
  OPTIONAL BYVAL Orientation AS LONG _ ' The text orientation (%ZD_TextHorzUp, %ZD_TextVertUp, %ZD_TextVertDn)
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.09
' Compute an ARGB color to ensure compatibility with GDI+
  DECLARE FUNCTION ZD_ColorARGB LIB "GDIMAGE.DLL" ALIAS "ZD_ColorARGB"( _
  BYVAL AlphaChannel AS BYTE, _ ' The translucency level ranging from 0 to 255.
  BYVAL ColrRGB AS DWORD _      ' The classical RGB() color to use.
  ) AS LONG
' Return:
' A 32-bit ARGB color.
'****************************************************************************
'
'****************************************************************************
' Version 1.09
' To retrieve the bounding size in pixel of specifc text using a True Type Font
' of a specific size.
  DECLARE FUNCTION ZD_GetTextBound LIB "GDIMAGE.DLL" ALIAS "ZD_GetTextBound" ( _
  zUseText AS ASCIIZ, _                ' The text to display.
  zUseFont AS ASCIIZ, _                ' The "Tue Type Font" name to use.
  BYVAL UseSize AS LONG, _             ' The size of the font in pixel.
  BYREF BoundingWidth AS LONG, _       ' The bounding width.
  BYREF BoundingHeight AS LONG, _      ' The bounding height.
  OPTIONAL BYVAL Orientation AS LONG _ ' The text orientation (%ZD_TextHorzUp, %ZD_TextVertUp, %ZD_TextVertDn).
  ) AS LONG
' Return:
' The width and height of the bounding rectangle that matches the text being used.
'****************************************************************************
'
'****************************************************************************
' Version 1.09
' Create a TEXT overlay object.
' Each overlay object must have a unique identifier.
' TEXT overlay is independant of the image background that is not altered.
  DECLARE FUNCTION ZD_DrawTextToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawTextToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  zUseText AS ASCIIZ, _                ' The text to display.
  BYVAL x AS LONG, _                   ' Top left X coordinate.
  BYVAL y AS LONG, _                   ' Top left Y coordinate.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  zUseFont AS ASCIIZ, _                ' The "Tue Type Font" name to use.
  BYVAL UseSize AS LONG, _             ' The size of the font in pixel.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  OPTIONAL BYVAL UseShadow AS LONG, _  ' The shadow 3D offset.
  OPTIONAL BYVAL Orientation AS LONG _ ' The text orientation (%ZD_TextHorzUp, %ZD_TextVertUp, %ZD_TextVertDn).
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.16
' To change on the fly the text of a TEXT overlay.
  DECLARE SUB ZD_SetObjectText LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectText" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  zUseText AS ASCIIZ _                 ' The text to display
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Create a RECTANGLE overlay object.
' Each overlay object must have a unique identifier.
' RECTANGLE overlay is independant of the image background that is not altered.
  DECLARE FUNCTION ZD_DrawRectangleToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawRectangleToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL x AS LONG, _                   ' Top left X coordinate.
  BYVAL y AS LONG, _                   ' Top left Y coordinate.
  BYVAL xWidth AS LONG, _              ' Rectangle width.
  BYVAL yHeight AS LONG, _             ' Rectangle height.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL BorderSize AS LONG, _          ' Size of the border (can be NULL).
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  ) AS LONG
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_OUTLINE                       Border only (frame mode)
' %ZD_DRAW_FILLED                        Fill mode
' %ZD_DRAW_3DIN                          Fill with 3D-IN effect
' %ZD_DRAW_3DOUT                         Fill with 3D_Out effect
'
' Return:
' TRUE (-1) if visible, FALSE (0) if not
'****************************************************************************
'
'****************************************************************************
' Create ARROW overlay object.
' Version 1.14
' Each overlay object must have a unique identifier.
  DECLARE FUNCTION ZD_DrawArrowToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawArrowToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL SeedX AS LONG, _               ' Swap SeedX and TargetX to select arrow orientation.
  BYVAL SeedY AS LONG, _               ' Swap SeedY and TargetY to select arrow orientation.
  BYVAL TargetX AS LONG, _             ' Swap TargetX and SeedX to select arrow orientation.
  BYVAL TargetY AS LONG, _             ' Swap TargetY and SeedY to select arrow orientation.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL ArrowSize AS LONG, _           ' Size of the Arrow.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The Drawing mode.
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  ) AS LONG
' To change the arrow orientation, swap Seed and Target coordinates
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_FILLED                        Fill mode ONLY
'
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Create ELLIPSE overlay object.
' Version 1.14
' Each overlay object must have a unique identifier.
  DECLARE FUNCTION ZD_DrawEllipseToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawEllipseToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL TopLeftX AS LONG, _            ' The top X of the rectangular region matching the ellipse size.
  BYVAL TopLeftY AS LONG, _            ' The top Y of the rectangular region matching the ellipse size.
  BYVAL BottomRightX AS LONG, _        ' The bottom X of the rectangular region matching the ellipse size.
  BYVAL BottomRightY AS LONG, _        ' The bottom Y of the rectangular region matching the ellipse size.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL OutlineSize AS LONG, _         ' Size of the outline.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  ) AS LONG
' The ellipse coordinates must match a rectangualr perimeter
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_OUTLINE                       Border only (frame mode)
' %ZD_DRAW_FILLED                        Fill mode
' %ZD_DRAW_3DIN                          Fill with 3D-IN effect
' %ZD_DRAW_3DOUT                         Fill with 3D_Out effect
'
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' Create CURVE overlay object.
' Version 1.14
' Each overlay object must have a unique identifier.
  DECLARE FUNCTION ZD_DrawCurveToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawCurveToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL pXY AS POINTS PTR, _           ' Pointer to an ARRAY of POINTS (holding x,y coordinates of each point).
  BYVAL ArraySize AS LONG, _           ' UBOUND - LBOUND + 1 = number of point in the array.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL CurveSize AS LONG, _           ' Size of the curve.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_OUTLINE                       Border only (frame mode)
' %ZD_DRAW_FILLED                        Fill mode
' %ZD_DRAW_3DIN                          Fill with 3D-IN effect
' %ZD_DRAW_3DOUT                         Fill with 3D_Out effect
' %ZD_DRAW_OPEN                          Do not apply to rectangle
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' Create POLYLINE overlay object.
' Version 1.14
' Each overlay object must have a unique identifier.
  DECLARE FUNCTION ZD_DrawPolyLineToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawPolyLineToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL pXY AS POINTS PTR, _           ' Pointer to an ARRAY of POINTS (holding x,y coordinates of each point).
  BYVAL ArraySize AS LONG, _           ' UBOUND - LBOUND + 1 = number of point in the array.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL CurveSize AS LONG, _           ' Size of the polyline.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_OUTLINE                       Border only (frame mode)
' %ZD_DRAW_FILLED                        Fill mode
' %ZD_DRAW_3DIN                          Fill with 3D-IN effect
' %ZD_DRAW_3DOUT                         Fill with 3D_Out effect
' %ZD_DRAW_OPEN                          Do not apply to rectangle
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Process pending window or dialog messages during animation sequence.
  DECLARE FUNCTION ZD_DoEvents LIB "GDIMAGE.DLL" ALIAS "ZD_DoEvents" () AS LONG
' Return:
' %WM_QUIT if user presses on exit button else %NULL.
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' To show or hide a GDImage overlay object
  DECLARE SUB ZD_ShowObject LIB "GDIMAGE.DLL" ALIAS "ZD_ShowObject" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ShowOrHide AS LONG _           ' %TRUE = SHOW, %FALSE = HIDE.
  )
' Apply to any of the ZD_DrawXXXToCtrl functions.
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Check for visibility of a GDImage overlay object
  DECLARE FUNCTION ZD_IsObjectVisible LIB "GDIMAGE.DLL" ALIAS "ZD_IsObjectVisible" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG
' Return:
' TRUE (-1) if visible, FALSE (0) if not.
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' Get the STYLE of a GDImage overlay object
  DECLARE FUNCTION ZD_GetObjectStyle LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectStyle" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG
' Return:
' The STYLE of the object.
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' Set the STYLE of a GDImage overlay object
  DECLARE SUB ZD_SetObjectStyle LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectStyle" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL UseStyle AS LONG _             ' The new style to use (must be a valid GDImage style).
  )
' See: GDImage overlay Generic STYLE
' Note: Use ZI_UpdateWindow to refresh the display after the style change.
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' To set up the Alpha channel of a specific sprite object
  DECLARE SUB ZD_SetObjectAlpha LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectAlpha" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL Alpha AS BYTE, _               ' The alpha channel (range 0-255, 0 = transparent, 255 = opaque).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' To get the ARGB parameters of a specific sprite object
  DECLARE SUB ZD_GetObjectARGB LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectARGB" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYREF Alpha AS BYTE, _               ' The alpha channel (range 0-255, 0 = transparent, 255 = opaque).
  BYREF Red AS BYTE, _                 ' The RED component (0-255).
  BYREF Green AS BYTE, _               ' The GREEN component (0-255).
  BYREF Blue AS BYTE _                 ' The BLUE component (0-255).
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' To set the ARGB parameters of a specific sprite object
  DECLARE SUB ZD_SetObjectARGB LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectARGB" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL Alpha AS BYTE, _               ' The alpha channel (range 0-255, 0 = transparent, 255 = opaque).
  BYVAL Red AS BYTE, _                 ' The RED component (0-255).
  BYVAL Green AS BYTE, _               ' The GREEN component (0-255).
  BYVAL Blue AS BYTE _                 ' The BLUE component (0-255).
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Retrieve the immediate parent of the overlay object
  DECLARE FUNCTION ZD_GetObjectParent LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectParent" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG
' Return:
' The GDImage control handle of the parent.
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Retrieve the bounding size that best fit the overlay object region
  DECLARE SUB ZD_GetObjectBound LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectBound" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYREF BoundWidth AS LONG, _          ' The bounding with
  BYREF BoundHeight AS LONG _          ' The bounding height
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Retrieve overlay object X, Y coordinates
  DECLARE SUB ZD_GetObjectXY LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectXY" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYREF x AS LONG, _                   ' The X coordinate
  BYREF y AS LONG _                    ' The Y coordinate
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.10
' Set the X,Y coordinates of an overlay object.
  DECLARE SUB ZD_SetObjectXY LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectXY" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYVAL x AS LONG, _                   ' The X coordinate
  BYVAL y AS LONG, _                   ' The Y coordinate
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' To Get the Z-order of an overlay object
  DECLARE FUNCTION ZD_GetObjectZorder LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectZorder" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  ) AS LONG
' Return:
' The overlay object Z-order
'****************************************************************************
'
'****************************************************************************
' Version 1.14
' You can use these constants
  %ZD_ORDER_TOP    = &HFFFFFF          ' Z-order Top
  %ZD_ORDER_BOTTOM = &HFFFF&           ' Z-Order Bottom
' To Set the Z-order of an overlay object
  DECLARE FUNCTION ZD_SetObjectZorder LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectZorder" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYVAL SetOrder AS LONG _             ' The new Z-order of the object
  ) AS LONG
' Return:
' 0 = Error
' ELSE the PREVIOUS z-order of the object.
'****************************************************************************
'
'****************************************************************************
' Version 1.17
' Create a sprite BITMAP (overlay object).
  DECLARE FUNCTION ZD_DrawBitmapToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawBitmapToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL x AS LONG, _                   ' The X coordinate.
  BYVAL y AS LONG, _                   ' The Y coordinate.
  BYVAL hBitmap AS LONG, _
  BYVAL ColrARGB AS LONG, _
  BYVAL ObjID AS LONG, _
  BYVAL ZS_STYLE AS LONG _
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 1.20
' To be used with a bitmap object.
' Retrieve a copy of the entire bitmap for the object IDentifier being used,
' using a 2 dimensions array of the form (x,y) pointing directly to pixel.
' You can use the array coordinates as you would do with a standard DC,
' because pixel 0,0 is at coordinate Array(0,0).
' Once your are done with the array, the bitmap is replaced using ZD_SetBitmapObjectBits.
' (see ZD_SetBitmapObjectBits)
  DECLARE FUNCTION ZD_GetBitmapObjectBits LIB "GDIMAGE.DLL" ALIAS "ZD_GetBitmapObjectBits" ( _
  BYVAL ObjID AS LONG, _                   ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  PixelArray() AS LONG _                   ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  ) AS LONG
' Return:
' Null if error, else success.
'****************************************************************************
'
'****************************************************************************
' Version 1.20
' To be used with a bitmap object.
' Replace a copy of a bitmap that was retrieved as a device-independent bitmap.
' (see ZD_GetBitmapObjectBits)
  DECLARE FUNCTION ZD_SetBitmapObjectBits LIB "GDIMAGE.DLL" ALIAS "ZD_SetBitmapObjectBits" ( _
  BYVAL ObjID AS LONG, _                   ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  PixelArray() AS LONG, _                  ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  OPTIONAL BYVAL DoNotClearArray AS LONG _ ' Boolean flag, %TRUE = DO NOT clear the array.
  )AS LONG
' Return:
' Null if error, else success.
'****************************************************************************
'
'****************************************************************************
' Version 1.21
  TYPE ZPOLYGON
      pXY        AS DWORD    ' 32-bit unsigned POINTS PTR
      ArraySize  AS INTEGER  ' 16-bit signed SHORT integer
      ObjID      AS LONG     ' 32-bit signed LONG integer
      ColorARGB  AS LONG     ' 32-bit signed LONG integer
      PenSize    AS INTEGER  ' 16-bit signed SHORT integer
      ZS_Style   AS LONG     ' 32-bit signed LONG integer
      ZD_Style   AS LONG     ' 32-bit signed LONG integer
  END TYPE
'****************************************************************************
'
'****************************************************************************
' Version 1.21
' Draws a series of closed polygons.
' Each polygon is outlined or filled by using a specific pen size and ARGB color.
' The polygons drawn by this function can overlap.
  DECLARE FUNCTION ZD_PolyPolygon LIB "GDIMAGE.DLL" ALIAS "ZD_PolyPolygon" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  zp() AS ZPOLYGON, _                  ' The polypolygon description.
  BYVAL PolygonCount AS LONG _         ' The plygon count.
  ) AS LONG
' Return:
' TRUE (-1) if success, FALSE (0) if error
'****************************************************************************
'
'****************************************************************************
' Version 1.21
' Show or hide a list of GDImage overlay objects at once.
  DECLARE SUB ZD_ShowObjectList LIB "GDIMAGE.DLL" ALIAS "ZD_ShowObjectList" ( _
  BYVAL ObjectList AS LONG PTR, _     ' A long pointer to an array of object ID
  BYVAL ListSize AS LONG, _           ' The size of the array.
  BYVAL ShowOrHide AS LONG _          ' %TRUE = SHOW, %FALSE = HIDE.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.36
' Show or Hide a specific GDImage overlay object.
  DECLARE SUB ZD_SetObjectVisibility LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectVisibility" ( _
  BYVAL ObjID AS LONG, _      ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ShowOrHide AS LONG _  ' A boolean TRUE/FALSE flag to show or hide the object.
  )
'****************************************************************************
'
'
'****************************************************************************
'****************************************************************************
'*                                                                          *
'*                             HELPER FUNCTIONS                             *
'*                                                                          *
'****************************************************************************
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Retrieve the instance of the current module
  DECLARE FUNCTION zInstance LIB "GDIMAGE.DLL" ALIAS "zInstance" () AS LONG
' Return:
' the instance handle of the running application.
'****************************************************************************
'
'****************************************************************************
' Version 1.07
' Beep the user.
  DECLARE SUB zFocusBeep LIB "GDIMAGE.DLL" ALIAS "zFocusBeep" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.11
' Compute CPU SPEED, handy to compute animation speed.
  DECLARE FUNCTION zGetCPUspeed LIB "GDIMAGE.DLL" ALIAS "zGetCPUspeed" () AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.00
' Check if file exist
  DECLARE FUNCTION zExist LIB "GDIMAGE.DLL" ALIAS "zExist" ( _
  BYVAL FullPathName AS STRING _ ' The name of the file to check.
  ) AS LONG
' Return:
' TRUE (-1) if exist, FALSE (0) if not.
'****************************************************************************
'
'****************************************************************************
' Version 1.16
' Generic I/O file manager faster and less overhead than built-in PB's functions.
' OPEN File
  DECLARE FUNCTION zFOpen LIB "GDIMAGE.DLL" ALIAS "zFOpen" ( _
  BYVAL FullPathName AS STRING, _ ' The name of the file to open.
  BYVAL AccessMode AS LONG, _
  BYVAL ShareMode AS LONG, _
  BYREF hFile AS LONG _
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.16
' Generic I/O file manager faster and less overhead than built-in PB's functions
' CLOSE File
  DECLARE SUB zFClose LIB "GDIMAGE.DLL" ALIAS "zFClose" ( _
  BYREF hFile AS LONG _
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.16
' Generic I/O file manager faster and less overhead than built-in PB's functions
' GET buffer
  DECLARE FUNCTION zFGet LIB "GDIMAGE.DLL" ALIAS "zFGet" ( _
  BYVAL hFile AS LONG, _
  BYREF sBuffer AS STRING _
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.16
' Generic I/O file manager faster and less overhead than built-in PB's functions
' Disk size of an open file FLOF
  DECLARE FUNCTION zFlof LIB "GDIMAGE.DLL" ALIAS "zFlof" ( _
  BYVAL hFile AS LONG _
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
  MACRO Pi = 3.141592653589793##
  MACRO HalfPI = 1.5707963267948965##
  MACRO PiDiv4 = 0.785398163397448##
  MACRO DegreesToRadians(Deg) = Deg * 0.0174532925199432957##

'****************************************************************************
'
'****************************************************************************

' Version 1.21
' Low level function to retrieve a device-independent bitmap.
  DECLARE FUNCTION zGetDIBits LIB "GDIMAGE.DLL" ALIAS "zGetDIBits" ( _
  BYVAL hBitmap AS LONG, _                 ' A valid bitmap handle.
  PixelArray() AS LONG _                   ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  ) AS LONG

' Version 1.21
' Low level function to replace a copy of a bitmap that was retrieved as a device-independent bitmap.
  DECLARE FUNCTION zSetDIBits LIB "GDIMAGE.DLL" ALIAS "zSetDIBits" ( _
  BYVAL hBitmap AS LONG, _                 ' A valid bitmap handle.
  PixelArray() AS LONG _                   ' Array using 2 dimensions (Y,Y) matching the pixel coordinates.
  ) AS LONG

' Version 1.30
' Low level function to split an ARGB color.
  DECLARE SUB zSplitColorARGB LIB "GDIMAGE.DLL" ALIAS "zSplitColorARGB" ( _
  BYVAL ARGB AS LONG, _                    ' The ARGB color to split
  Alpha AS BYTE, _                         ' The Alpha channel in the range 0-255.
  Red AS BYTE, _                           ' The Red component in the range 0-255.
  Green AS BYTE, _                         ' The Green component in the range 0-255.
  Blue AS BYTE _                           ' The Blue component in the range 0-255.
  )

'****************************************************************************
'
'****************************************************************************
'****************************************************************************
'***                                                                      ***
'***                         SLIDE SHOW FUNCTIONS                         ***
'***                                                                      ***
'****************************************************************************
'****************************************************************************
' Version 1.25
  TYPE ZSLIDESHOW
    ' Slide section
      FilName   AS ASCIIZ * 260
      Delay     AS LONG
      Effect    AS INTEGER
      Grain     AS INTEGER
    ' Font section
      Legend    AS ASCIIZ * 128
      FontName  AS ASCIIZ * 64
      FontSize  AS INTEGER
      FontColor AS LONG
      Shadow    AS BYTE
      Location  AS BYTE
  END TYPE

' Transition effects
  %ZE_EFFECT_MIN                 = 0  '
  %ZE_TRANSLUCENT_SPIRAL         = 0  ' Translucent spiral (uGrain to adjust speed).
  %ZE_SMOOTH_FADING              = 1  ' Smooth fading (uGrain to adjust speed).
  %ZE_MOVE_BOTTOM_TO_TOP         = 2  ' Moving from bottom to top (uGrain to adjust speed).
  %ZE_VERTICAL_LINE              = 3  ' Vertical line (use uGrain to change space between lines).
  %ZE_VERTICAL_LINE_FILLED_RIGHT = 4  ' Vertical line (use uGrain to change space between lines).
  %ZE_CHECKER_BOARD              = 5  ' Checker board (use uGrain for larger square).
  %ZE_RANDOM_DOT                 = 6  ' Random dots (use uGrain for larger dots).
  %ZE_WIPE_TO_CENTER             = 7  ' Wipe to center (uGrain to adjust speed).
  %ZE_STRETCH_FROM_CENTER        = 8  ' Stretch from center (uGrain to adjust speed).
  %ZE_PUSH_LEFT_TO_RIGHT         = 9  ' Push from left to right (uGrain to adjust speed).
  %ZE_PUSH_TOP_TO_BOTTOM         = 10 ' Push from top to bottom (uGrain to adjust speed).
  %ZE_NO_EFFECT                  = 11 ' Cut mode (no transition effect).
  %ZE_EFFECT_MAX                 = 11

' Legend location
  %ZE_TXT_TOP_LEFT               = 1  ' Text on the top, left justified.
  %ZE_TXT_TOP_CENTER             = 2  ' Text on the top, centered.
  %ZE_TXT_TOP_RIGHT              = 3  ' Text on the top, right justified.
  %ZE_TXT_MIDDLE_CENTER          = 4  ' Text on the middle, centered.
  %ZE_TXT_BOTTOM_LEFT            = 5  ' Text on the bottom, left justified.
  %ZE_TXT_BOTTOM_CENTER          = 0  ' Text on the bottom, centered.
  %ZE_TXT_BOTTOM_RIGHT           = 6  ' Text on the bottom, right justified.

'****************************************************************************
'
'****************************************************************************
' Version 1.37
' Start playing a GDImage slide show.
  DECLARE SUB ZI_SlideAnimate LIB "GDIMAGE.DLL" ALIAS "ZI_SlideAnimate" ( _
  BYVAL hGDImageCtrl AS LONG, _  ' The GDImage control handle.
  BYVAL ipt AS ZSLIDESHOW PTR, _ ' A DWORD PTR to a ZSLIDESHOWE array.
  BYVAL ImageCount AS LONG, _    ' Number of element in the array
  BYVAL LoopMode AS LONG _       ' Boolean flag, TRUE = play slide show in loop mode.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.25
' STOP a playing GDImage slide show.
  DECLARE SUB ZI_SlideStop LIB "GDIMAGE.DLL" ALIAS "ZI_SlideStop" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.25
' Play a GDImage slide show in incremental order.
  DECLARE SUB ZI_SlidePlayIncrOrder LIB "GDIMAGE.DLL" ALIAS "ZI_SlidePlayIncrOrder" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.25
' Play a GDImage slide show in decremental order.
  DECLARE SUB ZI_SlidePlayDecrOrder LIB "GDIMAGE.DLL" ALIAS "ZI_SlidePlayDecrOrder" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.25
' PLAY a GDImage slide show that has been previously PAUSED.
  DECLARE SUB ZI_SlidePlay LIB "GDIMAGE.DLL" ALIAS "ZI_SlidePlay" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.25
' PAUSE a playing GDImage slide show.
  DECLARE SUB ZI_SlidePause LIB "GDIMAGE.DLL" ALIAS "ZI_SlidePause" ()
'****************************************************************************
'
'****************************************************************************
'****************************************************************************
'*                                                                          *
'*                             OpenGL FUNCTIONS                             *
'*                                                                          *
'****************************************************************************
'****************************************************************************
'
'****************************************************************************
  %ZI_GLDC      = 8  ' OpenGL Device Context
  %ZI_GLRC      = 9  ' OpenGL Rendering Context
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' No need to use it if you have already registered the RegisterGDImageClass
' -------------------------------------------------------------------------
' Must be done in the WinMain section BEFORE USING any of the GDImage function.
' Parameter: None
  DECLARE FUNCTION RegisterGLImageClass LIB "GDIMAGE.DLL" ALIAS "RegisterGLImageClass" () AS LONG
' Return:
' 0 = means failure, any other value means registered.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' Create an OpenGL texture from any of the supported GDImage graphic format.
' GDImage takes care of all the hard stuff to create a correct OpenGL texture.
  DECLARE FUNCTION ZI_CreateGLTextureFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_CreateGLTextureFromFile" ( _
  zFullPathName AS ASCIIZ, _        ' Name of the graphic file to create the texture from.
  xPower2 AS LONG, _                ' A value in the range: 2, 4, 16, 32, 64, 128, 256, 512, etc.
  yPower2 AS LONG, _                ' A value in the range: 2, 4, 16, 32, 64, 128, 256, 512, etc.
  PixelArray() AS BYTE _           ' Byte array holding the texture.
  ) AS LONG
' Return:
' If the function succeeds the returned value is %TRUE,
' and the PixelArray is full of bytes that are already converted to the internal RGBA OpenGL format.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' Create on the fly an OpenGL texture from any supported GDImage raster graphic file.
  DECLARE FUNCTION ZI_SetGLTextureFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_SetGLTextureFromFile" ( _
  zFullPathName AS ASCIIZ _        ' Name of the graphic file to create the texture from.
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' Enable the use of OpenGL with a previously "bounded" GDImage OpenGL texture.
  DECLARE SUB ZI_InitGLControl LIB "GDIMAGE.DLL" ALIAS "ZI_InitGLControl" ( _
  BYVAL ARGB AS LONG _ ' The GDImage ARGB color to paint the control background.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' Allows you to resize the "view port" of a GDImage OpenGL control during WM_SIZE message.
' The GDImage control being the container of the OpenGL "view port",
' you must resize both the control and the "veiw port".
  DECLARE SUB ZI_ResizeGLWindow LIB "GDIMAGE.DLL" ALIAS "ZI_ResizeGLWindow" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  )
' Note: To resize automatically a GDImage control use the ZI_SetAnchorMode API.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' Allows you to update a GDImage OpenGL control.
  DECLARE SUB ZI_UpdateGLWindow LIB "GDIMAGE.DLL" ALIAS "ZI_UpdateGLWindow" (BYVAL hWnd AS LONG)
' Note:
' This API must be called from your "DrawScene" procedure to display the rendered animation.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' To retrieve the GDImage OpenGL permanent (CS_OWNDC) Device Context.
  DECLARE FUNCTION ZI_GetGLDC LIB "GDIMAGE.DLL" ALIAS "ZI_GetGLDC" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Do not delete this DC.
'****************************************************************************
'
'****************************************************************************
' Version 1.30
' To retrieve the GDImage OpenGL Rendering Context.
  DECLARE FUNCTION ZI_GetGLRC LIB "GDIMAGE.DLL" ALIAS "ZI_GetGLRC" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.31
  TYPE ZGLFONT
      fontName   AS ASCIIZ * 64 ' The True Type font name.
      fontBase   AS LONG        ' The OpenGL FontBase (do not set this).
      charStart  AS LONG        ' OpenGL starting ASCII character (usually 32).
      charNum    AS LONG        ' OpenGL number of glyphe characters to create(usually 96).
      fontHeight AS LONG        ' The font size (72 DPI).
      fontWeight AS LONG        ' The font weigt.
      fontHandle AS LONG        ' The Win32 font handle
  END TYPE
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Create an OpenGL font, from a Windows True Type Font, to use with ZI_DrawGLText.
  DECLARE SUB ZI_BuildGLfont LIB "GDIMAGE.DLL" ALIAS "ZI_BuildGLfont" ( _
  BYVAL hGLcontrolDC AS LONG, _ ' The GDimage Device Context (see ZI_GetGLDC).
  UseFont AS ZGLFONT _          ' Pointer to a ZGLFONT structure.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Delete a GDImage OpenGL font previously created with ZI_BuildGLfont.
  DECLARE SUB ZI_DeleteGLFont LIB "GDIMAGE.DLL" ALIAS "ZI_DeleteGLFont" ( _
  UseFont AS ZGLFONT _          ' Pointer to a ZGLFONT structure.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Display a text string on a GDImage OpenGL graphic control.
  DECLARE SUB ZI_DrawGLText LIB "GDIMAGE.DLL" ALIAS "ZI_DrawGLText" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  UseFont AS ZGLFONT, _         ' Pointer to a ZGLFONT structure.
  BYVAL x AS LONG, _            ' The X location in pixel coordinates.
  BYVAL y AS LONG, _            ' The Y location in pixel coordinates.
  zTxt AS ASCIIZ, _             ' The text string to display.
  BYVAL ARGB AS LONG _          ' The ARGB color to use.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Return Width and Height of a string based on a specific ZGLFONT font structure.
  DECLARE SUB ZI_GetGLTextExtent LIB "GDIMAGE.DLL" ALIAS "ZI_GetGLTextExtent"( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  UseFont AS ZGLFONT, _         ' Pointer to a ZGLFONT structure.
  zTxt AS ASCIIZ, _             ' The text string to compute the size from.
  stWidth AS LONG, _            ' The width of the string in pixel.
  stHeight AS LONG _            ' The height of the string in pixel.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Do not create a default SQUARE shape texture.
' With spherical objects, it is better to use a rectangular texture:
' Best size would be 128 x 64, 256 x 128, 512 x 256, 1024 x 512, etc. (always 2^n).
  DECLARE SUB ZI_DoNotSquareTexture LIB "GDIMAGE.DLL" ALIAS "ZI_DoNotSquareTexture" ()
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Set the current GDImage OpenGL zoom.
  DECLARE SUB ZI_SetGLzoom LIB "GDIMAGE.DLL" ALIAS "ZI_SetGLzoom" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL fovy AS LONG _          ' The field of view angle, in degrees (1-180), in the y-direction.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Retrieve the current GDImage OpenGL zoom.
  DECLARE FUNCTION ZI_GetGLzoom LIB "GDIMAGE.DLL" ALIAS "ZI_GetGLzoom" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' The fovy angle in degree from the observer in the range 1-180.
'****************************************************************************
'
'****************************************************************************
' Version 1.31
' Create a polar view.
  DECLARE SUB ZI_UseGLPolarView LIB "GDIMAGE.DLL" ALIAS "ZI_UseGLPolarView" ( _
  BYVAL radius AS DOUBLE, _     ' The radius value.
  BYVAL twist AS DOUBLE, _      ' The twist value.
  BYVAL latitude AS DOUBLE, _   ' The latitude value.
  BYVAL longitude AS DOUBLE _   ' The longitude value.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.33
' Convert a GDImage ARGB color to an OpenGL color.
' The new color applies to all subsequent OpenGL drawing procedures until a new color is defined.
  DECLARE SUB ZI_glColor4f LIB "GDIMAGE.DLL" ALIAS "ZI_glColor4f" ( _
  BYVAL ARGB AS LONG _          ' A GDImage ARGB color.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Determines whether a key is up or down at the time the function is called.
  DECLARE FUNCTION ZI_IsKeyDown LIB "GDIMAGE.DLL" ALIAS "ZI_IsKeyDown" ( _
  BYVAL CheckKey AS LONG _ ' One of 256 possible virtual-key codes.
  ) AS LONG
' Return:
' TRUE = the key is down, FALSE = the key is up.
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Determines whether the left mouse button is up or down at the time the function is called.
  DECLARE FUNCTION ZI_IsLButtonDown LIB "GDIMAGE.DLL" ALIAS "ZI_IsLButtonDown" () AS LONG
' Return:
' TRUE = the mouse button is down, FALSE = the mouse button is up.
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Determines whether the right mouse button is up or down at the time the function is called.
  DECLARE FUNCTION ZI_IsRButtonDown LIB "GDIMAGE.DLL" ALIAS "ZI_IsRButtonDown" () AS LONG
' Return:
' TRUE = the mouse button is down, FALSE = the mouse button is up.
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Determines whether a the Shift key is up or down at the time the function is called.
  DECLARE FUNCTION ZI_IsShiftKeyPressed LIB "GDIMAGE.DLL" ALIAS "ZI_IsShiftKeyPressed" () AS LONG
' Return:
' TRUE = the Shift key is down, FALSE = the Shift key is up.
'****************************************************************************
'
'****************************************************************************
' Version 1.32
' Determines whether the Ctrl key is up or down at the time the function is called.
  DECLARE FUNCTION ZI_IsCtrlKeyPressed LIB "GDIMAGE.DLL" ALIAS "ZI_IsCtrlKeyPressed" () AS LONG
' Return:
' TRUE = the Ctrl key is down, FALSE = the Ctrl key is up.
'****************************************************************************
'
'****************************************************************************
' Version 1.34
' Create a GDImage OpenGL panorama view.
  DECLARE SUB ZI_UseGLPanoramaView LIB "GDIMAGE.DLL" ALIAS "ZI_UseGLPanoramaView" ( _
  BYVAL Vert AS DOUBLE, _  ' The vertical orientation angle in degree.
  BYVAL Horz AS DOUBLE _   ' The horizontal orientation angle in degree.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.35
  TYPE ZGLTEXTURE
      ID       AS LONG
      FullName AS ASCIIZ * 260
      Texture  AS LONG
  END TYPE
'****************************************************************************
'
'****************************************************************************
' Version 1.35
' Load multiple OpenGL "Named texture" at once.
  DECLARE FUNCTION ZI_SetMutipleGLTextureFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_SetMutipleGLTextureFromFile" ( _
  BYVAL ztp AS ZGLTEXTURE PTR, _         ' A DWORD PTR to a ZGLTEXTURE array.
  BYVAL N AS LONG _                      ' Number of element in the array
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.
'****************************************************************************
'
'****************************************************************************
' Version 1.35
' Assign a new texture to an existing OpenGL "Named texture".
  DECLARE FUNCTION ZI_UpdateNamedGLTextureFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_UpdateNamedGLTextureFromFile" ( _
  zFullName AS ASCIIZ, _       ' Full qualified path name.
  BYVAL NamedTexture AS LONG _ ' An existing OpenGL NamedTexture
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.
'****************************************************************************
'
'****************************************************************************

  %WM_MMTIMER = &H400 + 2060 ' MultiMedia timer message

  MACRO GLenum     = DWORD   ' 32-Bit unsigned.
  MACRO GLboolean  = BYTE    ' 8-Bit  unsigned.
  MACRO GLbitfield = DWORD   ' 32-Bit unsigned.
  MACRO GLbyte     = BYTE    ' 8-Bit  signed.
  MACRO GLshort    = INTEGER ' 16-Bit signed.
  MACRO GLint      = LONG    ' 32-Bit signed.
  MACRO GLubyte    = BYTE    ' 8-Bit  unsigned.
  MACRO GLushort   = WORD    ' 16-Bit unsigned.
  MACRO GLuint     = DWORD   ' 32-Bit unsigned.
  MACRO GLsizei    = LONG    ' 32-Bit signed.
  MACRO GLfloat    = SINGLE  ' single precision float.
  MACRO GLclampf   = SINGLE  ' single precision float in [0,1].
  MACRO GLdouble   = DOUBLE  ' double precision float.
  MACRO GLclampd   = DOUBLE  ' double precision float in [0,1].
  MACRO GLvoid     = ANY     ' No need for it.


'****************************************************************************
'
'****************************************************************************
' Version 1.39
' FlipReverse :
  %ZD_Normal  = 0 ' Orientation unchanged (default)
  %ZD_Flip    = 1 ' Swap top / bottom
  %ZD_Reverse = 2 ' Swap left / right
' Allows you to crop / create a new bitmap from an existing one using new coordinates that must lie within the range of the previous one.
  DECLARE FUNCTION ZI_CropBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_CropBitmap" ( _
  BYVAL hBmp AS LONG, _          ' Handle to an existing bitmap.
  BYVAL x AS LONG, _             ' X top left corner of the croping section.
  BYVAL y AS LONG, _             ' Y top corner of the croping section.
  BYVAL w AS LONG, _             ' Width of the crop.
  BYVAL h AS LONG, _             ' Height of the crop.
  BYVAL FlipReverse AS LONG _    ' Orientation of the resulting croped section.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 3.01 '// 1.39
' Save multiple layers into a  single disk file, using any of the supported graphic format.
  %RotateNoneFlipNone = 0
  %Rotate90FlipNone = 1
  %Rotate180FlipNone = 2
  %Rotate270FlipNone = 3
  DECLARE FUNCTION ZI_RenderLayersToFile LIB "GDIMAGE.DLL" ALIAS "ZI_RenderLayersToFile" ( _
  BYVAL hGDImageCtrl AS LONG, _      ' The GDimage control handle.
  zFullName AS ASCIIZ, _             ' Full qualified path name.
  BYVAL Quality AS LONG, _           ' For JPEG only, quality ranges from 0-100 (100 = best quality)
  BYVAL Rotation AS LONG, _          ' Orientation
  OPTIONAL BYVAL UseWidth AS LONG, _ ' Optional parameter to fit the image into a specific width.
  OPTIONAL BYVAL UseHeight AS LONG _ ' Optional parameter to fit the image into a specific height.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.39
' Replace a RGB color with another RGB color, using a bitmap handle.
  DECLARE SUB ZI_ReplaceRGBColorBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_ReplaceRGBColorBitmap" ( _
  BYVAL hBitmap AS LONG, _      ' A valid bitmap handle.
  BYVAL WasColor AS LONG, _     ' RGB Pixel color to replace
  BYVAL NewColor AS LONG _      ' New RGB pixel color
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Change the zooming value of a GDImage Zoom window control ( ZI_ZoomWindow property).
  DECLARE SUB ZI_SetZoomValue LIB "GDIMAGE.DLL" ALIAS "ZI_SetZoomValue"( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL ZoomValue AS SINGLE _   ' The zoom factor as a floating value.
  )
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Get the zoom factor of a GDImage Zoom window control ( ZI_ZoomWindow property).
  DECLARE FUNCTION ZI_GetZoomValue LIB "GDIMAGE.DLL" ALIAS "ZI_GetZoomValue" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS SINGLE
' Return:
' The zoom factor as a floating value
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Computes location and size to stretch a bitmap preserving its aspect.
  DECLARE SUB ZI_Iconise LIB "GDIMAGE.DLL" ALIAS "ZI_Iconise" ( _
  BYVAL xPicSize AS LONG, _ ' The real image width.
  BYVAL yPicSize AS LONG, _ ' The real image height.
  BYVAL xCell AS LONG, _    ' The fit into wdith.
  BYVAL yCell AS LONG, _    ' The fit inot height.
  BYREF xPos AS LONG, _     ' New X computed value.
  BYREF yPos AS LONG, _     ' New Y computed value.
  BYREF xSize AS LONG, _    ' New Width computed value.
  BYREF ySize AS LONG _     ' New Height computed value.
  )

  %WM_USER          = 1024
  %ZM_Size          = %WM_USER + 1001
  %ZM_Crop          = %WM_USER + 1002
  %ZM_CENTER_DIALOG = %WM_USER + 1003
  %ZM_CropRedEye    = %WM_USER + 1004
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Retrieve the current selected bitmap from a specific Device Context.
  DECLARE FUNCTION ZI_GetBitmapFromDC LIB "GDIMAGE.DLL" ALIAS "ZI_GetBitmapFromDC" ( _
  BYVAL hDC AS LONG _ ' A Windows valid DC
  ) AS LONG
' Return:
' The bitmap handle matching the specific DC if any.
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Enhanced HALFTONE StretchBlt function
  DECLARE FUNCTION ZD_StretchBlt LIB "GDIMAGE.DLL" ALIAS "ZD_StretchBlt" ( _
  BYVAL hDCdest AS LONG, _    ' Handle to destination DC.
  BYVAL xDest AS LONG, _      ' X-coord of destination upper-left corner.
  BYVAL yDest AS LONG, _      ' Y-coord of destination upper-left corner.
  BYVAL DestWidth AS LONG, _  ' Width of destination rectangle.
  BYVAL DestHeight AS LONG, _ ' Height of destination rectangle.
  BYVAL hDCsrce AS LONG, _    ' Handle to source DC.
  BYVAL xSrce AS LONG, _      ' X-coord of source upper-left corner.
  BYVAL ySrce AS LONG, _      ' Y-coord of source upper-left corner.
  BYVAL SrceWidth AS LONG, _  ' Width of source rectangle.
  BYVAL SrceHeight AS LONG _  ' Height of source rectangle.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Split multiple parts of a full path name.
  DECLARE SUB zSplitN LIB "GDIMAGE.DLL" ALIAS "zSplitN" ( _
  BYVAL FullName AS STRING,  _
  PathName AS STRING, _
  FilName AS STRING _
  )
' Return:
' The qualified path name plus the single file name.
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Load image from file and return a valid GDIPLUS image handle
  DECLARE FUNCTION zLoadImageFromFile LIB "GDIMAGE.DLL" ALIAS "zLoadImageFromFile" ( _
  zFullName AS ASCIIZ, _      ' Full path name to any of the supported graphic format.
  BYREF imgW AS LONG, _       ' Return the image width.
  BYREF imgH AS LONG, _       ' Return the image height.
  BYVAL Orientation AS LONG _ ' Orientation to create the memory image.
  ) AS LONG
' Return:
' A valid GDIPLUS image handle, suitable with the low level GDIPLUS flat API.
'****************************************************************************
'
'****************************************************************************
' Version 1.41
' Save image to file using a valid GDIPLUS image handle.
  DECLARE FUNCTION zSaveImageToFile LIB "GDIMAGE.DLL" ALIAS "zSaveImageToFile" ( _
  zFullName AS ASCIIZ, _      ' Full path name destination.
  BYVAL Img AS LONG, _        ' A valid GDIPLUS handle.
  BYVAL Quality AS LONG _     ' Quality applies to the JPEG format only.
  ) AS LONG
' Return:
' Null in case of success, else a GDIPLUS error code.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Assign a label to any sprite object.
  DECLARE SUB ZD_SetObjectImageLabel LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectImageLabel" ( _
  BYVAL ObjID AS LONG, _  ' The unique sprite object identifier.
  zUseText AS ASCIIZ _    ' The label to use.
  )
' Comment:
' This label is a complement to the unique identifier being used for a sprite.
' It can be used to dialog with the user when using a ZI_EventMessage callback.
' Remark:
' Maximum label size is 64 characters.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the label matching a specific sprite object identifier.
  DECLARE FUNCTION ZD_GetObjectImageLabel LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectImageLabel" ( _
  BYVAL ObjID AS LONG _  ' The unique sprite object identifier.
  ) AS STRING
' Return:
' The label matching the identifier if any.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Setup the scroll with background property of a specific sprite object.
  DECLARE SUB ZD_SetObjectScroll LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectScroll" ( _
  BYVAL ObjID AS LONG, _     ' The unique sprite object identifier.
  BYVAL TrueFalse AS LONG _  ' The TRUE or FALSE scroll mode.
  )
' Remark:
' If scroll mode is set to false (default),
' then the sprite looks floating above the backround when you scroll it.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the scroll status of a specific sprite object identifier.
  DECLARE FUNCTION ZD_GetObjectScroll LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectScroll" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' Null = scrolling disabled, Else = scrolling enabled.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Set the mouse lock status of a specific sprite object.
  DECLARE SUB ZD_SetObjectLocked LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectLocked" ( _
  BYVAL ObjID AS LONG, _     ' The unique sprite object identifier.
  BYVAL TrueFalse AS LONG _  ' The TRUE or FALSE lock mode.
  )
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the mouse lock status of a specific sprite object identifier.
  DECLARE FUNCTION ZD_GetObjectLocked LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectLocked" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Use full variable opacity with 32-bit PNG transparent.
  DECLARE SUB ZD_UsePngOpacity LIB "GDIMAGE.DLL" ALIAS "ZD_UsePngOpacity" ( _
  BYVAL ObjID AS LONG, _     ' The unique sprite object identifier.
  BYVAL TrueFalse AS LONG _  ' TRUE = enable, FALSE = disable (default).
  )
' Remark:
' This feature is only available with PNG 32-bit, because they have an alpha channel.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' To customize the default Load / Save Dialog messages.
  DECLARE SUB ZI_SetSaveDialogMsg LIB "GDIMAGE.DLL" ALIAS "ZI_SetSaveDialogMsg" ( _
  zCaptionLoad AS ASCIIZ, _ ' Caption for the Load dialog.
  zCaptionSave AS ASCIIZ, _ ' caption for the Save dialog.
  zDefaultName AS ASCIIZ _  ' Default file name for the Save dialog.
  )
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Monitor the Windows message flow using a callback to take control over the GDImage default procedure.
  DECLARE SUB ZI_EventMessage LIB "GDIMAGE.DLL" ALIAS "ZI_EventMessage" ( _
  BYVAL pCodePtr AS DWORD, _   ' Pointer to a MyCallback function (see remark below).
  BYVAL WM_Message AS LONG, _  ' The Windows message to filter.
  BYVAL SetReset AS LONG _     ' TRUE = enable, FALSE = disable callback for the specific message.
  )

' Remark:
' FUNCTION MyCallBack( _       ' Use any name, and provide its code pointer to ZI_EventMessage
' BYVAL hWnd AS LONG, _        ' The GDImage control handle sending the event.
' BYVAL Msg AS LONG, _         ' Any standard Windows message.
' BYVAL wParam AS LONG, _      ' The contents of this parameter depend on the value of the Msg parameter.
' BYVAL lParam AS LONG _       ' The contents of this parameter depend on the value of the Msg parameter.
' ) AS LONG                    ' See MSDN documentation about using a WindowProc function.
'
' Important:
' If you want to stop further processing of the message by GDImage, then the callback function must return TRUE.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the unique object IDentifier of the sprite that has the GDImage focus.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE FUNCTION ZI_GetObjectFocusID LIB "GDIMAGE.DLL" ALIAS "ZI_GetObjectFocusID" () AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the unique object IDentifier of the sprite hover the mouse.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE FUNCTION ZI_MouseOverObjectID LIB "GDIMAGE.DLL" ALIAS "ZI_MouseOverObjectID" () AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the GDImage mouse captured X,Y location.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE SUB ZD_GetObjectXYcapture LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectXYcapture" ( _
  BYVAL ObjID AS LONG, _  ' The unique sprite object identifier.
  BYREF x AS LONG, _      ' Return the mouse X cursor location.
  BYREF y AS LONG _       ' Return the mouse Y cursor location.
  )
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the Item of the sprite being moved.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE FUNCTION ZI_GetMovingSpriteItem LIB "GDIMAGE.DLL" ALIAS "ZI_GetMovingSpriteItem" () AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the unique IDentifier of the sprite being moved.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE FUNCTION ZI_GetMovingSpriteID LIB "GDIMAGE.DLL" ALIAS "ZI_GetMovingSpriteID" () AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Retrieve the DIB bitmap handle of the GDImage control background.
  DECLARE FUNCTION ZI_GetBMP LIB "GDIMAGE.DLL" ALIAS "ZI_GetBMP" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Create an OpenGL transparent texture from 32-bit PNG using variable opacity.
' GDImage takes care of all the hard stuff to create a correct OpenGL texture.
  DECLARE FUNCTION ZI_CreateGLTextureFrom32Bit LIB "GDIMAGE.DLL" ALIAS "ZI_CreateGLTextureFrom32Bit" ( _
  zFullPathName AS ASCIIZ, _        ' Name of the graphic file to create the texture from.
  xPower2 AS LONG, _                ' A value in the range: 2, 4, 16, 32, 64, 128, 256, 512, etc.
  yPower2 AS LONG, _                ' A value in the range: 2, 4, 16, 32, 64, 128, 256, 512, etc.
  PixelArray() AS BYTE _            ' Byte array holding the texture.
  ) AS LONG
' Remark:
' It can also be used to create opaque texture from a file without alpha channel.
' Return:
' If the function succeeds the returned value is %TRUE,
' and the PixelArray is full of bytes that are already converted to the internal RGBA OpenGL format.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Create on the fly an OpenGL transparent texture from a PNG 32-bit using variable opacity.
  DECLARE FUNCTION ZI_SetGLTextureFrom32Bit LIB "GDIMAGE.DLL" ALIAS "ZI_SetGLTextureFrom32Bit" ( _
  zFullPathName AS ASCIIZ _        ' Name of the graphic file to create the texture from.
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.
'****************************************************************************
'
'****************************************************************************
' Version 2.00
' Load multiple OpenGL transparent "Named texture" at once from PNG 32-bit using variable opacity.
  DECLARE FUNCTION ZI_SetMutipleGLTextureFrom32Bit LIB "GDIMAGE.DLL" ALIAS "ZI_SetMutipleGLTextureFrom32Bit" ( _
  BYVAL ztp AS ZGLTEXTURE PTR, _         ' A DWORD PTR to a ZGLTEXTURE array.
  BYVAL N AS LONG _                      ' Number of element in the array
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.

' Version 2.00
'  DECLARE FUNCTION ZI_FitImageFrom32Bit LIB "GDIMAGE.DLL" ALIAS "ZI_FitImageFrom32Bit" (zFullPath AS ASCIIZ, BYVAL Xin AS LONG, BYVAL Yin AS LONG) AS LONG

' Version 2.01
' To force the default folder being used by ZI_LoadDialog
  DECLARE FUNCTION ZI_LoadSavePath LIB "GDIMAGE.DLL" ALIAS "ZI_LoadSavePath" ( _
  zUseThisPath AS ASCIIZ, _              ' The new folder path
  BYVAL SetGet AS LONG _                 ' The Set/Get boolean property: Set = 1, Get = 0.
  ) AS STRING
' Return:
' The folder path when SetGet is in Get mode.

' Version 2.02 is DotNET compatible.

'****************************************************************************
'
'****************************************************************************
' Version 2.07
' Create a valid GDI BITMAP handle from FILE using any of the supported GDImage format,
' and using a mirror reflection effect.
  DECLARE FUNCTION ZI_CreateMirrorBitmapFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_CreateMirrorBitmapFromFile" ( _
  zFullImagePath AS ASCIIZ, _      ' The name of an image file.
  BitmapWidth AS LONG, _           ' The width of the bitmap.
  BitmapHeight AS LONG _           ' The Height of the bitmap.
  ) AS LONG
' Return:
' A valid GDI bitmap handle (do not confuse GDI bitmap handle and GDI+ Image handle).
' Important:
' You must use DeleteObject(GDIBitmapHandle) when you do not need it anymore.
'****************************************************************************
'
'****************************************************************************
' Version 2.09
' Twin any GDImage object (sprite bitmap, text, vector object)
' The duplicated object will have exactly the same parameters as the original except for the x, y location.
  DECLARE FUNCTION ZD_TwinObject LIB "GDIMAGE.DLL" ALIAS "ZD_TwinObject" ( _
  BYVAL IDtoTwin AS LONG, _       ' The unique IDentifier of the object to duplicate.
  BYVAL TwinID AS LONG, _         ' The unique IDentifier of the new Twin object.
  BYVAL x AS LONG, _              ' The X location in pixel coordinates.
  BYVAL y AS LONG _               ' The Y location in pixel coordinates.
  ) AS LONG
' Important:
' The duplicated object will have exactly the same parameters as the original except for the x, y location.
' However it uses a distinct Font handle for OBJECT_TEXT and a distinct Bitmap handle for OBJECT_IMAGE.
'****************************************************************************
'
'****************************************************************************
' Version 2.10
' Clone any GDImage object (sprite bitmap, text, vector object)
  DECLARE FUNCTION ZD_CloneObject LIB "GDIMAGE.DLL" ALIAS "ZD_CloneObject" ( _
  BYVAL IDtoClone AS LONG, _      ' The unique IDentifier of the object to duplicate.
  BYVAL CloneID AS LONG, _        ' The unique IDentifier of the new Twin object.
  BYVAL x AS LONG, _              ' The X location in pixel coordinates.
  BYVAL y AS LONG _               ' The Y location in pixel coordinates.
  ) AS LONG
' Important:
' The clone shares the same handles and parameters than the original, except for the x, y location.
' It it doesn't create a distinct Font handle for OBJECT_TEXT, nor a distinct Bitmap handle for OBJECT_IMAGE.
'****************************************************************************
'
'****************************************************************************
' Version 2.10
' Delete any GDImage object (sprite bitmap, text, vector object)
  DECLARE SUB ZD_DeleteObject LIB "GDIMAGE.DLL" ALIAS "ZD_DeleteObject" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  )
'****************************************************************************
'
'****************************************************************************
' Version 2.10
' Apply a scale factor to resize a sprite on the fly
  DECLARE SUB ZD_SetObjectScale LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectScale" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL ScaleValue AS SINGLE _ ' The scale factor 0.5, 0.75, 0.80, etc.
  )
' Note:
' The real size of the sprite bitmap stay unchanged, it just affect the way it is being shown.
'****************************************************************************
'
'****************************************************************************
' Version 2.10
' Get the scale factor for the specific sprite identifier
  DECLARE FUNCTION ZD_GetObjectScale LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectScale" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS SINGLE
' Return:
' The current scale factor (default = 1, means no scale factor).
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Delete all objects matching a specific GDImage control
  DECLARE SUB ZI_DeleteCtrlObject LIB "GDIMAGE.DLL" ALIAS "ZI_DeleteCtrlObject" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Associate a new memory bitmap matching the client size of the GDImage control
' to be used as a private DC.
  DECLARE SUB ZI_SetCtrlEmptyBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_SetCtrlEmptyBitmap" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL RGBcolor AS LONG _      ' The RGB color to paint the memory bitmap background.
  )
' Note:
' The size of the memory bitmap will match exactly the client size of the GDImage control.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the horizontal scroll range for a specific GDImage control
  DECLARE FUNCTION ZI_GetXscroll LIB "GDIMAGE.DLL" ALIAS "ZI_GetXscroll" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' The horizontal scroll range in pixel.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the vertical scroll range for a specific GDImage control
  DECLARE FUNCTION ZI_GetYscroll LIB "GDIMAGE.DLL" ALIAS "ZI_GetYscroll" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' The verical scroll range in pixel.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Enable/disable the keyboard hook being used to move the sprite with the direction keys.
  DECLARE FUNCTION ZI_DisableKeybHook LIB "GDIMAGE.DLL" ALIAS "ZI_DisableKeybHook" ( _
  BYVAL EnableDisable AS LONG, _ ' TRUE = Disable, FALSE = Enable
  BYVAL RW AS LONG _             ' TRUE = Set EnableDisable value, FALSE = Read EnableDisable value
  ) AS LONG
' Remark:
' Do it only once per session from the main program section.
' Return:
' The current status.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
  %OBJECT_TEXT        = 1
  %OBJECT_ELLIPSE     = 2
  %OBJECT_RECT        = 3
  %OBJECT_CURVE       = 4
  %OBJECT_ARROW       = 5
  %OBJECT_POLYLINE    = 6
  %OBJECT_BITMAP      = 7
  %OBJECT_BEZIER      = 8
  %OBJECT_POLYPOLYGON = 9
  %OBJECT_TEXTBITMAP  = 10

' Retrieve the type of a GDImage sprite object.
  DECLARE FUNCTION ZD_GetObjectType LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectType" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The object type

' Change the type of a GDImage sprite object.
  DECLARE SUB ZD_SetObjectType LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectType" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL ObjectType AS LONG _   ' The object type (see ZD_GetObjectType)
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Retrieve the rotation angle of a GDImage sprite object.
  DECLARE FUNCTION ZD_GetObjectAngle LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectAngle" ( _
  BYVAL ObjID AS LONG _
  ) AS LONG
' Return:
' The rotation angle in degree (0-360).

' Set the rotation angle of a GDImage sprite object.
  DECLARE SUB ZD_SetObjectAngle LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectAngle" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL AngleDegree AS LONG, _ ' Value must fit within the 0-360 degree range.
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent.
  )
' Remark:
' Full rotation angle applies only to bitmap objects (OBJECT_BITMAP and OBJECT_TEXTBITMAP).
'****************************************************************************
'
'****************************************************************************
  %InterpolationModeDefault = 0
  %InterpolationModeLowQuality = 1
  %InterpolationModeHighQuality = 2'%QualityModeHigh
  %InterpolationModeBilinear = 3
  %InterpolationModeBicubic = 4
  %InterpolationModeNearestNeighbor = 5
  %InterpolationModeHighQualityBilinear = 6
  %InterpolationModeHighQualityBicubic = 7

' Version 3.00
' Get the rendering quality (interpolation mode) of a GDImage sprite object.
  DECLARE FUNCTION ZD_GetObjectQuality LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectQuality" ( _
  BYVAL ObjID AS LONG _  ' The unique sprite object identifier.
  ) AS LONG
' Return:
' An interpolation mode constant (int the range 0-7).

' Set the rendering quality of a GDImage sprite object.
  DECLARE SUB ZD_SetObjectQuality LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectQuality" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL Quality AS LONG, _     ' One interpolation mode constant (in the range 0-7).
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent.
  )
' Remark:
' Quality must match one interpolation mode constant.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the 32-bit ARGB color of a GDImage object.
  DECLARE FUNCTION ZD_GetObjectARGBcolor LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectARGBcolor" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The ARGB color with Alpha channel.

' Set the 32-bit ARGB color of a GDImage object (including its Alpha channel)
  DECLARE SUB ZD_SetObjectARGBcolor LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectARGBcolor" ( _
  BYVAL ObjID AS LONG, _  ' The unique sprite object identifier.
  BYVAL UseARGB AS LONG _ ' The ARGB color with Alpha channel.
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the flip mode of a specific bitmap sprite object.
  DECLARE FUNCTION ZD_GetObjectFlipMode LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectFlipMode" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The flip mode, that is a combination of the (ZD_Reverse = 2) and/or (ZD_Flip = 1) constant.

' Set the flip mode of a specific bitmap sprite object.
  DECLARE SUB ZD_SetObjectFlipMode LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectFlipMode" ( _
  BYVAL ObjID AS LONG, _      ' The unique sprite object identifier.
  BYVAL FipMode AS LONG _     ' A combination of the (ZD_Reverse = 2) and/or (ZD_Flip = 1) constant.
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the rotation angle of a specific bitmap sprite object.
  DECLARE FUNCTION ZD_GetObjectRotation LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectRotation" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The rotation angle in degree.

' Set the rotation mode of a specific bitmap sprite object.
  DECLARE SUB ZD_SetObjectRotation LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectRotation" ( _
  BYVAL ObjID AS LONG, _      ' The unique sprite object identifier.
  BYVAL AngleDegree AS LONG _ ' The rotation angle in degree.
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Update the clone ID parameter of a specific bitmap sprite object.
  DECLARE SUB ZD_SetObjectClone LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectClone" ( _
  BYVAL ObjID AS LONG, _  ' The unique sprite object identifier.
  BYVAL CloneID AS LONG _ ' The new clone ID to use
  )
' Remark:
' Internal use only!

' Get the clone ID parameter of a specific bitmap sprite object.
  DECLARE FUNCTION ZD_GetObjectClone LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectClone" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The unique ID of the clone object if any.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Get the TRUE/FALSE PNG variable opacity status of a bitmap sprite object.
  DECLARE FUNCTION ZD_GetObjectOpacity LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectOpacity" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' A boolean True(-1) or False(0) value.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' To change (on the fly) the bitmap associated to a GDImage bitmap sprite object.
  DECLARE FUNCTION ZD_SetObjectBitmapFromFile LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectBitmapFromFile" ( _
  zFullName AS ASCIIZ, _       ' Full path name to any of the supported graphic format.
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent.
  ) AS LONG
' Remark:
' The file can use any of the supported raster graphic format.
' Return:
' The new bitmap handle
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Create a bitmap sprite object from a text using a True Type Font.
  DECLARE FUNCTION ZD_CreateBitmapFromText LIB "GDIMAGE.DLL" ALIAS "ZD_CreateBitmapFromText" ( _
  zUseText AS ASCIIZ, _                 ' The text string to convert to bitmap.
  zUseFont AS ASCIIZ, _                 ' The True Type Font to use.
  BYVAL UseSize AS LONG, _              ' The pixel size to use.
  BYVAL ColrARGB AS LONG, _             ' The ARGB color to use
  OPTIONAL BYVAL Use3D AS LONG, _       ' The shadow 3D offset.
  OPTIONAL BYVAL UseStrFormat AS LONG _ ' Not needed
  ) AS LONG
' Return:
' The bitmap handle of the new OBJECT_TEXTBITMAP.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Replace the bitmap of an existing bitmap sprite object with a new one.
  DECLARE SUB ZD_SetObjectBitmapFromBitmap LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectBitmapFromBitmap" ( _
  BYVAL hBitmap AS LONG, _     ' The new bitmap to use.
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent.
  )
' Remark:
' This is suitable to perform animation of a bitmap sprite object.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' GDImage 32-bit alphablend API to display bitmap with transparent or semitransparent pixels.
  DECLARE SUB ZI_AlphaBlendEx LIB "GDIMAGE.DLL" ALIAS "ZI_AlphaBlendEx" ( _
  BYVAL hDCDest AS LONG, _     ' Hhandle to destination DC.
  BYVAL xDest AS LONG, _       ' X-coord of upper-left corner.
  BYVAL yDest AS LONG, _       ' Y-coord of upper-left corner.
  BYVAL wDest AS LONG, _       ' Destination width.
  BYVAL hDest AS LONG, _       ' Destination height.
  BYVAL hDCSrce AS LONG, _     ' Handle to source DC.
  BYVAL xSrce AS LONG, _       ' X-coord of upper-left corner.
  BYVAL ySrce AS LONG, _       ' Y-coord of upper-left corner.
  BYVAL wSrce AS LONG, _       ' Source width.
  BYVAL hSrce AS LONG, _       ' Source height.
  BYVAL Alpha AS LONG, _       ' Alpha level in the range 0-255 (0 = transparent, 255 = opaque).
  BYVAL AngleDegree AS LONG, _ ' Rotation angle in degree.
  BYVAL Quality AS LONG _      ' Interpolation mode.
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Display the common save to file dialog providing a valid hParent and hGDImageCtrl handle.
  DECLARE FUNCTION ZI_SaveLayersDialog LIB "GDIMAGE.DLL" ALIAS "ZI_SaveLayersDialog" ( _
  BYVAL hParent AS LONG, _      ' The parent window handle.
  BYVAL hGDImageCtrl AS LONG, _ ' The GDImage control handle.
  BYVAL Quality AS LONG,  _     ' Use this for JPEG quality.
  BYVAL Orientation AS LONG, _  ' Orientation mode.
  BYVAL UseWidth AS LONG, _     ' Optional parameter to fit the image into a specific width.
  BYVAL UseHeight AS LONG _     ' Optional parameter to fit the image into a specific height.
  ) AS LONG
' Return:
' Error code in case of error, zero if succesful.
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Update the SCROLLINFO structure of a GDImage Zoom control.
  DECLARE SUB ZI_SetZoomScrollInfo LIB "GDIMAGE.DLL" ALIAS "ZI_SetZoomScrollInfo" ( _
  BYVAL hGDImageCtrl AS LONG, _   ' The GDImage control handle.
  BYVAL OldZoomValue AS SINGLE, _ ' Old zoom value
  BYVAL ZoomValue AS SINGLE _     ' New zoom value
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.00
' Set the positive or negative value of the 3D shadow offset for text and vector sprite objects.
  DECLARE SUB ZD_SetObjectUse3Dshadow LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectUse3Dshadow" ( _
  BYVAL ObjID AS LONG, _  ' The unique sprite object identifier.
  BYVAL Use3D AS LONG _   ' The positive or negative shadow offset value.
  )
' Remark:
' Negative value = shadow offset bottom left.
' Positive value = shadow offset bottom right.

' Get the sprite object 3D shadow offset.
  DECLARE FUNCTION ZD_GetObjectUse3Dshadow LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectUse3Dshadow" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The positive or negative value for the 3D shadow offset if any.
'****************************************************************************
'
'****************************************************************************
' Version 3.01
' Get the bitmap associated to a GDImage sprite OBJECT_BITMAP.
  DECLARE FUNCTION ZD_GetObjectBitmap LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectBitmap" ( _
  BYVAL ObjID AS LONG _ ' The unique sprite object identifier.
  ) AS LONG
' Return:
' The OBJECT_BITMAP handle if any.
'****************************************************************************
'
'****************************************************************************
' Version 3.01
' Resize an existing bitmap into a new one using the specificied width and height size.
  DECLARE FUNCTION ZI_ResizeBitmapFromBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_ResizeBitmapFromBitmap" ( _
  BYVAL BmpSrce AS LONG, _  ' The bitmap to duplicate.
  BYVAL UseWidth AS LONG, _ ' Width of the new bitmap to create.
  BYVAL UseHeight AS LONG _ ' Height of the new bitmap to create.
  ) AS LONG
' Return:
' A valid GDI bitmap handle, or NULL in case of error.
'****************************************************************************
'
'****************************************************************************
' Version 3.01
' Load and resize a bitmap from file into one single step.
  DECLARE FUNCTION ZI_ResizeBitmapFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_ResizeBitmapFromFile" ( _
  zFullName AS ASCIIZ, _    ' Full path name to any of the supported graphic format.
  BYVAL UseWidth AS LONG, _ ' Width of the new bitmap to create.
  BYVAL UseHeight AS LONG _ ' Height of the new bitmap to create.
  ) AS LONG
' Return:
' A valid bitmap handle or NULL in case of error.
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Enable the drawing of a rectangular section in XOR mode using the left mouse button.
  DECLARE SUB ZI_EnableCropRectangle LIB "GDIMAGE.DLL" ALIAS "ZI_EnableCropRectangle" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  )
' Remark:
' Once selected, the rectangular section can be resized.
' Once done, click on the right mouse button to pop up the contextuel menu "Select, Cancel"
' or use "double click" to validate the selection.
'
' Important:
' In case of validation, GDImage post a WM_COMMAND message to the parent owner of the control
' using a ZM_Crop notification this way:
' PostMessage(GetParent(GDImageControl), WM_COMMAND, MAKLNG(GetDlgCtrlID(GDImageControl), ZM_Crop), MenuChoice)
' The (lParam) MenuChoice = 1, means the selection has been validated.
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Disable (cancel) the drawing of a rectangular section.
  DECLARE SUB ZI_DisableCropRectangle LIB "GDIMAGE.DLL" ALIAS "ZI_DisableCropRectangle" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  )
' See also:
' ZI_EnableCropRectangle
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Disable any drawing tool.
  DECLARE SUB ZI_DisableAllTools LIB "GDIMAGE.DLL" ALIAS "ZI_DisableAllTools" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  )
' See also:
' ZI_EnableCropRectangle
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' To edit the language being used for the contextual popup menu.
  DECLARE SUB ZI_SetCropPopupText LIB "GDIMAGE.DLL" ALIAS "ZI_SetCropPopupText" ( _
  zMenu AS ASCIIZ _ ' The text of the popup menu (use "," as delimiter) ex: "Select,Cancel"
  )
' See also:
' ZI_EnableCropRectangle
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Get the coordinates of the rectangular selected area.
  DECLARE SUB ZI_GetCropCoordinates LIB "GDIMAGE.DLL" ALIAS "ZI_GetCropCoordinates" ( _
  BYREF x AS LONG, _        ' Crop X location
  BYREF y AS LONG, _        ' Crop Y location
  BYREF UseWidth AS LONG, _ ' Crop Width
  BYREF UseHeight AS LONG _ ' Crop Height
  )
' Remark:
' This must be done in the GDImage parent form,
' while you process the WM_COMMAND message to detect for the ZM_Crop notification.
' See also:
' ZI_EnableCropRectangle
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Create a bitmap matching a GDImage control selected area.
  DECLARE FUNCTION ZI_CropWindowToBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_CropWindowToBitmap"( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL x AS LONG, _            ' Crop X location
  BYVAL y AS LONG, _            ' Crop Y location
  BYVAL UseWidth AS LONG, _     ' Crop Width
  BYVAL UseHeight AS LONG _     ' Crop Height
  ) AS LONG
' Return:
' A valid GDI bitmap handle, or NULL in case of error.
' See also:
' ZI_EnableCropRectangle
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Copy a GDImage DIB into the clipboard as a compatible bitmap.
  DECLARE FUNCTION ZI_PutBitmapToClipboard LIB "GDIMAGE.DLL" ALIAS "ZI_PutBitmapToClipboard" ( _
  BYVAL ThisBitmap AS LONG _ ' A valid GDImage DIB bitmap handle
  ) AS LONG
' Return:
' A boolean True(-1) in case of succes or False(0) in case of error.
' Remark:
' The clipboard is unable to store bitmap larger than 16Gb.
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Get the TRUE or FALSE selected status of a sprite object.
  DECLARE FUNCTION ZD_GetObjectSelected LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectSelected" ( _
  BYVAL ObjID AS LONG _  ' The unique sprite object identifier.
  ) AS LONG
' Return:
' True(-1) if selected or False(0) if unselected.
' See also:
' ZD_SetObjectSelected
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Set the TRUE or FALSE selected status of a sprite object.
  DECLARE SUB ZD_SetObjectSelected LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectSelected" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL OnOff AS LONG, _       ' True = Enabled (Selected) or False = Disabled (default)
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent
  )
' See also:
' ZD_GetObjectSelected
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Clear all selected objects matching a specific GDImage control.
  DECLARE SUB ZI_ClearObjectSelected LIB "GDIMAGE.DLL" ALIAS "ZI_ClearObjectSelected" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle.
  )
' See also:
' ZD_GetObjectSelected, ZD_SetObjectSelected
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Detect if there is any selected object in a specific GDImage control.
  DECLARE FUNCTION ZI_ObjectSelected LIB "GDIMAGE.DLL" ALIAS "ZI_ObjectSelected" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle.
  ) AS LONG
' Return:
' The ID of the first selected object found.
' See also:
' ZD_GetObjectSelected, ZD_SetObjectSelected, ZI_ClearObjectSelected
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Retrieve all the properties of a GDImage sprite object in one single step.
  DECLARE SUB ZD_GetObjectProperties LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectProperties" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  zDetail AS ZOBJECT _         ' Reference to the matching ZOBJECT structure.
  )
' Remark:
' This is a low level GDImage API.
' See also:
' ZD_SetObjectProperties
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Update all the propreties of a GDImage sprite object in one single step.
  DECLARE SUB ZD_SetObjectProperties LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectProperties" ( _
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  zDetail AS ZOBJECT _         ' Reference to the matching ZOBJECT structure.
  )
' Remark:
' This is a low level GDImage API.
' See also:
' ZD_GetObjectProperties
'****************************************************************************
'
'****************************************************************************
' Version 3.02
' Flatten all layers (visible sprite objects) with respect of their z-order, into a new memory bitmap.
  DECLARE FUNCTION ZI_RenderLayersToBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_RenderLayersToBitmap" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle.
  ) AS LONG
' Return:
' The handle of the new memory bitmap.
' See also:
' ZI_RenderLayersToFile
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Low level procedure to get the Windows temp directory path.
  DECLARE FUNCTION zGetTempPath LIB "GDIMAGE.DLL" ALIAS "zGetTempPath" () AS STRING
' Return:
' The full qualified Windows temp directory path.
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Low level procedure to delete file (remove) file from disk (the file is not sent to tray).
  DECLARE FUNCTION zKillFile LIB "GDIMAGE.DLL" ALIAS "zKillFile" (zFullName AS ASCIIZ) AS LONG
' Return:
' Error code in case of error, zero if succesful.
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Move the specified file to tray.
  DECLARE FUNCTION ZI_MoveToTray LIB "GDIMAGE.DLL" ALIAS "ZI_MoveToTray"(zFullName AS ASCIIZ) AS LONG
' Return:
' Error code in case of error, zero if succesful.
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Display the GDImage dialog True Type Font Text editor.
  DECLARE FUNCTION ZI_FontBox LIB "GDIMAGE.DLL" ALIAS "ZI_FontBox" ( _
  BYVAL hParent AS LONG, _  ' The parent window handle.
  zCaption AS ASCIIZ, _     ' The font box caption.
  zUseText AS ASCIIZ, _     ' The string to edit.
  zUseFont AS ASCIIZ, _     ' The font to use.
  BYREF UseSize AS LONG, _  ' The pixel size to use.
  BYREF ColrARGB AS LONG, _ ' The ARGB color to use
  BYREF Use3D AS LONG _     ' The shadow 3D offset.
  ) AS LONG
' Return:
' Return = 2 when the user clic the "Ok" button to validate the input, any other value must be ignored.
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' To change the default Font Box parameters.
  DECLARE SUB ZI_SetFontBoxParameters LIB "GDIMAGE.DLL" ALIAS "ZI_SetFontBoxParameters" ( _
  BYVAL SquareSize AS LONG, _    ' Default 640 x 640 pixels
  BYVAL MaxFontSize AS LONG, _   ' Default 512 pixels
  BYVAL TextCharLength AS LONG _ ' Default 64 characters
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' The Crop tool status mode.
  DECLARE FUNCTION ZI_GetToolCropStatus LIB "GDIMAGE.DLL" ALIAS "ZI_GetToolCropStatus" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' True = Crop status is On, False = Crop status is false.
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Get the font string format of a text sprite object.
  DECLARE FUNCTION ZD_GetStringFormat LIB "GDIMAGE.DLL" ALIAS "ZD_GetStringFormat" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  ) AS LONG
' Return:
' A constant value, matching the current string format: ZD_TextHorzUp, ZD_TextVertUp, ZD_TextVertDn
'****************************************************************************
'
'****************************************************************************
' Version 3.50
' Set the font string format of a text sprite object.
  DECLARE SUB ZD_SetStringFormat LIB "GDIMAGE.DLL" ALIAS "ZD_SetStringFormat" ( _
  BYVAL ObjID AS LONG, _       ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYVAL StrFormat AS LONG, _   ' The constant value to use: ZD_TextHorzUp, ZD_TextVertUp, ZD_TextVertDn
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent
  )
'****************************************************************************
'
'****************************************************************************
' Version 3.51
' List of parameters
' szProfileName =  A profile name, limited to 256 characters or less. This is the profile
'                  to use when logging on. If you pass an empty string, and the flFlags
'                  parameter is set to %MAPI_LOGON_UI, MAPILogon displays a logon dialog
'                  box with an empty name field.
' szPassword    =  A credential string, limited to 256 characters or less. If the
'                  messaging system does not require password credentials, or if it
'                  requires that the user enter them, the strPassword parameter should be
'                  an empty string. When the user must enter credentials, the flFlags
'                  parameter must be set to %MAPI_LOGON_UI to allow a logon dialog box to
'                  be displayed.
' szSubject     =  Subject of the email.
' szNote        =  Email text.
' szAddresses   =  A list of email addresses separated by ;'s Make sure to put in the
'                  message type preceded by a : if it's not being delivered to an MS Mail
'                  post office. For example, if you're sending mail out to the internet
'                  via MS Mail, the mail type is SMTP. You will need to preceed the
'                  address with SMTP:
'                  e.g. "SMTP:ddickinson@usinternet.com;SMTP:ddickinson@compuserve.com"
' szFiles       =  A list of ; delimited file names (full drive letter, file path and file
'                  name must be included). If the file doesn't exist (DIR$(FileName) = "")
'                  then it will be ignored.
  DECLARE FUNCTION zSendMapiMail LIB "GDIMAGE.DLL"  ALIAS "zSendMapiMail" ( _
  szProfileName AS ASCIIZ, _
  szPassword AS ASCIIZ, _
  szSubject AS ASCIIZ, _
  szNote AS ASCIIZ, _
  szNames AS ASCIIZ, _
  szAddresses AS ASCIIZ, _
  szFiles AS ASCIIZ _
  ) AS DWORD
' Return:
' A MAPI Error code if any, and null in case of success.
'****************************************************************************
'
'****************************************************************************
' Version 3.51 (pro version only)
' Put the focus on a specific GDImage sprite object.
  DECLARE SUB ZI_SetObjectFocusID LIB "GDIMAGE.DLL" ALIAS "ZI_SetObjectFocusID" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  )
' Remark:
' Same effect that to clic with the left mouse button on a GDImage sprite object.
'****************************************************************************
'
'****************************************************************************
' Version 3.51
' Get the number of objects being used in a specific GDImage control.
  DECLARE FUNCTION ZI_GetCtrlObjectCount LIB "GDIMAGE.DLL" ALIAS "ZI_GetCtrlObjectCount" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDimage control handle.
  ) AS LONG
' Return:
' The object count.
'****************************************************************************
'
'****************************************************************************
' Version 3.51
' Get the alpha channel value of a specific GDImage object.
  DECLARE FUNCTION ZD_GetObjectAlpha LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectAlpha" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  ) AS LONG
' Return:
' The alpha channel value in the range 0-255 (0 = full transparency, 255 = full opacity).
'****************************************************************************
'
'****************************************************************************
' Version 3.51
' To create a tooltip, to be used with a GDImage control.
  DECLARE FUNCTION ZI_CreateToolTip LIB "GDIMAGE.DLL" ALIAS "ZI_CreateToolTip" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  zText AS ASCIIZ _             ' The tooltip text to display.
  ) AS LONG
' Return:
' The handle of the tooltip.
'
' Remark:
' This function must be called only once, to create the initial tooltip container.
' To change the text of the tooltip when the mouse hover a specific object, use ZI_SetToolTipText.
'
' Usualy the tooltip text matches the object label.
'****************************************************************************
'
'****************************************************************************
' Version 3.51
' To change the text of an existing GDImage control tooltip.
  DECLARE SUB ZI_SetToolTipText LIB "GDIMAGE.DLL" ALIAS "ZI_SetToolTipText" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  zText AS ASCIIZ _             ' The tooltip text to display.
  )
' Remark:
' The tooltip must have been first created with ZI_CreateToolTip.
' Usualy the tooltip text matches the object label.
' It is of the programmer's responsability to change the text of the tooltip
' when the mouse hover a specific GDImage object.
'****************************************************************************
'
'****************************************************************************
' Version 3.52
' Create a square canvas using a specific size to stretch the source bitmap into it.
' Note: a sprite always use a square size to ease further rotation computation.
  DECLARE FUNCTION ZI_CreateSpriteFileFromBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_CreateSpriteFileFromBitmap" ( _
  zFullPathName AS ASCIIZ, _      ' The full path name of the sprite graphic file to create
  BYVAL BmpSrce AS LONG, _        ' The source bitmap to create the sprite from.
  BYVAL UseSize AS LONG, _        ' The size of the sprites's canvas square (16, 32, 64, 128, 256, 512)
  BYVAL JpegQuality AS LONG _     ' In case of JPEG format, the encoding quality 1-100
  )AS LONG
' Return:
' A status error code, or null in case of success.
' Remark:
' Stretching is done using high quality bicubic interpolation.
'****************************************************************************
'
'****************************************************************************
' Version 3.52
' Open the GDImage common save dialog to select a specific folder and enter/edit the filename.
  DECLARE FUNCTION ZI_ChooseSaveFileName LIB "GDIMAGE.DLL" ALIAS "ZI_ChooseSaveFileName" ( _
  BYVAL hParent AS LONG, _        ' The parent window handle.
  zDefaultName AS ASCIIZ _        ' The default file name to edit.
  ) AS STRING
' Return:
' The full path name of the file to save.
' Remark:
' Once you have got the file name, you can use: ZI_SaveToFile
' See also:
' ZI_SaveDialog
'****************************************************************************
'
'****************************************************************************
'//3.55
' To create a variable opacity PNG file from any of the supported graphic file format.
  DECLARE FUNCTION ZI_CreateVariableOpacityPGN LIB "GDIMAGE.DLL" ALIAS "ZI_CreateVariableOpacityPGN" ( _
  zInputName AS ASCIIZ, _  ' Full path name of the input graphic file to convert.
  zOutputName AS ASCIIZ _  ' Full path name to the output PNG graphic file to create.
  ) AS LONG
' Remark:
' The zOutputName is always a PNG graphic file using the .png extension.
' Return:
' A status generic error or null if all went fine.
'****************************************************************************
'
'****************************************************************************
'//3.55
' Create a variable opacity memory bitmap, from any of the supported graphic file format.
  DECLARE FUNCTION ZI_CreateVariableOpacityBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_CreateVariableOpacityBitmap" ( _
  zInputName AS ASCIIZ, _  ' Full path name of the input graphic file source.
  imgW AS LONG, _          ' Width of the image.
  imgH AS LONG _           ' Height of the image.
  ) AS LONG
' Return:
' A valid bitmap handle or null in case of error.
'****************************************************************************
'
'****************************************************************************
'//3.55
' Add a TEXT bitmap sprite object to a GDImage control.
  DECLARE FUNCTION ZD_DrawTextBitmapToCtrl LIB "GDIMAGE.DLL" ALIAS "ZD_DrawTextBitmapToCtrl" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL x AS LONG, _                   ' The X coordinate.
  BYVAL y AS LONG, _                   ' The Y coordinate.
  BYVAL hBitmap AS LONG, _             ' The TEXT bitmap to use.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ZS_STYLE AS LONG _             ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  ) AS LONG
' Remark:
' The TEXT bitmap must have been created first using ZD_CreateBitmapFromText
' Return:
' TRUE (-1) if success, FALSE (0) if error.
'****************************************************************************
'
'****************************************************************************
' Version 4.01
' Return the number of selected object in a specific GDImage control.
  DECLARE FUNCTION ZI_SelectedCount LIB "GDIMAGE.DLL" ALIAS "ZI_SelectedCount" ( _
  BYVAL hGDImageCtrl AS LONG _ ' The GDImage control handle.
  ) AS LONG
' Return:
' The selected object Count.
' See also:
' ZD_GetObjectSelected, ZD_SetObjectSelected, ZI_ClearObjectSelected
'****************************************************************************
'
'****************************************************************************
'//3.57
' Retrieve the unique IDentifier of the first object whose bound limits are hovered by the mouse.
' Its primary purpose it to be used from a ZI_EventMessage callback.
  DECLARE FUNCTION ZI_MouseHoverBoundID LIB "GDIMAGE.DLL" ALIAS "ZI_MouseHoverBoundID" () AS LONG
' Return:
' The unique IDentifier of the matching GDImage sprite object.
'****************************************************************************
'
'****************************************************************************
'//3.57
' Create a GDIPLUS compatible 32-bit DIB DC.
  DECLARE FUNCTION ZI_Create32bitDC LIB "GDIMAGE.DLL" ALIAS "ZI_Create32bitDC" ( _
  BYVAL nWidth AS LONG, _      ' The DIB width.
  BYVAL nHeight AS LONG, _     ' The DIB height.
  BYVAL ARGBcolor AS LONG _    ' FULL ARGB color to paint the DIB background.
  ) AS LONG
' Return:
' The DC (device context) of the 32-bit DIB or NULL in case of error.
'****************************************************************************
'
'****************************************************************************
'//3.57
' Create an empty image background (Bitmap) into a GDImage control.
' Use it to perform direct drawing, everything lying out of it (overlay objects) would be clipped.
  DECLARE FUNCTION ZI_CreateImageBackgroundEx LIB "GDIMAGE.DLL" ALIAS "ZI_CreateImageBackgroundEx" ( _
  BYVAL hGDImageCtrl AS LONG, _        ' The GDImage control handle.
  BYVAL BitmapWidth AS LONG, _         ' The width of the bitmap.
  BYVAL BitmapHeight AS LONG, _        ' The Height of the bitmap.
  BYVAL UseColor AS LONG, _            ' a 24-bit RGB color or 32-bit ARGB color if BitPerPixel = 32
  BYVAL BitPerPixel AS LONG _          ' 24 or 32-bit
  ) AS LONG
' Return:
' A valid GDImage DC (ZI_GetDC) you can use to draw in.
' Note: After drawing into the provided DC, use ZI_UpdateWindow to refresh the display.
'****************************************************************************
'
'****************************************************************************
'//3.56
' Paint a sprite object onto the background of a specific GDImage control.
  DECLARE FUNCTION ZD_CopyToBackground LIB "GDIMAGE.DLL" ALIAS "ZD_CopyToBackground" ( _
  BYVAL hGDImageCtrl AS LONG, _ ' The GDimage control handle.
  BYVAL ObjID AS LONG, _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL ClearBack AS LONG, _    ' Boolean flag, use %TRUE to paint first the background with the following RGBcolor.
  BYVAL RGBColor AS LONG _      ' The RGB color to use to paint the bitmap background if ClearBack = %TRUE.
  ) AS LONG
' Return:
' None.
'****************************************************************************
'
'****************************************************************************
'//2.11
' Flip a bitmap sprite object horizontaly.
  DECLARE SUB ZD_FlipObjectX LIB "GDIMAGE.DLL" ALIAS "ZD_FlipObjectX" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  )
' Remark:
' The type of the sprite object must be: OBJECT_BITMAP or OBJECT_TEXTBITMAP exclusively.
'****************************************************************************
'
'****************************************************************************
'//2.11
' Flip a bitmap sprite object verticaly.
  DECLARE SUB ZD_FlipObjectY LIB "GDIMAGE.DLL" ALIAS "ZD_FlipObjectY" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  )
' Remark:
' The type of the sprite object must be: OBJECT_BITMAP or OBJECT_TEXTBITMAP exclusively.
'****************************************************************************
'
'****************************************************************************
'//2.11
' Rotate a bitmap sprite object by step of 90° counter clock.
  DECLARE SUB ZD_RotateObjectCounterclock90 LIB "GDIMAGE.DLL" ALIAS "ZD_RotateObjectCounterclock90" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  )
' Remark:
' The type of the sprite object must be: OBJECT_BITMAP or OBJECT_TEXTBITMAP exclusively.
'****************************************************************************
'
'****************************************************************************
'//2.11
' Rotate a bitmap sprite object by step of 90° clock wise.
  DECLARE SUB ZD_RotateObjectClockWise90 LIB "GDIMAGE.DLL" ALIAS "ZD_RotateObjectClockWise90" ( _
  BYVAL ObjID AS LONG _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  )
' Remark:
' The type of the sprite object must be: OBJECT_BITMAP or OBJECT_TEXTBITMAP exclusively.
'****************************************************************************
'
'****************************************************************************
'//3.56
' To retrieve the IDentifier of the sprite object that has captured the mouse.
  DECLARE FUNCTION ZD_ObjectMouseCaptured LIB "GDIMAGE.DLL" ALIAS "ZD_ObjectMouseCaptured" () AS LONG
' Return:
' A GDImage sprite object IDentifier or NULL if none has captured the mouse.
'****************************************************************************
'
'****************************************************************************
'//3.57
' Replace the bitmap of a specific GDImage sprite object with a new one.
' Note: it also affects this new bitmap to the related clones if any.
  DECLARE SUB ZD_ReplaceObjectBitmap LIB "GDIMAGE.DLL" ALIAS "ZD_ReplaceObjectBitmap" ( _
  BYVAL hBitmap AS LONG, _     ' The new bitmap to use.
  BYVAL ObjID AS LONG, _       ' The unique sprite object identifier.
  BYVAL RedrawParent AS LONG _ ' TRUE causes immediate redraw of the object parent.
  )
' Remark:
' The type of the sprite object must be: OBJECT_BITMAP or OBJECT_TEXTBITMAP exclusively.
'****************************************************************************
'
'****************************************************************************




' Undocumented features
' *********************
'//3.53
' To set/get the default Load Dialog file extension.
  DECLARE FUNCTION ZI_SetLoadExtension LIB "GDIMAGE.DLL" ALIAS "ZI_SetLoadExtension" ( _
  zExtension AS ASCIIZ, _  ' The file extension to use.
  BYVAL RW AS LONG _       ' TRUE = Set extension, FALSE = Read extension.
  ) AS STRING
' Remark:
' File extension must be of the form "*.PCS (PhotoComposer Script)|*.pcs"

'//3.53
' To set/get the default Save Dialog file extension.
  DECLARE FUNCTION ZI_SetSaveExtension LIB "GDIMAGE.DLL" ALIAS "ZI_SetSaveExtension" ( _
  zExtension AS ASCIIZ, _  ' The file extension to use.
  BYVAL RW AS LONG _       ' TRUE = Set extension, FALSE = Read extension.
  ) AS STRING
' Remark:
' File extension must be of the form "*.PCS (PhotoComposer Script)|*.pcs"

'//3.56
' Returns a registry string.
  DECLARE FUNCTION zGetReg LIB "GDIMAGE.DLL" ALIAS "zGetReg" (BYVAL hLocation AS DWORD, zSubKeys AS ASCIIZ, zValueName AS ASCIIZ) AS STRING

'//3.56
' Saves a string value to the registry, returns nonzero if successful.
  DECLARE FUNCTION zSetReg LIB "GDIMAGE.DLL" ALIAS "zSetReg" (BYVAL hLocation AS DWORD, zSubKeys AS ASCIIZ, zValueName AS ASCIIZ, zData AS ASCIIZ) AS LONG

'//3.56
' To check the Hidden status of a GDImage sprite object.
  DECLARE FUNCTION ZD_IsObjectHidden LIB "GDIMAGE.DLL" ALIAS "ZD_IsObjectHidden" ( _
  BYVAL ObjID AS LONG _         ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG
' See also:
' ZD_SetObjectHidden

'//3.56
' Set the HIDDEN state of a GDImage sprite object.
  DECLARE SUB ZD_SetObjectHidden LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectHidden" ( _
  BYVAL ObjID AS LONG, _        ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL OnOff AS LONG _         ' Boolean TRUE / FALSE condition.
  )
' Remark:
' Hidden state should not be confused with the Visibility state.
' This is a low level feature being used to draw Hollow sprite objects.
' Such object can be used to follow or replace the mouse cursor.
' See also:
' ZD_IsObjectHidden.

'//3.57
' Create a GDIPLUS image attribute to remap a specific ARGB color from one color to another.
  DECLARE FUNCTION ZI_RemapImageColor LIB "GDIMAGE.DLL" ALIAS "ZI_RemapImageColor" ( _
  BYVAL nColorFrom AS LONG, _  ' Previous ARGB color to remap .
  BYVAL nColorTo AS LONG _     ' New ARGB color to use.
  ) AS LONG
' Return:
' A GDIPLUS ImageAttribute

'//3.57
' Create a GDIPLUS image attribute to remap a specific ARGB color along the full alpha channel range (0-255).
  DECLARE FUNCTION ZI_RemapAlphaColor LIB "GDIMAGE.DLL" ALIAS "ZI_RemapAlphaColor" ( _
  BYVAL nColorFrom AS LONG, _  ' Previous ARGB color to remap .
  BYVAL nColorTo AS LONG _     ' New ARGB color to use.
  ) AS LONG
' Return:
' A GDIPLUS ImageAttribute

''//3.57
'' Fills a rectangle using a specific 32-bit ARGB color.
'  DECLARE SUB ZI_PaintBrushBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_PaintBrushBitmap" ( _
'  BYVAL hDC AS LONG, _        ' A valid 32-bit DC
'  BYVAL x AS LONG, _          ' The top left horizontal coordinate of the rectangle
'  BYVAL y AS LONG, _          ' The top left vertical coordinate of the rectangle
'  BYVAL xW AS LONG, _         ' The rectangle width
'  BYVAL yH AS LONG, _         ' The rectangle height
'  BYVAL ARGBcolor AS LONG _   ' The ARGB color to use
'  )

'// 4.02 SpritePlus set bit array to handle event message
' Monitor the Windows message flow using a callback to take control over the GDImage default procedure.
  DECLARE SUB ZI_EventMessageEx LIB "GDIMAGE.DLL" ALIAS "ZI_EventMessageEx" ( _
  BYVAL hWnd AS LONG, _        ' The GDimage control handle.
  BYVAL pCodePtr AS DWORD, _   ' Pointer to a MyCallback function (see remark below).
  BYVAL WM_Message AS LONG, _  ' The Windows message to filter.
  BYVAL SetReset AS LONG _     ' TRUE = enable, FALSE = disable callback for the specific message.
  )
' Remark:
' FUNCTION MyCallBack( _       ' Use any name, and provide its code pointer to ZI_EventMessage
' BYVAL hWnd AS LONG, _        ' The GDImage control handle sending the event.
' BYVAL Msg AS LONG, _         ' Any standard Windows message.
' BYVAL wParam AS LONG, _      ' The contents of this parameter depend on the value of the Msg parameter.
' BYVAL lParam AS LONG _       ' The contents of this parameter depend on the value of the Msg parameter.
' ) AS LONG                    ' See MSDN documentation about using a WindowProc function.
'
' Important:
' If you want to stop further processing of the message by GDImage, then the callback function must return TRUE.

'///////////////////////////////////////////////////////////////////////////////////////////////////////////////

'//4.03
'  Create a GDImage animated clock control
   DECLARE FUNCTION zClockCtrl LIB "GDIMAGE.DLL" ALIAS "zClockCtrl" ( _
   BYVAL hOwner AS LONG, _            ' Handle of the window parent owner.
   zFullpathImageName AS ASCIIZ, _    ' Full path name to the clock image background.
   BYVAL x AS LONG, _                 ' X location of the clock control.
   BYVAL y AS LONG, _                 ' Y location of the clock control.
   BYVAL W AS LONG, _                 ' Width of the clock control.
   BYVAL H AS LONG, _                 ' Height of the clock control.
   BYVAL ButID AS LONG, _             ' Unique ID of the clock control.
   BYVAL ARGB1 AS LONG, _             ' The color to draw the Hour/Minute hands.
   BYVAL ARGB2 AS LONG, _             ' The color to draw the second hands.
   OPTIONAL BYVAL GMToffset AS LONG _ ' The GMT offset to be used.
   ) AS LONG
   %DISABLE_TIMER = 99 '// Use this value in the optional GMToffset parameter to disable local timer in case of animated background
 
'//4.05
' Useful to embend an image into a fixed size square to perform image rotation from the center
' Example 512 x 512 or 1024 x 1024 or 2048 x 2048 or 1024 x 512 (for texture creation)
  DECLARE FUNCTION ZI_FitBitmapFromFile LIB "GDIMAGE.DLL" ALIAS "ZI_FitBitmapFromFile" ( _
  zFullPath AS ASCIIZ, _       ' Full path name to image
  BYVAL Xin AS LONG, _         ' Width of the container
  BYVAL Yin AS LONG _          ' Height of the container
  ) AS LONG
  
' Paper size 152 x 102 or 233 x 152  
  DECLARE FUNCTION ZI_FitImageToPaper LIB "GDIMAGE.DLL" ALIAS "ZI_FitImageToPaper" ( _
  zImageSrce AS ASCIIZ, _      ' Full path to image source
  BYVAL nPaperW AS LONG, _     ' paper width in mm
  BYVAL nPaperH AS LONG, _     ' paper height in mm
  zCropedImageDest AS ASCIIZ _ ' Full path to the resulting croped image
  ) AS LONG

' Effects

'//4.05
  DECLARE FUNCTION ZD_GetObjectBrightness LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectBrightness" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectBrightness LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectBrightness" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL Brightness AS LONG, _          ' The brightness level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
  DECLARE FUNCTION ZD_GetObjectContrast LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectContrast" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectContrast LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectContrast" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL Contrast AS LONG, _            ' The contrast level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
  DECLARE FUNCTION ZD_GetObjectRed LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectRed" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectRed LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectRed" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nRed AS LONG, _                ' The red level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
  DECLARE FUNCTION ZD_GetObjectGreen LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectGreen" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectGreen LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectGreen" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nGreen AS LONG, _              ' The green level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
  DECLARE FUNCTION ZD_GetObjectBlue LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectBlue" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectBlue LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectBlue" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nBlue AS LONG, _               ' The blue level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
  DECLARE FUNCTION ZD_GetObjectHue LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectHue" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'//4.05
  DECLARE SUB ZD_SetObjectHue LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectHue" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nHue AS LONG, _                ' The Hue level in the range (range 0-255, 0 = default).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//4.05
' Apply the effects to an object bitmap.
  DECLARE FUNCTION ZD_RenderEffectToBitmapObject LIB "GDIMAGE.DLL" ALIAS "ZD_RenderEffectToBitmapObject" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  ) AS LONG
' Return:
' The new object bitmap handle.

'//4.05
  DECLARE FUNCTION ZI_CreateBitmapFromImage LIB "GDIMAGE.DLL" ALIAS "ZI_CreateBitmapFromImage" ( _
  BYVAL hImage AS LONG _               ' The GDIPLUS image handle to convert into a GDI32 bitmap handle
  ) AS LONG
' Return:
' A GDI32 bitmap handle.

'//4.05
  DECLARE FUNCTION ZI_IsAnyArrowPressed LIB "GDIMAGE.DLL" ALIAS "ZI_IsAnyArrowPressed" () AS LONG

'//4.05
  DECLARE FUNCTION ZI_ApplyEffectToFile LIB "GDIMAGE.DLL" ALIAS "ZI_ApplyEffectToFile" ( _
  zImageSrce AS ASCIIZ, _
  zDetail AS ZOBJECT, _         ' Reference to the matching ZOBJECT structure.
  zImageDest AS ASCIIZ _
  ) AS LONG

'//4.05 Create a Disabled Window that works with any control created directly with the API
' This creates a layered transparent window hover the window you want to disable.
'//5.05
  DECLARE FUNCTION ZI_CreateDW LIB "GDIMAGE.DLL" ALIAS "ZI_CreateDW" ( _
  BYVAL hParent AS LONG _
  ) AS LONG

'//5.05 Removed (see ZI_CreateDW)
'//4.05 Show an existing Disabled Window
  'DECLARE SUB ZI_ShowDW LIB "GDIMAGE.DLL" ALIAS "ZI_ShowDW"( _
  'BYVAL hDW AS LONG _
  ')

'//5.05 Removed (see ZI_DestroyDW)
'//4.05 Hide an existing Disabled Window
  'DECLARE SUB ZI_HideDW LIB "GDIMAGE.DLL" ALIAS "ZI_HideDW" ( _
  'BYVAL hDW AS LONG _
  ')

'//4.06 Paint image in tiling mode
  DECLARE SUB ZI_ImageTilePaint LIB "GDIMAGE.DLL" ALIAS "ZI_ImageTilePaint" ( _
  BYVAL graphics AS LONG, _
  BYVAL Img AS LONG, _
  BYVAL xOffset AS LONG, _
  BYVAL yOffset AS LONG, _
  BYVAL nPaintWidth AS LONG, _
  BYVAL nPaintHeight AS LONG _
  )

''//4.06 Computes location and size to stretch a bitmap preserving its aspect.
'  DECLARE SUB ZI_ComputeAspect LIB "GDIMAGE.DLL" ALIAS "ZI_ComputeAspect" ( _
'  BYVAL xPicSize AS LONG, _
'  BYVAL yPicSize AS LONG, _
'  BYVAL xCell AS LONG, _
'  BYVAL yCell AS LONG, _
'  BYREF xPos AS LONG, _
'  BYREF yPos AS LONG, _
'  BYREF xSize AS LONG, _
'  BYREF ySize AS LONG _
'  )

'//4.06 Create a Skin background matching a specific size
  DECLARE FUNCTION ZI_CreateSkinBackground LIB "GDIMAGE.DLL" ALIAS "ZI_CreateSkinBackground" ( _
  zImageDest AS ASCIIZ, _
  BYVAL rwX AS LONG, _
  BYVAL rwY AS LONG, _
  zUseBackground AS ASCIIZ, _
  zSkinFolder AS ASCIIZ _
  ) AS LONG

'//4.07 To perform self image rotation
'// %Rotate90FlipNone = 1
'// %Rotate180FlipNone = 2
'// %Rotate270FlipNone = 3
'// %RotateNoneFlipX = 4
'// %Rotate90FlipX = 5
'// %Rotate180FlipX = 6
'// %Rotate270FlipX = 7
  DECLARE FUNCTION ZI_SetImageFileOrientation LIB "GDIMAGE.DLL" ALIAS "ZI_SetImageFileOrientation" ( _
  zImageSrce AS ASCIIZ, _
  BYVAL Orientation AS LONG _
  ) AS LONG

  DECLARE FUNCTION ZI_SetImageAlpha LIB "GDIMAGE.DLL" ALIAS "ZI_SetImageAlpha" ( _
  BYVAL Alpha AS LONG _
  ) AS LONG
' Return:
' A valid GDIPLUS image attribute.
  
'//4.08
  DECLARE FUNCTION ZI_SetImageAttributesHue LIB "GDIMAGE.DLL" ALIAS "ZI_SetImageAttributesHue" ( _
  BYVAL nHue AS LONG _
  ) AS LONG  
' Return:
' A valid GDIPLUS image attribute.

' To convert a GDI32 bitmap into a GDIPLUS image, based on a provided DC matching the GDI32 bitmap
  DECLARE FUNCTION zBitmapToImage LIB "GDIMAGE.DLL" ALIAS "zBitmapToImage" ( _
  BYVAL hDC AS LONG _
  ) AS LONG
' Return:
' A GDIPLUS image handle

' To create a GDI32 DIB section
  DECLARE FUNCTION ZI_CreateDIBSection LIB "GDIMAGE.DLL" ALIAS "ZI_CreateDIBSection" ( _
  BYVAL hDC AS LONG, _
  BYVAL nWidth AS LONG, _
  BYVAL nHeight AS LONG, _
  BYVAL BitCount AS LONG _
  ) AS LONG

' To convert a RGB value into shade of gray.
  DECLARE FUNCTION Rgb2Gray LIB "GDIMAGE.DLL" ALIAS "Rgb2Gray" ( _
  BYVAL RGBValue AS DWORD _
  ) AS DWORD

' GDImage encapsulation of GDI32 Alphablend API
  DECLARE SUB zAlphaBlend LIB "GDIMAGE.DLL" ALIAS "zAlphaBlend" ( _
  BYVAL hDcDest AS LONG, _
  BYVAL xDest AS LONG, _
  BYVAL yDest AS LONG, _
  BYVAL wDest AS LONG, _
  BYVAL hDest AS LONG, _
  BYVAL hDcSrce AS LONG, _
  BYVAL xSrce AS LONG, _
  BYVAL ySrce AS LONG, _
  BYVAL wSrce AS LONG, _
  BYVAL hSrce AS LONG _
  )

' GDImage 32-bit Alphablend API
  DECLARE SUB ZI_AlphaBlend LIB "GDIMAGE.DLL" ALIAS "ZI_AlphaBlend" ( _
  BYVAL hDCDest AS LONG, _
  BYVAL xDest AS LONG, _
  BYVAL yDest AS LONG, _
  BYVAL nWidth AS LONG, _
  BYVAL nHeight AS LONG, _
  BYVAL hDCSrce AS LONG, _
  BYVAL xCurrentScroll AS LONG, _
  BYVAL yCurrentScroll AS LONG _
  )

'//4.09
  TYPE ZGLTEXTUREX
      ID       AS LONG
      FullName AS ASCIIZ * 260
      Texture  AS LONG
      Square   AS LONG            '// boolean TRUE or FALSE value 
  END TYPE
  
'//4.09
  DECLARE SUB ZI_MakeMultipleTexture LIB "GDIMAGE.DLL" ALIAS "ZI_MakeMultipleTexture" ( _
  BYVAL tp AS ZGLTEXTUREX PTR, _
  BYVAL N AS LONG _
  )

'//4.09
  DECLARE FUNCTION ZI_CreateGLTextureFromFileEX LIB "GDIMAGE.DLL" ALIAS "ZI_CreateGLTextureFromFileEX" ( _
  zFullPath AS ASCIIZ, _
  Xin AS LONG, _
  Yin AS LONG, _
  PixelArray() AS BYTE, _
  BYVAL SquareTexture AS LONG _
  ) AS LONG

'//4.11
  DECLARE FUNCTION ZI_CenterDialog LIB "GDIMAGE.DLL" ALIAS "ZI_CenterDialog" ( _
  BYVAL nFlag AS LONG, _
  BYVAL RW AS LONG _
  ) AS LONG

'//4.14
  DECLARE FUNCTION ZD_ARGB LIB "GDIMAGE.DLL" ALIAS "ZD_ARGB" ( _
  BYVAL A AS BYTE, _
  BYVAL R AS BYTE, _
  BYVAL G AS BYTE, _
  BYVAL B AS BYTE _
  ) AS LONG

'//4.14
  DECLARE FUNCTION ZI_ImageFromResource LIB "GDIMAGE.DLL" ALIAS "ZI_ImageFromResource" ( _
  BYVAL nInstance AS LONG, _
  zName AS ASCIIZ _
  ) AS LONG

'//4.14
  DECLARE SUB ZI_RemoveRedEye LIB "GDIMAGE.DLL" ALIAS "ZI_RemoveRedEye" ( _
  BYVAL hDC AS LONG, _
  BYVAL x AS LONG, _
  BYVAL y AS LONG, _
  BYVAL UseWidth AS LONG, _
  BYVAL UseHeight AS LONG _
  )

'//4.14
  DECLARE SUB ZD_RemoveRedEyeFromBitmapObject LIB "GDIMAGE.DLL" ALIAS "ZD_RemoveRedEyeFromBitmapObject" ( _
  BYVAL nObjectID AS LONG, _
  BYVAL x AS LONG, _
  BYVAL y AS LONG, _
  BYVAL UseWidth AS LONG, _
  BYVAL UseHeight AS LONG _
  )

'//4.14
' Enable red eye crop selection
  DECLARE SUB ZI_EnableCropRedEye LIB "GDIMAGE.DLL" ALIAS "ZI_EnableCropRedEye" ( _
  BYVAL hWnd AS LONG _
  )

'//4.15
  DECLARE SUB zDrawImage LIB "GDIMAGE.DLL" ALIAS "zDrawImage" ( _
  BYVAL hDC AS LONG, _      ' A Windows DC (do not use ZI_GetDC except if you want to paint over the image)
  BYVAL Img AS LONG, _      ' A valid GDImage - GDIPLUS handle.
  BYVAL x AS LONG, _        ' The top left corner horizontal location
  BYVAL y AS LONG, _        ' The top left corner vertical location
  BYVAL xW AS LONG, _       ' The width
  BYVAL yH AS LONG _        ' The height
  )

'// 4.16 To create a composited rectangle object
  DECLARE SUB ZI_CreateRectangleObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateRectangleObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL x AS LONG, _                   ' Top left X coordinate.
  BYVAL y AS LONG, _                   ' Top left Y coordinate.
  BYVAL xWidth AS LONG, _              ' Rectangle width.
  BYVAL yHeight AS LONG, _             ' Rectangle height.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL BorderSize AS LONG, _          ' Size of the border (can be NULL).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  )
' GDImage Drawing STYLE                  Drawing mode:
' ---------------------                  -------------
' %ZD_DRAW_OUTLINE                       Border only (frame mode)
' %ZD_DRAW_FILLED                        Fill mode
' %ZD_DRAW_3DIN                          Fill with 3D-IN effect
' %ZD_DRAW_3DOUT                         Fill with 3D_Out effect

'// 4.16 To create a composited bitmap object
  DECLARE SUB ZI_CreateBitmapObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateBitmapObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL x AS LONG, _                   ' Top left X coordinate.
  BYVAL y AS LONG, _                   ' Top left Y coordinate.
  BYVAL hBitmap AS LONG, _             ' Bitmap handle.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL ZS_STYLE AS LONG _             ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  )

'// 4.16 To create a composited text object
  DECLARE SUB ZI_CreateTextObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateTextObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  zUseText AS ASCIIZ, _                ' The text to display
  BYVAL x AS LONG, _                   ' Top left X coordinate.
  BYVAL y AS LONG, _                   ' Top left Y coordinate.
  BYVAL xWidth AS LONG, _              ' Rectangle width.
  BYVAL yHeight AS LONG, _             ' Rectangle height.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  zUseFont AS ASCIIZ, _                ' The "Tue Type Font" name to use
  BYVAL UseSize AS LONG, _             ' The size of the font in pixel
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL Use3D AS LONG, _               ' The shadow 3D offset
  BYVAL UseStrFormat AS LONG _         ' Any of the %StringAlignment below 
  )
  %StringAlignmentNear = 0
  %StringAlignmentCenter = 1
  %StringAlignmentFar = 2

'// 4.16 To create a composited arrow object
  DECLARE SUB ZI_CreateArrowObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateArrowObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL SeedX AS LONG, _               ' Swap SeedX and TargetX to select arrow orientation.
  BYVAL SeedY AS LONG, _               ' Swap SeedY and TargetY to select arrow orientation.
  BYVAL TargetX AS LONG, _             ' Swap TargetX and SeedX to select arrow orientation.
  BYVAL TargetY AS LONG, _             ' Swap TargetY and SeedY to select arrow orientation.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL BorderSize AS LONG, _          ' Size of the border (can be NULL).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE.
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  )

'// 4.16 To create a composited ellipse object
  DECLARE SUB ZI_CreateEllipseObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateEllipseObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL TopLeftX AS LONG, _            ' The top X of the rectangular region matching the ellipse size.
  BYVAL TopLeftY AS LONG, _            ' The top Y of the rectangular region matching the ellipse size.
  BYVAL BottomRightX AS LONG, _        ' The bottom X of the rectangular region matching the ellipse size.
  BYVAL BottomRightY AS LONG, _        ' The bottom Y of the rectangular region matching the ellipse size.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL BorderSize AS LONG, _          ' Size of the border (can be NULL).
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE.
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  )

'// 4.16 To create a composited curve object
  DECLARE SUB ZI_CreateCurveObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreateCurveObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL pXY AS POINTS PTR, _           ' Pointer to an ARRAY of POINTS (holding x,y coordinates of each point).
  BYVAL ArraySize AS LONG, _           ' UBOUND - LBOUND + 1 = number of point in the array.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL PenSize AS LONG, _             ' Size of the pen.
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  )

'// 4.16 To create a composited PolyLine object
  DECLARE SUB ZI_CreatePolyLineObject LIB "GDIMAGE.DLL" ALIAS "ZI_CreatePolyLineObject" ( _
  zDetail AS ZOBJECT, _                ' Reference to the matching ZOBJECT structure.
  BYVAL pXY AS POINTS PTR, _           ' Pointer to an ARRAY of POINTS (holding x,y coordinates of each point).
  BYVAL ArraySize AS LONG, _           ' UBOUND - LBOUND + 1 = number of point in the array.
  BYVAL ColrARGB AS LONG, _            ' The ARGB color to use.
  BYVAL PenSize AS LONG, _             ' Size of the pen.
  BYVAL ZS_STYLE AS LONG, _            ' The object Generic STYLE (use at least %ZS_VISIBLE to show it).
  BYVAL ZD_STYLE AS LONG, _            ' The object Drawing STYLE (see below).
  OPTIONAL BYVAL Use3D AS LONG _       ' The shadow 3D offset.
  )

'// 4.16 To create a composited image
  DECLARE FUNCTION ZI_CreateImageComposited LIB "GDIMAGE.DLL" ALIAS "ZI_CreateImageComposited" ( _
  zImageDest AS ASCIIZ, _              ' Name of the file to save the resulting composited image: 
  BYVAL xW AS LONG, _                  ' Bound Width of the resulting composited image.
  BYVAL yH AS LONG, _                  ' Bound Height of the resulting composited image.
  BYVAL pSprite AS ZOBJECT PTR, _      ' Pointer to the ZOBJECT array structure
  BYVAL N AS LONG _                    ' The ZOBJECT array count.
  ) AS LONG
' Note: 
' If zImageDest is NULL then the function returns a bitmap handle, 
' then the calling application is responsible to delete the bitmap handle.

'// 4.16
' Get the number of frames embedded into the image list object.
  DECLARE FUNCTION ZD_GetObjectFrameCount LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectFrameCount" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'// 4.16
' Set the number of frames embedded into the image list object.
  DECLARE SUB ZD_SetObjectFrameCount LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectFrameCount" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nCount AS LONG _               ' The horizontal image list count
  )

'// 4.16
' Get the range of the current active frame into the image list object.
  DECLARE FUNCTION ZD_GetObjectFrameToUse LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectFrameToUse" ( _
  BYVAL ObjID AS LONG _                ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  ) AS LONG

'// 4.16
' Set the range of the current active frame into the image list object.
  DECLARE SUB ZD_SetObjectFrameToUse LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectFrameToUse" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one).
  BYVAL nImageToUse AS LONG, _         ' The image to use in the list.
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'// 4.16
' Low level drawing API allowing to use the full range of GDImage ZOBJECT color settings attributes.
  DECLARE SUB ZI_RenderAttributes LIB "GDIMAGE.DLL" ALIAS "ZI_RenderAttributes" ( _
  BYVAL hDCdest AS LONG, _    ' Handle to destination DC.
  BYVAL xDest AS LONG, _      ' X-coord of destination upper-left corner.
  BYVAL yDest AS LONG, _      ' Y-coord of destination upper-left corner.
  BYVAL DestWidth AS LONG, _  ' Width of destination rectangle.
  BYVAL DestHeight AS LONG, _ ' Height of destination rectangle.
  BYVAL hDCsrce AS LONG, _    ' Handle to source DC.
  BYVAL xSrce AS LONG, _      ' X-coord of source upper-left corner.
  BYVAL ySrce AS LONG, _      ' Y-coord of source upper-left corner.
  BYVAL SrceWidth AS LONG, _  ' Width of source rectangle.
  BYVAL SrceHeight AS LONG, _ ' Height of source rectangle.
  BYVAL nAlpha AS LONG, _     ' 0-255 Alpha channel value, use 255 = opaque 
  zObjItem AS ZOBJECT _       ' To use extended GDImage attrivutes
  )

'// 5.00
  DECLARE SUB GL_DrawCup LIB "GDIMAGE.DLL" ALIAS "GL_DrawCup" ( _
  BYVAL sRadius AS SINGLE, _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawDome LIB "GDIMAGE.DLL" ALIAS "GL_DrawDome" ( _
  BYVAL sRadius AS SINGLE, _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCylinder LIB "GDIMAGE.DLL" ALIAS "GL_DrawCylinder" ( _
  BYVAL Radius AS SINGLE, _
  BYVAL Value AS SINGLE, _
  BYVAL R1 AS SINGLE, _
  BYVAL R2 AS SINGLE, _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawDisk LIB "GDIMAGE.DLL" ALIAS "GL_DrawDisk" ( _
  BYVAL sRadius AS SINGLE, _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawSphere LIB "GDIMAGE.DLL" ALIAS "GL_DrawSphere" ( _
  BYVAL sRadius AS SINGLE, _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeFrontFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeFrontFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeBackFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeBackFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeTopFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeTopFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeBottomFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeBottomFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeRightFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeRightFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCubeLeftFace LIB "GDIMAGE.DLL" ALIAS "GL_DrawCubeLeftFace" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_DrawCube LIB "GDIMAGE.DLL" ALIAS "GL_DrawCube" ( _
  BYVAL nTexture AS LONG _    ' The texture to use, or 0 to use the current one. 
  )

'// 5.00
  DECLARE SUB GL_CreateContext LIB "GDIMAGE.DLL" ALIAS "GL_CreateContext" ( _
  BYVAL nWidth AS LONG, _      ' The DIB bitmap width.
  BYVAL nHeight AS LONG _      ' The DIB bitmap height.
  )
' See also: GL_DeleteContext

'// 5.00
  DECLARE FUNCTION GL_GLDC LIB "GDIMAGE.DLL" ALIAS "GL_GLDC" () AS LONG
' Return: The GDImage DIB DC.

'// 5.00
  DECLARE FUNCTION GL_GLRC LIB "GDIMAGE.DLL" ALIAS "GL_GLRC" ()  AS LONG
' Return: The OpenGL Rendering Context.

'// 5.00
' To delete all resources created with GL_CreateContext.
  DECLARE SUB GL_DeleteContext LIB "GDIMAGE.DLL" ALIAS "GL_DeleteContext" ( _
  BYREF hGLDC AS LONG, _
  BYREF hGLRC AS LONG _
  )

'// 5.00
  DECLARE SUB GL_AlphaBlend LIB "GDIMAGE.DLL" ALIAS "GL_AlphaBlend" ( _
  BYVAL hDcDest AS LONG, _
  BYVAL hDcSrce AS LONG _
  )

'// 5.00
  DECLARE FUNCTION GL_CreateDrawingDC LIB "GDIMAGE.DLL" ALIAS "GL_CreateDrawingDC" ( _
  BYVAL nWidth AS LONG, _      ' The DIB width.
  BYVAL nHeight AS LONG _      ' The DIB height.
  ) AS LONG

'// 5.00
  DECLARE FUNCTION ZD_ComputeObjectAngleFromPoint LIB "GDIMAGE.DLL" ALIAS "ZD_ComputeObjectAngleFromPoint" ( _
  BYVAL ObjID AS LONG, _
  BYVAL x AS LONG, _
  BYVAL y AS LONG _
  ) AS LONG

'// 5.00
  DECLARE SUB ZI_DestroyDW LIB "GDIMAGE.DLL" ALIAS "ZI_DestroyDW" ( _
  BYREF hDW AS LONG _          ' The Disabled Window handle to destroy
  )

'//5.00
  DECLARE FUNCTION ZI_CreateImageFromBitmap LIB "GDIMAGE.DLL" ALIAS "ZI_CreateImageFromBitmap" ( _
  BYVAL hBmp AS LONG _
  ) AS LONG

'//Change in version 5.00
' No more need to use ZD_UsePngOpacity to use ALPHA channel.
' OpenGL 3D primitives.
' Sprite multi-state.
' Create a composited bitmap directly in memory.

'//5.01
' To anchor a specific GDImage sprite object.
' Note: it uses a limited subset of the %ANCHOR flags,
'       because you can't change the width or the height of a sprite object with any of %ANCHOR_WIDTH or %ANCHOR_HEIGHT
  DECLARE FUNCTION ZD_SetObjectAnchorMode LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectAnchorMode" ( _
  BYVAL nObjID AS LONG, _
  BYVAL AnchorMode AS LONG _
  ) AS LONG

'//////////////////////////////////////////////////////////////////////////////////////////
' Undocumented features

'//5.02
' Get the frame count of a GDIPLUS image. 
  DECLARE FUNCTION ZI_GetImageFrameCount LIB "GDIMAGE.DLL" ALIAS "ZI_GetImageFrameCount" ( _
  BYVAL Img AS LONG _       ' A valid GDImage - GDIPLUS handle.
  ) AS LONG

'//5.02
' Convert a multi-frame GDIPLUS image, into a multi-state GDImage.
  DECLARE FUNCTION ZI_CreateMultiFrameImage LIB "GDIMAGE.DLL" ALIAS "ZI_CreateMultiFrameImage" ( _
  BYVAL Img AS LONG, _      ' A valid GDImage - GDIPLUS handle.
  BYVAL nUseBit AS LONG, _  ' Either 24 or 32-bit.
  BYVAL nFit AS LONG _      ' To use square frames suitable to perform image rotation. 
  ) AS LONG

'//5.03
  DECLARE FUNCTION ZD_GetObjectLinked LIB "GDIMAGE.DLL" ALIAS "ZD_GetObjectLinked" ( _
  BYVAL nObjID AS LONG _
  ) AS LONG

'//5.03
  DECLARE SUB ZD_SetObjectLinked LIB "GDIMAGE.DLL" ALIAS "ZD_SetObjectLinked" ( _
  BYVAL nObjID AS LONG, _
  BYVAL LinkedID AS LONG _
  )

'//5.04
' This API works like ZD_SetObjectXY, 
' however its mains purpose is to move linked objects with the keyboard in a GDImageCallback
  DECLARE SUB ZD_MoveLinkedObject LIB "GDIMAGE.DLL" ALIAS "ZD_MoveLinkedObject" ( _
  BYVAL ObjID AS LONG, _               ' The unique object IDentifier (each object MUST USE A UNIQUE one)
  BYVAL x AS LONG, _                   ' The X coordinate
  BYVAL y AS LONG, _                   ' The Y coordinate
  BYVAL RedrawParent AS LONG _         ' TRUE causes immediate redraw of the object parent.
  )

'//5.06
' Assign a new texture to an existing OpenGL "Named texture".
  DECLARE FUNCTION ZI_UpdateNamedGLTextureFromFileEx LIB "GDIMAGE.DLL" ALIAS "ZI_UpdateNamedGLTextureFromFileEx" ( _
  zFullName AS ASCIIZ, _        ' Full qualified path name.
  BYVAL NamedTexture AS LONG, _ ' An existing OpenGL NamedTexture
  BYVAL SquareMode AS LONG _    ' The square mode to use
  ) AS LONG
' Return:
' An OpenGL error code in case of Error.

  DECLARE FUNCTION ZI_LoadDLL LIB "GDIMAGE.DLL" ALIAS "ZI_LoadDLL" (zUserName AS ASCIIZ) AS LONG
