⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdimage.inc

📁 Powerbasic 对GDI 的操作 很漂亮的代码!
💻 INC
📖 第 1 页 / 共 5 页
字号:
' (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_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&, _        ' The RGB color to replace
  BYVAL NewRGBColor& _         ' 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" ( _

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -