Jump to content

Search the Community

Showing results for tags 'Graphic'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 14 results

  1. Here a first draft for creating barcodes using the Zint.dll (v2.15.09). Mor information about Zint can be found here: https://zint.org.uk Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All historical versions are distributed under the GNU General Public License version 3 or later. Version 2.5 (and later) is released under a dual license: the encoding library is released under the BSD license whereas the GUI, Zint Barcode Studio, is released under the GNU General Public License version 3 or later. The code became too long to post here! -> Download from my OneDrive: Zint Zint.au3 ;Coded by UEZ ;v0.60 build 2025-09-14 beta ;IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name! ; Distributing copies of the program in compiled format (exe) must be free of any fee! #include-once #include "ZintDll.au3" Global $g__ZintDLL = @AutoItX64 ? (@ScriptDir & "\Zint64.dll") : (@ScriptDir & "\Zint.dll") #Region Constances ; === Barcode Symbologies === Global Const $BARCODE_CODE11 = 1 ; Code 11 Global Const $BARCODE_C25STANDARD = 2 ; 2 of 5 Standard (Matrix) Global Const $BARCODE_C25MATRIX = 2 ; Legacy Global Const $BARCODE_C25INTER = 3 ; 2 of 5 Interleaved Global Const $BARCODE_C25IATA = 4 ; 2 of 5 IATA Global Const $BARCODE_C25LOGIC = 6 ; 2 of 5 Data Logic Global Const $BARCODE_C25IND = 7 ; 2 of 5 Industrial Global Const $BARCODE_CODE39 = 8 ; Code 39 Global Const $BARCODE_EXCODE39 = 9 ; Extended Code 39 Global Const $BARCODE_EAN8 = 10 ; EAN-8 (GTIN-8) Global Const $BARCODE_EAN_2ADDON = 11 ; EAN/UPC 2-digit add-on Global Const $BARCODE_EAN_5ADDON = 12 ; EAN/UPC 5-digit add-on Global Const $BARCODE_EANX = 13 ; Legacy Global Const $BARCODE_EANX_CHK = 14 ; Legacy Global Const $BARCODE_EAN13 = 15 ; EAN-13 (GTIN-13) Global Const $BARCODE_GS1_128 = 16 ; GS1-128 Global Const $BARCODE_EAN128 = 16 ; Legacy Global Const $BARCODE_CODABAR = 18 ; Codabar Global Const $BARCODE_CODE128 = 20 ; Code 128 Global Const $BARCODE_DPLEIT = 21 ; Deutsche Post Leitcode Global Const $BARCODE_DPIDENT = 22 ; Deutsche Post Identcode Global Const $BARCODE_CODE16K = 23 ; Code 16k Global Const $BARCODE_CODE49 = 24 ; Code 49 Global Const $BARCODE_CODE93 = 25 ; Code 93 Global Const $BARCODE_FLAT = 28 ; Flattermarken Global Const $BARCODE_DBAR_OMN = 29 ; GS1 DataBar Omnidirectional Global Const $BARCODE_RSS14 = 29 ; Legacy Global Const $BARCODE_DBAR_LTD = 30 ; GS1 DataBar Limited Global Const $BARCODE_RSS_LTD = 30 ; Legacy Global Const $BARCODE_DBAR_EXP = 31 ; GS1 DataBar Expanded Global Const $BARCODE_RSS_EXP = 31 ; Legacy Global Const $BARCODE_TELEPEN = 32 ; Telepen Alpha Global Const $BARCODE_UPCA = 34 ; UPC-A Global Const $BARCODE_UPCA_CHK = 35 ; UPC-A including check digit Global Const $BARCODE_UPCE = 37 ; UPC-E Global Const $BARCODE_UPCE_CHK = 38 ; UPC-E including check digit Global Const $BARCODE_POSTNET = 40 ; USPS POSTNET Global Const $BARCODE_MSI_PLESSEY = 47 ; MSI Plessey Global Const $BARCODE_FIM = 49 ; Facing Identification Mark Global Const $BARCODE_LOGMARS = 50 ; LOGMARS Global Const $BARCODE_PHARMA = 51 ; Pharmacode One-Track Global Const $BARCODE_PZN = 52 ; Pharmazentralnummer Global Const $BARCODE_PHARMA_TWO = 53 ; Pharmacode Two-Track Global Const $BARCODE_CEPNET = 54 ; Brazilian CEPNet Postal Code Global Const $BARCODE_PDF417 = 55 ; PDF417 Global Const $BARCODE_PDF417COMP = 56 ; Compact PDF417 Global Const $BARCODE_PDF417TRUNC = 56 ; Legacy Global Const $BARCODE_MAXICODE = 57 ; MaxiCode Global Const $BARCODE_QRCODE = 58 ; QR Code Global Const $BARCODE_CODE128AB = 60 ; Code 128 (Suppress Code Set C) Global Const $BARCODE_CODE128B = 60 ; Legacy Global Const $BARCODE_AUSPOST = 63 ; Australia Post Standard Customer Global Const $BARCODE_AUSREPLY = 66 ; Australia Post Reply Paid Global Const $BARCODE_AUSROUTE = 67 ; Australia Post Routing Global Const $BARCODE_AUSREDIRECT = 68 ; Australia Post Redirection Global Const $BARCODE_ISBNX = 69 ; ISBN Global Const $BARCODE_RM4SCC = 70 ; Royal Mail 4-State Global Const $BARCODE_DATAMATRIX = 71 ; Data Matrix (ECC200) Global Const $BARCODE_EAN14 = 72 ; EAN-14 Global Const $BARCODE_VIN = 73 ; Vehicle Identification Number Global Const $BARCODE_CODABLOCKF = 74 ; Codablock-F Global Const $BARCODE_NVE18 = 75 ; NVE-18 (SSCC-18) Global Const $BARCODE_JAPANPOST = 76 ; Japanese Postal Code Global Const $BARCODE_KOREAPOST = 77 ; Korea Post Global Const $BARCODE_DBAR_STK = 79 ; GS1 DataBar Stacked Global Const $BARCODE_RSS14STACK = 79 ; Legacy Global Const $BARCODE_DBAR_OMNSTK = 80 ; GS1 DataBar Stacked Omnidirectional Global Const $BARCODE_RSS14STACK_OMNI = 80 ; Legacy Global Const $BARCODE_DBAR_EXPSTK = 81 ; GS1 DataBar Expanded Stacked Global Const $BARCODE_RSS_EXPSTACK = 81 ; Legacy Global Const $BARCODE_PLANET = 82 ; USPS PLANET Global Const $BARCODE_MICROPDF417 = 84 ; MicroPDF417 Global Const $BARCODE_USPS_IMAIL = 85 ; USPS Intelligent Mail Global Const $BARCODE_ONECODE = 85 ; Legacy Global Const $BARCODE_PLESSEY = 86 ; UK Plessey Global Const $BARCODE_TELEPEN_NUM = 87 ; Telepen Numeric Global Const $BARCODE_ITF14 = 89 ; ITF-14 Global Const $BARCODE_KIX = 90 ; Dutch Post KIX Global Const $BARCODE_AZTEC = 92 ; Aztec Global Const $BARCODE_DAFT = 93 ; DAFT Global Const $BARCODE_DPD = 96 ; DPD Global Const $BARCODE_MICROQR = 97 ; Micro QR Global Const $BARCODE_HIBC_128 = 98 ; HIBC Code 128 Global Const $BARCODE_HIBC_39 = 99 ; HIBC Code 39 Global Const $BARCODE_HIBC_DM = 102 ; HIBC Data Matrix Global Const $BARCODE_HIBC_QR = 104 ; HIBC QR Global Const $BARCODE_HIBC_PDF = 106 ; HIBC PDF417 Global Const $BARCODE_HIBC_MICPDF = 108 ; HIBC MicroPDF417 Global Const $BARCODE_HIBC_BLOCKF = 110 ; HIBC Codablock-F Global Const $BARCODE_HIBC_AZTEC = 112 ; HIBC Aztec Global Const $BARCODE_DOTCODE = 115 ; DotCode Global Const $BARCODE_HANXIN = 116 ; Han Xin Global Const $BARCODE_MAILMARK_2D = 119 ; Royal Mail 2D Mailmark Global Const $BARCODE_UPU_S10 = 120 ; UPU S10 Global Const $BARCODE_MAILMARK_4S = 121 ; Royal Mail 4-State Mailmark Global Const $BARCODE_MAILMARK = 121 ; Legacy Global Const $BARCODE_AZRUNE = 128 ; Aztec Runes Global Const $BARCODE_CODE32 = 129 ; Code 32 Global Const $BARCODE_EANX_CC = 130 ; Legacy Global Const $BARCODE_GS1_128_CC = 131 ; GS1-128 Composite Global Const $BARCODE_EAN128_CC = 131 ; Legacy Global Const $BARCODE_DBAR_OMN_CC = 132 ; DataBar Omnidirectional Composite Global Const $BARCODE_RSS14_CC = 132 ; Legacy Global Const $BARCODE_DBAR_LTD_CC = 133 ; DataBar Limited Composite Global Const $BARCODE_RSS_LTD_CC = 133 ; Legacy Global Const $BARCODE_DBAR_EXP_CC = 134 ; DataBar Expanded Composite Global Const $BARCODE_RSS_EXP_CC = 134 ; Legacy Global Const $BARCODE_UPCA_CC = 135 ; UPC-A Composite Global Const $BARCODE_UPCE_CC = 136 ; UPC-E Composite Global Const $BARCODE_DBAR_STK_CC = 137 ; DataBar Stacked Composite Global Const $BARCODE_RSS14STACK_CC = 137 ; Legacy Global Const $BARCODE_DBAR_OMNSTK_CC = 138 ; DataBar Stacked Omnidirectional Composite Global Const $BARCODE_RSS14_OMNI_CC = 138 ; Legacy Global Const $BARCODE_DBAR_EXPSTK_CC = 139 ; DataBar Expanded Stacked Composite Global Const $BARCODE_RSS_EXPSTACK_CC = 139 ; Legacy Global Const $BARCODE_CHANNEL = 140 ; Channel Code Global Const $BARCODE_CODEONE = 141 ; Code One Global Const $BARCODE_GRIDMATRIX = 142 ; Grid Matrix Global Const $BARCODE_UPNQR = 143 ; UPNQR Global Const $BARCODE_ULTRA = 144 ; Ultracode Global Const $BARCODE_RMQR = 145 ; Rectangular Micro QR Global Const $BARCODE_BC412 = 146 ; IBM BC412 Global Const $BARCODE_DXFILMEDGE = 147 ; DX Film Edge Global Const $BARCODE_EAN8_CC = 148 ; EAN-8 Composite Global Const $BARCODE_EAN13_CC = 149 ; EAN-13 Composite Global Const $BARCODE_LAST = 149 ; Max marker ; === Output options === Global Const $BARCODE_BIND_TOP = 0x00001 ; Bind top Global Const $BARCODE_BIND = 0x00002 ; Bind bottom Global Const $BARCODE_BOX = 0x00004 ; Box around symbol Global Const $BARCODE_STDOUT = 0x00008 ; Output to stdout Global Const $READER_INIT = 0x00010 ; Reader Initialisation Global Const $SMALL_TEXT = 0x00020 ; Small human readable text Global Const $BOLD_TEXT = 0x00040 ; Bold human readable text Global Const $CMYK_COLOUR = 0x00080 ; Use CMYK in EPS Global Const $BARCODE_DOTTY_MODE = 0x00100 ; Dotty mode Global Const $GS1_GS_SEPARATOR = 0x00200 ; Use GS as separator Global Const $OUT_BUFFER_INTERMEDIATE = 0x00400 ; Return intermediate data Global Const $BARCODE_QUIET_ZONES = 0x00800 ; Force quiet zones Global Const $BARCODE_NO_QUIET_ZONES = 0x01000 ; Suppress quiet zones Global Const $COMPLIANT_HEIGHT = 0x02000 ; Compliant height Global Const $EANUPC_GUARD_WHITESPACE = 0x04000 ; Guard whitespace Global Const $EMBED_VECTOR_FONT = 0x08000 ; Embed vector font Global Const $BARCODE_MEMORY_FILE = 0x10000 ; Output to memory Global Const $BARCODE_RAW_TEXT = 0x20000 ; Output raw text ; === Input modes === Global Const $DATA_MODE = 0 ; Binary input Global Const $UNICODE_MODE = 1 ; Unicode input Global Const $GS1_MODE = 2 ; GS1 input Global Const $ESCAPE_MODE = 0x0008 ; Escape sequences Global Const $GS1PARENS_MODE = 0x0010 ; GS1 parentheses Global Const $GS1NOCHECK_MODE = 0x0020 ; Skip GS1 checks Global Const $HEIGHTPERROW_MODE = 0x0040 ; Height per row Global Const $FAST_MODE = 0x0080 ; Fast mode Global Const $EXTRA_ESCAPE_MODE = 0x0100 ; Extra escape Global Const $GS1SYNTAXENGINE_MODE = 0x0200 ; GS1 syntax engine ; === Data Matrix options === Global Const $DM_SQUARE = 100 ; Square only Global Const $DM_DMRE = 101 ; DMRE only Global Const $DM_ISO_144 = 128 ; ISO 144 compliance ; === QR/Han Xin/Grid Matrix options === Global Const $ZINT_FULL_MULTIBYTE = 200 ; Full multibyte ; === Ultracode options === Global Const $ULTRA_COMPRESSION = 128 ; Compression mode ; === Warnings & Errors === Global Const $ZINT_WARN_HRT_TRUNCATED = 1 ; HRT truncated Global Const $ZINT_WARN_INVALID_OPTION = 2 ; Invalid option Global Const $ZINT_WARN_USES_ECI = 3 ; Uses ECI Global Const $ZINT_WARN_NONCOMPLIANT = 4 ; Noncompliant symbol Global Const $ZINT_ERROR = 5 ; General error Global Const $ZINT_ERROR_TOO_LONG = 5 ; Data too long Global Const $ZINT_ERROR_INVALID_DATA = 6 ; Invalid data Global Const $ZINT_ERROR_INVALID_CHECK = 7 ; Invalid check digit Global Const $ZINT_ERROR_INVALID_OPTION = 8 ; Invalid option Global Const $ZINT_ERROR_ENCODING_PROBLEM = 9 ; Encoding problem Global Const $ZINT_ERROR_FILE_ACCESS = 10 ; File access error Global Const $ZINT_ERROR_MEMORY = 11 ; Memory error Global Const $ZINT_ERROR_FILE_WRITE = 12 ; File write error Global Const $ZINT_ERROR_USES_ECI = 13 ; Uses ECI Global Const $ZINT_ERROR_NONCOMPLIANT = 14 ; Noncompliant Global Const $ZINT_ERROR_HRT_TRUNCATED = 15 ; HRT truncated ; === Warning levels === Global Const $WARN_DEFAULT = 0 ; Default warnings Global Const $WARN_FAIL_ALL = 2 ; Treat all warnings as errors ; === Capabilities === Global Const $ZINT_CAP_HRT = 0x0001 ; Has HRT Global Const $ZINT_CAP_STACKABLE = 0x0002 ; Stackable Global Const $ZINT_CAP_EANUPC = 0x0004 ; EAN/UPC Global Const $ZINT_CAP_EXTENDABLE = 0x0004 ; Extendable (legacy) Global Const $ZINT_CAP_COMPOSITE = 0x0008 ; Composite Global Const $ZINT_CAP_ECI = 0x0010 ; ECI capable Global Const $ZINT_CAP_GS1 = 0x0020 ; GS1 capable Global Const $ZINT_CAP_DOTTY = 0x0040 ; Dotty capable Global Const $ZINT_CAP_QUIET_ZONES = 0x0080 ; Quiet zones Global Const $ZINT_CAP_FIXED_RATIO = 0x0100 ; Fixed ratio Global Const $ZINT_CAP_READER_INIT = 0x0200 ; Reader Init Global Const $ZINT_CAP_FULL_MULTIBYTE = 0x0400 ; Full multibyte Global Const $ZINT_CAP_MASK = 0x0800 ; Masking Global Const $ZINT_CAP_STRUCTAPP = 0x1000 ; Structured Append Global Const $ZINT_CAP_COMPLIANT_HEIGHT = 0x2000 ; Compliant height Global Const $ZINT_CAP_BINDABLE = 0x4000 ; Bindable ; === Limits === Global Const $ZINT_MAX_DATA_LEN = 17400 ; Max data length Global Const $ZINT_MAX_SEG_COUNT = 256 ; Max segment count #EndRegion #Region Structs ; Vector elements Global Const $tag_zint_vector_rect = "struct;" & _ "float x;" & _ ; Top left "float y;" & _ "float height;" & _ "float width;" & _ "long colour;" & _ ; -1 foreground, 1-8 = Cyan, Blue, Magenta, Red, Yellow, Green, Black, White "ptr next;" & _ ; Pointer to next rectangle "endstruct" Global Const $tag_zint_vector_hexagon = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Short diameter (inscribed circle) "long rotation;" & _ ; 0, 90, 180, 270 (0 = apex at top) "ptr next;" & _ ; Pointer to next hexagon "endstruct" Global Const $tag_zint_vector_string = "struct;" & _ "float x;" & _ ; Relative to halign "float y;" & _ ; Relative to baseline "float fsize;" & _ ; Font size "float width;" & _ ; Rendered width estimate "long length;" & _ ; Number of characters (bytes) "long rotation;" & _ ; 0, 90, 180, 270 "long halign;" & _ ; 0 = centre, 1 = left, 2 = right "ptr text;" & _ ; UTF-8, NUL-terminated "ptr next;" & _ ; Pointer to next string "endstruct" Global Const $tag_zint_vector_circle = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Circle diameter (excludes width) "float width;" & _ ; Perimeter width, 0 = fill "long colour;" & _ ; 0 = foreground colour, else background "ptr next;" & _ ; Pointer to next circle "endstruct" Global Const $tag_zint_vector = "struct;" & _ "float width;" & _ ; Overall barcode width "float height;" & _ ; Overall barcode height "ptr rectangles;" & _ ; Pointer to first rectangle "ptr hexagons;" & _ ; Pointer to first hexagon "ptr strings;" & _ ; Pointer to first string "ptr circles;" & _ ; Pointer to first circle "endstruct" ; Structured Append info Global Const $tag_zint_structapp = "long index;" & _ ; Position in sequence (1-based) "long count;" & _ ; Number of symbols in sequence "char id[32];" ; Optional ID, ASCII, NUL-terminated ; Segment info Global Const $tag_zint_seg = "struct;" & _ "ptr source;" & _ ; Data pointer "long length;" & _ ; Data length (0 = NUL-terminated) "long eci;" & _ ; Extended Channel Interpretation "endstruct" ; Main symbol structure Global Const $tag_zint_symbol = "struct;" & _ "long symbology;" & _ ; Symbol type "float height;" & _ ; Barcode height "float scale;" & _ ; Scale factor "long whitespace_width;" & _ ; Horizontal whitespace "long whitespace_height;" & _ ; Vertical whitespace "long border_width;" & _ ; Border width "long output_options;" & _ ; Output options "char fgcolour[16];" & _ ; Foreground colour string "char bgcolour[16];" & _ ; Background colour string "ptr fgcolor;" & _ ; Pointer to fgcolour "ptr bgcolor;" & _ ; Pointer to bgcolour "char outfile[256];" & _ ; Output filename "char primary[128];" & _ ; Primary message data "long option_1;" & _ ; Symbol-specific option "long option_2;" & _ "long option_3;" & _ "long show_hrt;" & _ ; Show (1) / hide (0) human readable text "long input_mode;" & _ ; Input encoding "long eci;" & _ ; Extended Channel Interpretation "float dpmm;" & _ ; Resolution in dots/mm "float dot_size;" & _ ; Dot size (dotty mode) "float text_gap;" & _ ; Gap between barcode and text "float guard_descent;" & _ ; EAN/UPC guard bar descent $tag_zint_structapp & _ ; Structured append info "long warn_level;" & _ ; Warning behaviour "long debug;" & _ ; Debug flags "byte text[256];" & _ ; Human-readable text (output) "long text_length;" & _ ; Length of text (output) "long rows;" & _ ; Number of rows (output) "long width;" & _ ; Symbol width (output) "byte encoded_data[28800];" & _ ; Encoded data (flattened 200x144) "float row_height[200];" & _ ; Row heights "char errtxt[160];" & _ ; Error text (output) "ptr bitmap;" & _ ; Bitmap pointer (output) "long bitmap_width;" & _ ; Bitmap width "long bitmap_height;" & _ ; Bitmap height "ptr alphamap;" & _ ; Alpha channel pointer "ptr vector;" & _ ; Vector header pointer "ptr memfile;" & _ ; In-memory file buffer "long memfile_size;" & _ ; Buffer length "ptr raw_segs;" & _ ; Raw segments pointer "long raw_seg_count;" & _ ; Number of raw segs "endstruct" #EndRegion #Region Functions ; Create and initialize a symbol structure Func ZBarcode_Create() If Not FileExists($g__ZintDLL) Then If @AutoItX64 Then _zint64dll(True) Else _zintdll(True) EndIf EndIf Local $hPtr = DllCall($g__ZintDLL, "ptr:cdecl", "ZBarcode_Create")[0] If $hPtr = 0 Then Return SetError(2, 0, 0) Return $hPtr EndFunc ; Free any output buffers that may have been created and initialize output fields Func ZBarcode_Clear($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Clear", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free any output buffers that may have been created and reset all fields to defaults Func ZBarcode_Reset($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Reset", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free a symbol structure, including any output buffers Func ZBarcode_Delete($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Delete", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; =================================================================== ; Encoding ; =================================================================== ; Encode a barcode. If length is 0 or negative, source must be NUL-terminated Func ZBarcode_Encode($pSymbol, $sInput) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a barcode with multiple ECI segments Func ZBarcode_Encode_Segs($pSymbol, $pSegs, $iSegCount) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a barcode using input data from file Func ZBarcode_Encode_File($pSymbol, $sFilename) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File", "ptr", $pSymbol, "str", $sFilename)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Output to file ; =================================================================== ; Output a previously encoded symbol to file Func ZBarcode_Print($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Print", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode and output a symbol to file Func ZBarcode_Encode_and_Print($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Print", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a symbol with multiple ECI segments and output to file Func ZBarcode_Encode_Segs_and_Print($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Print", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a symbol using input data from file and output to file Func ZBarcode_Encode_File_and_Print($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Print", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Output to memory (raster/vector) ; =================================================================== Func ZBarcode_Buffer($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Buffer_Vector($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer_Vector", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer_Vector($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer_Vector", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer_Vector($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer_Vector", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer_Vector($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer_Vector", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Info & Validation ; =================================================================== ; Is symbol_id a recognized symbology? Func ZBarcode_ValidID($iSymbolID) Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_ValidID", "long", $iSymbolID)[0] EndFunc ; Copy BARCODE_XXX name of symbol_id into name buffer Func ZBarcode_BarcodeName($iSymbolID) Local $tName = DllStructCreate("char[32]") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_BarcodeName", "long", $iSymbolID, "struct*", $tName)[0] If $iResult Then Return SetError($iResult, 0, "") Return DllStructGetData($tName, 1) EndFunc ; Return the capability flags for symbology symbol_id that match cap_flag Func ZBarcode_Cap($iSymbolID, $iCapFlag) Return DllCall($g__ZintDLL, "uint:cdecl", "ZBarcode_Cap", "long", $iSymbolID, "uint", $iCapFlag)[0] EndFunc ; =================================================================== ; X-dimension & Scaling ; =================================================================== Func ZBarcode_Default_Xdim($iSymbolID) Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Default_Xdim", "long", $iSymbolID)[0] EndFunc Func ZBarcode_Scale_From_XdimDp($iSymbolID, $fXDimMM, $fDpmm, $sFiletype = "") Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Scale_From_XdimDp", _ "long", $iSymbolID, "float", $fXDimMM, "float", $fDpmm, "str", $sFiletype)[0] EndFunc Func ZBarcode_XdimDp_From_Scale($iSymbolID, $fScale, $fXDimOrDpmm, $sFiletype = "") Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_XdimDp_From_Scale", _ "long", $iSymbolID, "float", $fScale, "float", $fXDimOrDpmm, "str", $sFiletype)[0] EndFunc ; =================================================================== ; UTF-8 & ECI helpers ; =================================================================== Func ZBarcode_UTF8_To_ECI($iEci, $sSource, ByRef $sDest) Local $iLength = StringLen($sSource) Local $tSrc = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tSrc.text = $sSource Local $tDest = DllStructCreate("ubyte[1024]") ; allocate buffer Local $pDestLen = DllStructCreate("int") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_UTF8_To_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength + 1, "struct*", $tDest, "struct*", $pDestLen)[0] If $iResult Then Return SetError($iResult, 0, "") $sDest = BinaryToString(DllStructGetData($tDest, 1)) Return 1 EndFunc Func ZBarcode_Dest_Len_ECI($iEci, $sSource) Local $iLength = StringLen($sSource) Local $tSrc = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tSrc.text = $sSource Local $pDestLen = DllStructCreate("int") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Dest_Len_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength + 1, "struct*", $pDestLen)[0] If $iResult Then Return SetError($iResult, 0, 0) Return DllStructGetData($pDestLen, 1) EndFunc ; =================================================================== ; Build info ; =================================================================== Func ZBarcode_NoPng() Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_NoPng")[0] EndFunc Func ZBarcode_HaveGS1SyntaxEngine() Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_HaveGS1SyntaxEngine")[0] EndFunc ; Return the version of Zint linked to Func ZBarcode_Version() Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Version")[0] Local $a = StringRegExp((Mod(StringLen($iResult), 2) ? "0" : "") & $iResult, ".{2}", 3) If Not IsArray($a) Then Return SetError(1, 0, 0) Return StringFormat("%01i.%02i.%02i", $a[0], $a[1], $a[2]) EndFunc #EndRegion Example1.au3 #AutoIt3Wrapper_UseX64=y #include <GDIPlus.au3> #include "Zint.au3" Global Const $sTestFile = "out.png" ;default output name If FileExists($sTestFile) Then FileDelete($sTestFile) Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ConsoleWrite("Zint DLL version: " & ZBarcode_Version() & @CRLF) ConsoleWrite("PNG support: " & (ZBarcode_NoPng() ? "No" : "Yes") & @CRLF) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) If @error Then MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ZBarcode_Delete($pZB) Exit EndIf With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 1 .option_1 = -1 .show_hrt = 1 .output_options = $SMALL_TEXT .outfile = $sTestFile EndWith ZBarcode_Encode_and_Print($pZB, "12340984576") Global $iError = @error ZBarcode_Delete($pZB) If FileExists($sTestFile) Then ShellExecute($sTestFile) Else MsgBox(16, "Error", "Code was not create. Error: " & $iError, 5) EndIf Example2.au3 #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include "Zint.au3" Global Const $sTestFile = @ScriptDir & "\Barcode.png" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) $t_zint_symbol.symbology = $BARCODE_QRCODE $t_zint_symbol.scale = 10 ZBarcode_Encode_and_Buffer($pZB, "Hello QR World ;-)") _GDIPlus_Startup() Global $stride = BitAND(($t_zint_symbol.bitmap_width * 3) + 3, BitNOT(3)) Global $iMemSize = $stride * $t_zint_symbol.bitmap_height Global $tPixel = DllStructCreate("ubyte rgb[" & $iMemSize & "];") Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height, $GDIP_PXF24RGB, $stride, $tPixel) DllCall("msvcrt.dll", "ptr:cdecl", "memcpy", "struct*", $tPixel, "ptr", $t_zint_symbol.bitmap, "uint", $iMemSize) Global Const $hGUI = GUICreate("Test QR Code", $t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height) GUISetState(@SW_SHOW) Global Const $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, $t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() ZBarcode_Delete($pZB) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Example3.au3 #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include "Zint.au3" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB), $sText = "12340984576 ;-)" With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 1 EndWith If Not ZBarcode_Encode_and_Buffer_Vector($pZB, $sText) Then Exit MsgBox(16, "ERROR", "Unable to encode!" & @CRLF & "Error code = " & @error, 10) Global $tVector = DllStructCreate($tag_zint_vector, $t_zint_symbol.vector) Global $tVector_Rect = DllStructCreate($tag_zint_vector_rect, $tVector.rectangles) ConsoleWrite($tVector.width & " x " & $tVector.height & @CRLF) _GDIPlus_Startup() Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($tVector.width, $tVector.height, $GDIP_PXF24RGB), $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hBrush = _GDIPlus_BrushCreateSolid() _GDIPlus_GraphicsClear($hCanvas, 0xFFFFFFFF) While $tVector_Rect.next _GDIPlus_BrushSetSolidColor($hBrush, BitAND($tVector_Rect.colour, 0xFF000000)) _GDIPlus_GraphicsFillRect($hCanvas, $tVector_Rect.x, $tVector_Rect.y, $tVector_Rect.width, $tVector_Rect.height, $hBrush) $tVector_Rect = DllStructCreate($tag_zint_vector_rect, $tVector_Rect.next) WEnd Global $tVector_String = DllStructCreate($tag_zint_vector_string, $tVector.strings) _GDIPlus_GraphicsDrawString($hCanvas, $sText, ($tVector_String.width - $tVector_String.length * $tVector_String.fsize * 0.55) / 2, $tVector.height - $tVector_String.fsize * 1.33333, "Arial", $tVector_String.fsize * 0.75, Default, 0xFF000000) Global Const $hGUI = GUICreate("Test Bar Code 128", $tVector.width, $tVector.height) GUISetState(@SW_SHOW) Global Const $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, $tVector.width, $tVector.height) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_Shutdown() ZBarcode_Delete($pZB) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Example4.au3 #AutoIt3Wrapper_UseX64=y #include "Zint.au3" ; =================================================================== ; Zint AutoIt Demo Test ; =================================================================== ; ------------------------------------------------------------------- ; Step 1: Create a symbol ; ------------------------------------------------------------------- ConsoleWrite("Step 1: Create a symbol" & @CRLF) Global $pSymbol = ZBarcode_Create() If @error Then MsgBox(16, "Error", "Failed to create symbol") Exit EndIf ConsoleWrite("Symbol created: " & $pSymbol & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 2: Encode a simple string ; ------------------------------------------------------------------- ConsoleWrite("Step 2: Encode a simple string" & @CRLF) Global $sData = "HELLO123" If ZBarcode_Encode($pSymbol, $sData) Then ConsoleWrite("Encoding succeeded" & @CRLF) Else ConsoleWrite("Encoding failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 3: Output to raster buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 3: Output to raster buffer" & @CRLF) If ZBarcode_Buffer($pSymbol) Then ConsoleWrite("Raster buffer generated successfully" & @CRLF) Else ConsoleWrite("Raster buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 4: Output to vector buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 4: Output to vector buffer" & @CRLF) If ZBarcode_Buffer_Vector($pSymbol) Then ConsoleWrite("Vector buffer generated successfully" & @CRLF) Else ConsoleWrite("Vector buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 5: Print to file (just test call, file may not exist) ; ------------------------------------------------------------------- ConsoleWrite("Step 5: Print to file" & @CRLF) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pSymbol) $t_zint_symbol.symbology = $BARCODE_CODE128 $t_zint_symbol.input_mode = $DATA_MODE $t_zint_symbol.height = 50 $t_zint_symbol.scale = 1 $t_zint_symbol.option_1 = 0 $t_zint_symbol.option_2 = 0 $t_zint_symbol.option_3 = 0 $t_zint_symbol.show_hrt = 1 If ZBarcode_Print(DllStructGetPtr($t_zint_symbol)) Then ConsoleWrite("Print function call succeeded" & @CRLF) Else ConsoleWrite("Print failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 6: Get barcode info ; ------------------------------------------------------------------- ConsoleWrite("Step 6: Get barcode info" & @CRLF) ConsoleWrite("Valid ID for CODE128: " & ZBarcode_ValidID(20) & @CRLF) ConsoleWrite("Barcode name for CODE128: " & ZBarcode_BarcodeName(20) & @CRLF) ConsoleWrite("Default X-dim for CODE128: " & ZBarcode_Default_Xdim(20) & " mm" & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 7: UTF-8 to ECI conversion test ; ------------------------------------------------------------------- ConsoleWrite("Step 7: UTF-8 to ECI conversion test" & @CRLF) Global $sDest If ZBarcode_UTF8_To_ECI(3, "HELLO", $sDest) Then ConsoleWrite("UTF-8 to ECI conversion succeeded: " & $sDest & @CRLF) Else ConsoleWrite("UTF-8 to ECI conversion failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 8: Check Zint build info ; ------------------------------------------------------------------- ConsoleWrite("Step 8: Check Zint build info" & @CRLF) ConsoleWrite("Zint No PNG support: " & ZBarcode_NoPng() & @CRLF) ConsoleWrite("Zint GS1 support: " & ZBarcode_HaveGS1SyntaxEngine() & @CRLF) ConsoleWrite("Zint Version: " & ZBarcode_Version() & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 9: Clear, reset and delete symbol ; ------------------------------------------------------------------- ConsoleWrite("Step 9: Clear, reset and delete symbol" & @CRLF) ZBarcode_Clear($pSymbol) ConsoleWrite("Symbol cleared" & @CRLF) ZBarcode_Reset($pSymbol) ConsoleWrite("Symbol reset" & @CRLF) ZBarcode_Delete($pSymbol) ConsoleWrite("Symbol deleted" & @CRLF) ConsoleWrite(@CRLF) MsgBox(64, "Demo Complete", "Zint AutoIt demo test finished successfully.") Example5.au3 #AutoIt3Wrapper_UseX64=y #include "Zint.au3" ; Zint Symbol erstellen Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ; Configure Zint Symbol structure Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) With $t_zint_symbol .symbology = $BARCODE_AZTEC .input_mode = $UNICODE_MODE .scale = 10 .outfile = @ScriptDir & "\segtest.png" EndWith If FileExists($t_zint_symbol.outfile) Then FileDelete($t_zint_symbol.outfile) Global $tagSeg = "ptr source; int length; int eci" ; --- Create continuous array --- Global $iSize = (@AutoItX64 ? 16 : 12) ;size of $tagSeg Global $tContinuousArray = DllStructCreate("byte[" & $iSize * 3 & "]") ; --- Create individual zint_seg structures --- Global $tSeg1 = DllStructCreate($tagSeg, DllStructGetPtr($tContinuousArray)) Global $tSeg2 = DllStructCreate($tagSeg, DllStructGetPtr($tContinuousArray) + $iSize) Global $tSeg3 = DllStructCreate($tagSeg, DllStructGetPtr($tContinuousArray) + 2 * $iSize) ; --- Create the text data --- Global $sText1 = "Κείμενο" ; Greek Global $sText2 = "Текст" ; Cyrillic Global $sText3 = "文章" ; Chinese ; Convert to UTF-8 (or use direct string pointers if Zint.au3 supports it) Global $tText1 = DllStructCreate("char t[256]") Global $tText2 = DllStructCreate("char t[256]") Global $tText3 = DllStructCreate("char t[256]") $tText1.t = $sText1 $tText2.t = $sText2 $tText3.t = $sText3 ; --- Fill the segment structures --- $tSeg1.source = DllStructGetPtr($tText1) $tSeg1.length = 0 ; 0 = NUL-terminated $tSeg1.eci = 9 ; Greek ECI $tSeg2.source = DllStructGetPtr($tText2) $tSeg2.length = 0 $tSeg2.eci = 7 ; Cyrillic ECI $tSeg3.source = DllStructGetPtr($tText3) $tSeg3.length = 0 $tSeg3.eci = 20 ; Chinese ECI Global $iError = 0 ; --- Call ZBarcode_Encode_Segs --- If Not ZBarcode_Encode_Segs($pZB, DllStructGetPtr($tContinuousArray), 3) Then $iError = @error MsgBox(16, "ERROR", "ZBarcode_Encode_Segs returned error: " & $iError, 10) EndIf ZBarcode_Print($pZB, 0) If Not $iError Then ShellExecute($t_zint_symbol.outfile) ZBarcode_Delete($pZB) Please test and reply. Feel free to post examples here!
  2. I've ported some of the JavaScript 140 Bytes demos from dwitter.net to FreeBasic. Download AiO with 1000 examples (7-Zip archive): The beauty - magic of math Vol. 1 - 23 build 2024-01-14.7z (5.09 mb with source code and Windows x64 compiled executables) or have a look to my 1drive folder: _dwitter.net Some screenshots: ... Autoit is too slow for almost all of these examples. Happy watching.
  3. Since I disovered FreeBasic I decided to create a DLL to implement much faster image processing functionality to AutoIt. Following functions are implemented yet: _GDIPlus_BitmapApplyFilter_BWJJNDithering _GDIPlus_BitmapApplyFilter_BWBayerOrderedDithering _GDIPlus_BitmapApplyFilter_Cartoon1 _GDIPlus_BitmapApplyFilter_ColorAccent _GDIPlus_BitmapApplyFilter_Convolution_AnotherBlur _GDIPlus_BitmapApplyFilter_Convolution_BoxBlur _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection1 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection2 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection3 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection4 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection5 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection6 _GDIPlus_BitmapApplyFilter_Convolution_Emboss1 _GDIPlus_BitmapApplyFilter_Convolution_Emboss45Degree _GDIPlus_BitmapApplyFilter_Convolution_EmbossTopLeftBottomRight _GDIPlus_BitmapApplyFilter_Convolution_Gaussian3x3 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_1 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_2 _GDIPlus_BitmapApplyFilter_Convolution_GaussianBlur _GDIPlus_BitmapApplyFilter_Convolution_IntenseEmboss _GDIPlus_BitmapApplyFilter_Convolution_Kirsch _GDIPlus_BitmapApplyFilter_Convolution_Laplace1 _GDIPlus_BitmapApplyFilter_Convolution_Laplace2 _GDIPlus_BitmapApplyFilter_Convolution_Laplace3 _GDIPlus_BitmapApplyFilter_Convolution_LaplacianOfGaussian _GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix _GDIPlus_BitmapApplyFilter_Convolution_MotionBlur _GDIPlus_BitmapApplyFilter_Convolution_Outline3x3 _GDIPlus_BitmapApplyFilter_Convolution_Prewitt _GDIPlus_BitmapApplyFilter_Convolution_Sharpen1 _GDIPlus_BitmapApplyFilter_Convolution_Sharpen2 _GDIPlus_BitmapApplyFilter_Convolution_Sobel _GDIPlus_BitmapApplyFilter_Convolution_SovelVsPrewitt _GDIPlus_BitmapApplyFilter_Convolution_TriangleBlur _GDIPlus_BitmapApplyFilter_Convolution_Unsharp _GDIPlus_BitmapApplyFilter_Convolution_Unsharp5x5 _GDIPlus_BitmapApplyFilter_Delaunay _GDIPlus_BitmapApplyFilter_Dilatation _GDIPlus_BitmapApplyFilter_DistortionBlur _GDIPlus_BitmapApplyFilter_Edges _GDIPlus_BitmapApplyFilter_Erosion _GDIPlus_BitmapApplyFilter_FakeGreyscale _GDIPlus_BitmapApplyFilter_FishEye _GDIPlus_BitmapApplyFilter_Indexed _GDIPlus_BitmapApplyFilter_Jitter _GDIPlus_BitmapApplyFilter_Kuwahara _GDIPlus_BitmapApplyFilter_Linellism _GDIPlus_BitmapApplyFilter_Median _GDIPlus_BitmapApplyFilter_Median2 _GDIPlus_BitmapApplyFilter_Mosaic _GDIPlus_BitmapApplyFilter_OilPainting _GDIPlus_BitmapApplyFilter_Open _GDIPlus_BitmapApplyFilter_PenSketch _GDIPlus_BitmapApplyFilter_PenSketch2 _GDIPlus_BitmapApplyFilter_Pixelate _GDIPlus_BitmapApplyFilter_Pointillism _GDIPlus_BitmapApplyFilter_RadialBlur _GDIPlus_BitmapApplyFilter_Raster _GDIPlus_BitmapApplyFilter_Spiral _GDIPlus_BitmapApplyFilter_Swirl _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour _GDIPlus_BitmapApplyFilter_TiltShift _GDIPlus_BitmapApplyFilter_TimeWarp _GDIPlus_BitmapApplyFilter_Ver _GDIPlus_BitmapApplyFilter_Wave _GDIPlus_BitmapApplyFilter_XRay Since I am absolutely a newbie in FreeBasic, the DLL may contain errors. Please report any bug. FreeBasic source code can be found here: https://pastebin.com/Lugp6rCR To do: add function headers with descriptions speed-up FB code -> partly done add more filters -> ongoing Credits to: Jakub Szymanowski rdc Dewald Esterhuizen Santhosh G_ Christian Graus www.gutgames.com Have fun. You can compare the speed with AutoIt version: #AutoIt3Wrapper_Version=b #include <Array.au3> #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global Const $hGUI = GUICreate("GDI+ Image Filters", $iW * 2, $iH) Global $fProg = 0, $iEnd = $iW * $iH - 1 AdlibRegister("Progress", 490) Global $t = TimerInit() Global Const $hGDIBitmap = _GDIPlus_BitmapApplyFilter_Median($hImage, 4) ConsoleWrite(Round(TimerDiff($t) / 1000, 2) & " s / " & Round(TimerDiff($t) / 60000, 2) & " min" & @CRLF) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) Global Const $iPic_o = GUICtrlCreatePic("", $iW, 0, $iW - 1, $iH - 1) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) Global Const $hGDIBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_o, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap2)) GUISetState() AdlibUnRegister("Progress") ToolTip("") Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap2) _GDIPlus_Shutdown() Exit Func Progress() ToolTip(Int($fProg / $iEnd * 100) & " % / " & Round(TimerDiff($t) / 60000, 2) & " min", MouseGetPos(0) + 30, MouseGetPos(1) + 30) EndFunc #Region Symmetric Nearest Neighbour Func _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius = 2, $bGDI = True) ;no alpha channel implemented yet Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iRowOffset, $iX, $iY, $c, $k, $sumR, $sumG, $sumB, $iCount, $xx, $yy, $iR, $iG, $iB, $iR1, $iG1, $iB1, $iR2, $iG2, $iB2, $x, $y For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW For $iX = 0 To $iW - 1 $sumR = 0 $sumG = 0 $sumB = 0 $iCount = 0 $c = DllStructGetData($tPixel, 1, $iRowOffset + $iX) $iR = BitShift(BitAND(0x00FF0000, $c), 16) $iG = BitShift(BitAND(0x0000FF00, $c), 8) $iB = BitAND(0x000000FF, $c) For $yy = -$fRadius To $fRadius For $xx = -$fRadius To $fRadius $k = $iX + $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = $iY + $yy $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR1 = BitShift(BitAND(0x00FF0000, $c), 16) $iG1 = BitShift(BitAND(0x0000FF00, $c), 8) $iB1 = BitAND(0x000000FF, $c) $k = $iX - $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = ($iY - $yy) $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR2 = BitShift(BitAND(0x00FF0000, $c), 16) $iG2 = BitShift(BitAND(0x0000FF00, $c), 8) $iB2 = BitAND(0x000000FF, $c) If __DeltaE($iR, $iG, $iB, $iR1, $iG1, $iB1) < __DeltaE($iR, $iG, $iB, $iR2, $iG2, $iB2) Then $sumR += $iR1 $sumG += $iG1 $sumB += $iB1 Else $sumR += $iR2 $sumG += $iG2 $sumB += $iB2 EndIf $iCount += 1 Next Next DllStructSetData($tPixel_Dest, 1, 0xFF000000 + Int($sumR / $iCount) * 0x10000 + Int($sumG / $iCount) * 0x100 + Int($sumB / $iCount), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_SNN" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __DeltaE($iR1, $iG1, $iB1, $iR2, $iG2, $iB2) Return Sqrt(($iR1 - $iR2) * ($iR1 - $iR2) + ($iG1 - $iG2) * ($iG1 - $iG2) + ($iB1 - $iB2) * ($iB1 - $iB2)) EndFunc #EndRegion #Region Jitter Func _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount = 20, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset, $fNX, $fNY For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $fNX = $iX + Int((Random() - 0.5) * $iAmount) $fNX = $fNX < 1 ? 1 : $fNX > $iW - 1 ? $iW - 1 : $fNX $fNY = ($iY + Int((Random() - 0.5) * $iAmount)) $fNY = $fNY < 1 ? 1 : $fNY > $iH - 1 ? $iH - 1 : $fNY $fNY *= $iW DllStructSetData($tPixel_Dest, 1, DllStructGetData($tPixel, 1, $fNY + $fNX), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Jitter" & $iAmount & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc #EndRegion #Region Median Func _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius = 3, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 DllStructSetData($tPixel_Dest, 1, __Median_Value($iX, $iY, $fRadius, $tPixel, $iW, $iH), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Median" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __Median_Value($iPosX, $iPosY, $fRadius, $tPixel, $iW, $iH) Local $iX, $iY, $aColors[1000], $iColors = 0, $iSize = $iW * $iH - 1, $iOff, $e For $iX = $iPosX - $fRadius To $iPosX + $fRadius For $iY = $iPosY - $fRadius To $iPosY + $fRadius $iOff = 1 + $iY * $iW + $iX $aColors[$iColors] = DllStructGetData($tPixel, 1, $iOff < 1 ? 1 : $iOff > $iSize ? $iSize : $iOff) $iColors += 1 Next Next ReDim $aColors[$iColors] ;~ _ArraySort($aColors, 0) $e = $iColors - 1 __ArrayQuickSort1D($aColors, 0, $e) Local $iMid = Floor($iColors / 2), $iMedian If BitAND($iColors, 1) Then $iMedian = Int($aColors[$iMid + 1]) Else $iMedian = Int(($aColors[$iMid] + $aColors[$iMid + 1]) / 2) EndIf Return $iMedian EndFunc #EndRegion _GDIPlus_BitmapApplyFilter v0.9.8 build 2024-04-17 beta.7z
  4. I ported half of the Cairo functions to Autoit. You can read more about the functions here: https://www.cairographics.org/documentation/ The probability is high that errors have crept in and I have only tested a fraction of the functions. Anyone who wants to can contribute examples. All needed files (DLLs, UDF and examples) can be download from my OneDrive: Cairo for Autoit If you find a mistake, I am sure you will, then please report it.
  5. mesale0077 asked me whether I could code some CSS loading animations from different web sites. These are the results using GDI+ (AutoIt v3.3.12.0+ required!): _GDIPlus_MonochromaticBlinker.au3 / _GDIPlus_RotatingBokeh.au3 _GDIPlus_SpinningCandy.au3 / _GDIPlus_SteamPunkLoading.au3 _GDIPlus_IncreasingBalls.au3 / _GDIPlus_PacmanProgressbar.au3 _GDIPlus_StripProgressbar.au3 / _GDIPlus_RingProgressbar.au3 _GDIPlus_LineProgressbar.au3 / _GDIPlus_SimpleLoadingAnim.au3 _GDIPlus_TextFillingWithWater.au3 / _GDIPlus_MultiColorLoader.au3 _GDIPlus_LoadingSpinner.au3 / _GDIPlus_SpinningAndPulsing.au3 _GDIPlus_TogglingSphere.au3 / _GDIPlus_CloudySpiral.au3 _GDIPlus_GlowingText.au3 (thanks to Eukalyptus) / _GDIPlus_HypnoticLoader.au3 _GDIPlus_RotatingRectangles.au3 / _GDIPlus_TRONSpinner.au3 _GDIPlus_RotatingBars.au3 / _GDIPlus_AnotherText.au3 (thanks to Eukalyptus) _GDIPlus_CogWheels.au3 (thanks to Eukalyptus) / _GDIPlus_DrawingText.au3 (thanks to Eukalyptus) _GDIPlus_GearsAnim.au3 / _GDIPlus_LEDAnim.au3 _GDIPlus_LoadingTextAnim.au3 / _GDIPlus_MovingRectangles.au3 _GDIPlus_SpinningAndGlowing.au3 (thanks to Eukalyptus) / _GDIPlus_YetAnotherLoadingAnim.au3 _GDIPlus_AnimatedTypeLoader.au3 / _GDIPlus_Carousel.au3 Each animation function has a built-in example how it can be used. AiO download: GDI+ Animated Wait Loading Screens.7z (previous downloads: 1757) Big thanks to Eukalyptus for providing several examples. Maybe useful for some of you Br, UEZ PS: I don't understand CSS - everything is made out of my mind, so it might be different from original CSS examples
  6. hello autoit team please i've a question for you. am creating a audio player and in this audio player i want to show the current trac info such as the total time and the position ... etc i know i can show it as label but the screen reader for the blind read the text every change because it have a screen scan what i want is to show this informations but such image or icon i mean i need to create GUICtrlCreatepic or GUICtrlCreateicon .... or some thing as that and show this informations as image on it i think that i can do that with the _GDIPlus functions but i couldn't find the currect way to do it i tried the _GDIPlus_GraphicsDrawString but i couldn't know how it work what i need is a small example that create a GUI and add a multy line text to it as graphic or image. so i need a simple way because it will changed every sec i hope any one can help me to do that global $GUI = GUICreate("text", 400, 400) global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc
  7. Here a little tool to display the histogram of an image (inspired by this thread): ) ;#AutoIt3Wrapper_Icon=Histogram1.ico #AutoIt3Wrapper_Compile_Both=y ;#AutoIt3Wrapper_Res_Field=CompanyName|UEZ Software Development ;#AutoIt3Wrapper_Res_Field=ProductName|GDI+ Show Histogram ;#AutoIt3Wrapper_Res_Field=ProductVersion|%AutoItVer% #AutoIt3Wrapper_Res_Fileversion=0.9.8.0 ;#AutoIt3Wrapper_Res_Field=Build|2015-07-10 #AutoIt3Wrapper_Res_LegalCopyright=UEZ Software Development #AutoIt3Wrapper_Res_Language=1033 ;#AutoIt3Wrapper_Res_Field=URL|http://www.autoitscript.com/forum/index.php?showtopic=147777 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--best --lzma #AutoIt3Wrapper_Run_After=upx.exe --best --lzma "GDI+ Show Histogram_x64.exe" #AutoIt3Wrapper_UseX64=n #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("MouseCoordMode", 2) _GDIPlus_Startup() If @error Then Exit MsgBox(0x40010, "Error", "GDI+ Show Histogram can run on operating systems Vista or newer only!") Global $ghGDIPDll = $__g_hGDIPDll, $aRes Global Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Global Const $aFullScreen = WinGetPos($hFullScreen) Global Enum $HistogramFormatARGB, $HistogramFormatPARGB, $HistogramFormatRGB, $HistogramFormatGray, _ ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms534129(v=vs.85).aspx $HistogramFormatB, $HistogramFormatG, $HistogramFormatR, $HistogramFormatA Global $tStructChannel0 = DllStructCreate("uint channel0[256]") Global $pStructChannel0 = DllStructGetPtr($tStructChannel0) Global $tStructChannel1 = DllStructCreate("uint channel1[256]") Global $pStructChannel1 = DllStructGetPtr($tStructChannel1) Global $tStructChannel2 = DllStructCreate("uint channel2[256]") Global $pStructChannel2 = DllStructGetPtr($tStructChannel2) Global $tStructChannel3 = DllStructCreate("uint channel3[256]") Global $pStructChannel3 = DllStructGetPtr($tStructChannel3) Global $s, $sFile, $hImage, $bImgLoaded = False, $aLuminosity[257], $aCRGB[257] Global Const $STM_SETIMAGE = 0x0172, $iLineJoinBevel = 1, $frY = 0.299, $fgY = 0.587, $fbY = 0.114 Global Const $hGUI = GUICreate("GDI+ Show Histogram v0.98 beta by UEZ build 2015-07-13", 468, 310, -1, -1, Default, Default) GUISetBkColor(0xFFFFFF, $hGUI) Global Const $sLabel_Titel_Txt = "GDI+ Show Histogram" Global Const $iPosX_Label = 20, $iPosY_Label = 12 Global Const $iLabel_Titel_Shadow = GUICtrlCreateLabel($sLabel_Titel_Txt, $iPosX_Label, $iPosY_Label, 429, 57) GUICtrlSetFont(-1, 30, 400, 0, "Comic Sans MS", 4) GUICtrlSetColor(-1, 0xC0C0D8) Global Const $iLabel_Titel = GUICtrlCreateLabel($sLabel_Titel_Txt, $iPosX_Label - 4, $iPosY_Label - 4, 429, 57) GUICtrlSetFont(-1, 30, 400, 0, "Comic Sans MS", 4) GUICtrlSetColor(-1, 0x0000C0) GUICtrlSetBkColor(-1, -2) Global Const $iPic_Histogram = GUICtrlCreatePic("", 20, 90, 255, 127, -1, $WS_EX_STATICEDGE) GUICtrlSetCursor(-1, 14) Global Const $iPic_ColorGradient = GUICtrlCreatePic("", 20, 220, 255, 24, -1, $WS_EX_STATICEDGE) Global Const $iGroup = GUICtrlCreateGroup("Channel", 290, 84, 160, 164) Global Const $iRadio_L = GUICtrlCreateRadio("Luminosit&y (gray)", 300, 100, 110, 20) GUICtrlSetTip(-1, $frY & "*R, " & $fgY & "*G, " & $fbY & "*B") GUICtrlSetState($iRadio_L, $GUI_CHECKED) Global Const $iRadio_C = GUICtrlCreateRadio("&cRGB", 300, 130, 60, 20) GUICtrlSetTip(-1, "Combined average of RGB values") Global Const $iRadio_R = GUICtrlCreateRadio("&Red", 300, 160, 60, 20) Global Const $iRadio_G = GUICtrlCreateRadio("&Green", 300, 190, 60, 20) Global Const $iRadio_B = GUICtrlCreateRadio("&Blue", 300, 220, 60, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) Global Const $iButton_Save = GUICtrlCreateButton("&Save", 209, 265, 70, 30) GUICtrlSetTip(-1, "Click button to save all histogram images") GUICtrlSetState(-1, $GUI_DISABLE) Global Const $iButton_Load = GUICtrlCreateButton("&Load", 290, 265, 70, 30) GUICtrlSetTip(-1, "Click button to load an image") Global Const $iButton_Exit = GUICtrlCreateButton("E&xit", 390, 265, 60, 30) Global $sLabelCredit_Txt = "coded by UEZ'13" Global $aLabelCredit_Pos[StringLen($sLabelCredit_Txt)][4], $u, $iFS = 6.5, $iY = 280 For $u = 0 To UBound($aLabelCredit_Pos) - 1 $aLabelCredit_Pos[$u][0] = StringMid($sLabelCredit_Txt, $u + 1, 1) $aLabelCredit_Pos[$u][1] = 20 + $u * ($iFS - 0.25) $aLabelCredit_Pos[$u][2] = $iY $aLabelCredit_Pos[$u][3] = GUICtrlCreateLabel($aLabelCredit_Pos[$u][0], $aLabelCredit_Pos[$u][1], $aLabelCredit_Pos[$u][2], $iFS, $iFS * 1.8) GUICtrlSetFont(-1, $iFS, 400, 0, "Comic Sans MS", 2) GUICtrlSetColor(-1, 0x006000) Next Global $aLabelCredit_AnimPos[300] For $u = 0 To UBound($aLabelCredit_AnimPos) - 1 $aLabelCredit_AnimPos[$u] = $iY Next Global Const $fLimes = 2.2, $fStep = 0.1 Global $iPT = 0, $z = Int((UBound($aLabelCredit_AnimPos) - ($fLimes * $fStep * 100)) / 2) For $u = 0 To $fLimes Step $fStep $aLabelCredit_AnimPos[$z] = $iY + Sin($iPT * 4) * 10 $z += 1 $iPT += 0.075 Next Global $ihGui_PreviewSize = 256, $iBGColor = 0xF0F0F0 Global $hGui_Preview = GUICreate("", $ihGui_PreviewSize, $ihGui_PreviewSize + 58, -1, -1, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST, $hGUI) Global $iPic_Preview = GUICtrlCreatePic("", 0, 0, $ihGui_PreviewSize, $ihGui_PreviewSize) Global $idLabel_Info = GUICtrlCreateLabel("", 0, $ihGui_PreviewSize, $ihGui_PreviewSize * 2, 58) GUICtrlSetFont(-1, 8.5, 400, 0, "Arial", 5) GUICtrlSetColor(-1, $iBGColor) GUICtrlSetBkColor(-1, 0x333333) Global Const $hTexture_Checkerboard = _GDIPlus_CreateCheckerboardTexture(8, 0xFFFBFBFB, 0xFFFFFFFF) Global $hHBmp_L = _GDIPlus_CreateColorGradient("L", 256, 24) Global $hHBmp_C = _GDIPlus_CreateColorGradient("C", 256, 24) Global $hHBmp_R = _GDIPlus_CreateColorGradient("R", 256, 24) Global $hHBmp_G = _GDIPlus_CreateColorGradient("G", 256, 24) Global $hHBmp_B = _GDIPlus_CreateColorGradient("B", 256, 24) Global Const $hHBmp_HL = _GDIPlus_BitmapCreateFromScan0(256, 127) Global Const $hCtxt_HL = _GDIPlus_ImageGetGraphicsContext($hHBmp_HL) Global Const $hHBmp_HC = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HC = _GDIPlus_ImageGetGraphicsContext($hHBmp_HC) Global Const $hHBmp_HR = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HR = _GDIPlus_ImageGetGraphicsContext($hHBmp_HR) Global Const $hHBmp_HG = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HG = _GDIPlus_ImageGetGraphicsContext($hHBmp_HG) Global Const $hHBmp_HB = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HB = _GDIPlus_ImageGetGraphicsContext($hHBmp_HB) _GDIPlus_GraphicsClear($hCtxt_HL, 0xFFFFFFFF) _hBmpToPicControl($iPic_ColorGradient, $hHBmp_L) Global $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HL) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) GUISetState(@SW_HIDE, $hGui_Preview) GUISetState(@SW_SHOW, $hGUI) ControlFocus($hGUI, "", $iButton_Load) Global $hPen_H = _GDIPlus_PenCreate() $s = "L" Global $iDummyL = GUICtrlCreateDummy(), $iDummyC = GUICtrlCreateDummy(), $iDummyR = GUICtrlCreateDummy(), $iDummyG = GUICtrlCreateDummy(), $iDummyB = GUICtrlCreateDummy() Global $iHistogramFormat, $hHBmp_Preview, $aPosCtrl, $aPosWin, $aMouseInfo, $aPos_hWnd, $imp, $iVal, $iMpos_oldx, $iMpos_oldy, $sType, $iPaletteType, $iPixelFormat Global $fAverage_L, $fAverage_cRGB, $iAverage_R, $iAverage_B, $iAverage_G, $o = 0 Global $bShow = False, $bHide = False, $bIsAlpha = False, $bIsGray = False Global Const $iEntries = 256 Global Const $tagCOLORPALETTE = "uint Flags;" & _ ; Palette flags "uint Count;" & _ ; Number of color entries "uint ARGB[" & $iEntries & "];" ; Palette color AdlibRegister("AnimateLabel", 60) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iButton_Exit AdlibUnRegister("AnimateLabel") GUIDelete($hGui_Preview) GUIDelete($hGUI) _WinAPI_DeleteObject($hHBmp_L) _WinAPI_DeleteObject($hHBmp_C) _WinAPI_DeleteObject($hHBmp_L) _WinAPI_DeleteObject($hHBmp_R) _WinAPI_DeleteObject($hHBmp_G) _WinAPI_DeleteObject($hHBmp_B) If $hHBmp_Preview Then _WinAPI_DeleteObject($hHBmp_Preview) _GDIPlus_PenDispose($hPen_H) _GDIPlus_BrushDispose($hTexture_Checkerboard) _GDIPlus_GraphicsDispose($hCtxt_HL) _GDIPlus_GraphicsDispose($hCtxt_HC) _GDIPlus_GraphicsDispose($hCtxt_HR) _GDIPlus_GraphicsDispose($hCtxt_HG) _GDIPlus_GraphicsDispose($hCtxt_HB) _GDIPlus_BitmapDispose($hHBmp_HL) _GDIPlus_BitmapDispose($hHBmp_HC) _GDIPlus_BitmapDispose($hHBmp_HR) _GDIPlus_BitmapDispose($hHBmp_HG) _GDIPlus_BitmapDispose($hHBmp_HB) _GDIPlus_Shutdown() $tStructChannel0 = 0 $tStructChannel1 = 0 $tStructChannel2 = 0 $tStructChannel3 = 0 Exit Case $iRadio_L, $iDummyL If $s <> "L" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_L) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HL) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "L" EndIf Case $iRadio_C, $iDummyC If $s <> "C" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_C) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HC) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "C" EndIf Case $iRadio_R, $iDummyR If $s <> "R" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_R) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HR) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "R" EndIf Case $iRadio_G, $iDummyG If $s <> "G" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_G) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HG) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "G" EndIf Case $iRadio_B, $iDummyB If $s <> "B" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_B) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HB) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "B" EndIf Case $iButton_Load $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.bmp;*.gif)", 3) If @error Then ContinueCase If $bImgLoaded Then _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_ImageLoadFromFile($sFile) If @error Then MsgBox(0x40010, "Error", "Unable to load image", 30) ContinueCase EndIf GUICtrlSetState($iButton_Save, $GUI_ENABLE) $aRes = _GDIPlus_ImageGetFlags($hImage) If BitAND($aRes[0], $GDIP_IMAGEFLAGS_HASALPHA) Then $bIsAlpha = True Else $bIsAlpha = False EndIf If BitAND($aRes[0], $GDIP_IMAGEFLAGS_COLORSPACE_GRAY) Then $bIsGray = True Else $bIsGray = False EndIf $hHBmp_Preview = _GetImage($sFile, $ihGui_PreviewSize, $iBGColor) _hBmpToPicControl($iPic_Preview, $hHBmp_Preview, 1) If Not $bIsAlpha Then $pStructChannel3 = 0 $iHistogramFormat = $HistogramFormatRGB Else $pStructChannel3 = DllStructGetPtr($tStructChannel3) $iHistogramFormat = $HistogramFormatARGB EndIf _GDIPlus_BitmapGetHistogram($hImage, $iHistogramFormat, _GDIPlus_BitmapGetHistogramSize($iHistogramFormat), $pStructChannel0, $pStructChannel1, $pStructChannel2, $pStructChannel3) _GDIPlus_CreateHistogram() $bImgLoaded = True If BitAND(GUICtrlRead($iRadio_L), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyL) ElseIf BitAND(GUICtrlRead($iRadio_C), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyC) ElseIf BitAND(GUICtrlRead($iRadio_R), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyR) ElseIf BitAND(GUICtrlRead($iRadio_G), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyG) Else $s = "" GUICtrlSendToDummy($iDummyB) EndIf Case $iButton_Save If $sFile = "" Then ContinueLoop $sType = "png" $o += _GDIPlus_ImageSaveToFile($hHBmp_HL, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Luminosity." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HC, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_cRGB." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HR, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Red." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HG, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Green." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HB, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Blue." & $sType) If $o = 5 Then MsgBox(64 + 262144, "Information", "Images properly saved to " & StringRegExpReplace($sFile, "(.*)\\.*", "$1"), 30, $hGUI) Else MsgBox(16 + 262144, "Error", "One or more images could not saved to " & StringRegExpReplace($sFile, "(.*)\\.*", "$1") & ".", 30, $hGUI) EndIf EndSwitch If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) Switch $aMouseInfo[4] Case $iPic_Histogram If $bImgLoaded Then $aPos_hWnd = WinGetPos($hGUI) $imp = Max(1, Min(256, -19 + $aMouseInfo[0])) Switch $s Case "L" $iVal = $aLuminosity[$imp] Case "C" $iVal = $aCRGB[$imp] Case "R" $iVal = DllStructGetData($tStructChannel0, "channel0", $imp) Case "G" $iVal = DllStructGetData($tStructChannel1, "channel1", $imp) Case "B" $iVal = DllStructGetData($tStructChannel2, "channel2", $imp) EndSwitch If $iMpos_oldx <> $aMouseInfo[0] Or $iMpos_oldy <> $aMouseInfo[1] Then ToolTip("Index: " & $imp & ", Value: " & Round($iVal, 0) & ", Average: " & Round($fAverage_L, 2), $aPos_hWnd[0] + $aMouseInfo[0] - 60, $aMouseInfo[1] + $aPos_hWnd[1] - 20) $iMpos_oldx = $aMouseInfo[0] $iMpos_oldy = $aMouseInfo[1] EndIf ShowPreview($iPic_Histogram) $bShow = True $bHide = False EndIf Case Else If Not $bHide Then GUISetState(@SW_HIDE, $hGui_Preview) $bHide = True ToolTip("") EndIf $bShow = False EndSwitch EndIf WEnd Func AnimateLabel() Local Static $v = Int((UBound($aLabelCredit_AnimPos) - ($fLimes * $fStep * 100)) / 2) Local $u For $u = 0 To UBound($aLabelCredit_Pos) - 1 GUICtrlSetPos($aLabelCredit_Pos[$u][3], $aLabelCredit_Pos[$u][1], $aLabelCredit_AnimPos[$v - $u]) Next If $v - $u < 0 Then $v = UBound($aLabelCredit_AnimPos) - 1 $v -= 1 EndFunc ;==>AnimateLabel Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc ;==>Min Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc ;==>Max Func ShowPreview($iCtrl) $aPosWin = WinGetPos($hGUI) $aPosCtrl = ControlGetPos($hGUI, "", $iCtrl) Local $iNewX, $iNewX1 = $aPosWin[0] - $ihGui_PreviewSize + 10, $iNewX2 = $aPosWin[0] + $aPosWin[2] - 10 $iNewX = $iNewX1 If $iNewX1 < $aFullScreen[0] Then $iNewX = $iNewX2 EndIf WinMove($hGui_Preview, "", $iNewX, $aPosWin[1] + 50) GUISetState(@SW_SHOWNOACTIVATE, $hGui_Preview) EndFunc ;==>ShowPreview Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF, $bCheckerboard_Bg = True) Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2, $aFTS $aFTS = FileGetTime($sFile) If @error Then Return SetError(1, 0, 0) $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hBmp1) $hImage = _GDIPlus_ImageLoadFromFile($sFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) GUICtrlSetData($idLabel_Info, StringRegExpReplace($sFile, ".*\\(.*)", "$1") & @LF & Round(FileGetSize($sFile) / 1024, 0) & " kb (" & $iW & " x " & $iH & ")" & @LF & $aFTS[0] & "/" & $aFTS[1] & "/" & $aFTS[2] & " " & $aFTS[3] & ":" & $aFTS[4] & ":" & $aFTS[5] & @LF & "Alpha: " & $bIsAlpha & ", Gray: " & $bIsGray) $aGS = _GetScale($iW, $iH, $iWH) Switch $bCheckerboard_Bg Case True ;~ _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWH, $iWH, $hTexture_Checkerboard) _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) _GDIPlus_GraphicsFillRect($hGraphic, $aGS[0], $aGS[1], $aGS[2], $aGS[3], $hTexture_Checkerboard) Case False _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) EndSwitch _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hBmp2 EndFunc ;==>_GetImage Func _GetScale($iW, $iH, $iWH) Local $aRet[4] If $iW <= $iWH And $iH <= $iWH Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW > $iH Then $aRet[2] = $iWH $aRet[3] = $iH / ($iW / $iWH) $aRet[0] = 0 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW < $iH Then $aRet[2] = $iW / ($iH / $iWH) $aRet[3] = $iWH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $iWH $aRet[3] = $iWH $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc ;==>_GetScale Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0) Local $hOldBmp $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp) If $iFlag Then _WinAPI_DeleteObject($hBmp) EndFunc ;==>_hBmpToPicControl Func _GDIPlus_CreateHistogram($sRounding = "Ceiling") Local $iMaxL, $iMaxC, $iMaxR, $iMaxG, $iMaxB, $a, $r, $g, $b, $yR, $yG, $yB, $iRedAv, $iGreenAv, $iBlueAv For $i = 1 + $bIsAlpha To 256 If $bIsAlpha Then ;~ ConsoleWrite("Alpha: " & DllStructGetData($tStructChannel0, "channel0", $i) & @CRLF) $r = DllStructGetData($tStructChannel1, "channel1", $i) $yR = $r * $frY If DllStructGetData($tStructChannel1 , "channel1", $i) > $iMaxR Then $iMaxR = $r $g = DllStructGetData($tStructChannel2, "channel2", $i) $yG = $g * $fgY If DllStructGetData($tStructChannel2 , "channel2", $i) > $iMaxG Then $iMaxG = $g $b = DllStructGetData($tStructChannel3, "channel3", $i) $yB = $b * $fbY If DllStructGetData($tStructChannel3 , "channel3", $i) > $iMaxB Then $iMaxB = $b $fAverage_cRGB += $r + $g + $b $fAverage_L += $yR + $yG + $yB Else $r = DllStructGetData($tStructChannel0, "channel0", $i) $yR = $r * $frY If DllStructGetData($tStructChannel0 , "channel0", $i) > $iMaxR Then $iMaxR = $r $g = DllStructGetData($tStructChannel1, "channel1", $i) $yG = $g * $fgY If DllStructGetData($tStructChannel1 , "channel1", $i) > $iMaxG Then $iMaxG = $g $b = DllStructGetData($tStructChannel2, "channel2", $i) $yB = $b * $fbY If DllStructGetData($tStructChannel2 , "channel2", $i) > $iMaxB Then $iMaxB = $b EndIf $fAverage_cRGB += $r + $g + $b $fAverage_L += $yR + $yG + $yB $aLuminosity[$i] = $yR + $yG + $yB If $aLuminosity[$i] > $iMaxL Then $iMaxL = $aLuminosity[$i] $aCRGB[$i] = ($r + $g + $b) / 3 If $aCRGB[$i] > $iMaxC Then $iMaxC = $aCRGB[$i] Next $fAverage_cRGB /= 256 * 3 $fAverage_L /= 256 _GDIPlus_GraphicsClear($hCtxt_HL, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HC, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HR, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HG, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HB, 0xFFFFFFFF) Local $iDL = 1, $iDC = 1, $iDR = 1, $iDG = 1, $iDB = 1 Local $sRoundings = "Round,Ceiling,Floor," If Not StringInStr($sRoundings, $sRounding) Then $sRounding = "Ceiling" If $iMaxL > 128 Then ;~ $iDL = Ceiling($iMaxL / 128) $iDL = Execute($sRounding & "(" & $iMaxL / 128 & ")") Else $iDL = 1 / (128 / $iMaxL) EndIf If $iMaxC > 128 Then ;~ $iDC = Ceiling($iMaxC / 128) $iDC = Execute($sRounding & "(" & $iMaxC / 128 & ")") Else $iDC = 1 / (128 / $iMaxC) EndIf If $iMaxR > 128 Then ;~ $iDR = Ceiling($iMaxR / 128) $iDR = Execute($sRounding & "(" & $iMaxR / 128 & ")") Else $iDR = 1 / (128 / $iMaxR) EndIf If $iMaxG > 128 Then ;~ $iDG = Ceiling($iMaxG / 128) $iDG = Execute($sRounding & "(" & $iMaxG / 128 & ")") Else $iDG = 1 / (128 / $iMaxG) EndIf If $iMaxB > 128 Then ;~ $iDB = Ceiling($iMaxB / 128) $iDB = Execute($sRounding & "(" & $iMaxB / 128 & ")") Else $iDB = 1 / (128 / $iMaxB) EndIf For $i = 1 To 256 _GDIPlus_PenSetColor($hPen_H, 0xFF000000) _GDIPlus_GraphicsDrawLine($hCtxt_HL, $i - 1, 127, $i - 1, 127 - (Int($aLuminosity[$i] / $iDL)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF000000) _GDIPlus_GraphicsDrawLine($hCtxt_HC, $i - 1, 127, $i - 1, 127 - (Int($aCRGB[$i] / $iDC)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFFB00000) If $bIsAlpha Then _GDIPlus_GraphicsDrawLine($hCtxt_HR, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel1, "channel1", $i) / $iDR)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF00B000) _GDIPlus_GraphicsDrawLine($hCtxt_HG, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel2, "channel2", $i) / $iDG)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF0000B0) _GDIPlus_GraphicsDrawLine($hCtxt_HB, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel3, "channel3", $i) / $iDB)), $hPen_H) Else _GDIPlus_GraphicsDrawLine($hCtxt_HR, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel0, "channel0", $i) / $iDR)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF00B000) _GDIPlus_GraphicsDrawLine($hCtxt_HG, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel1, "channel1", $i) / $iDG)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF0000B0) _GDIPlus_GraphicsDrawLine($hCtxt_HB, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel2, "channel2", $i) / $iDB)), $hPen_H) EndIf Next EndFunc ;==>_GDIPlus_CreateHistogram Func _GDIPlus_CreateColorGradient($sColorChannel, $iW, $iH, $bHBitmap = True) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;~ _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) Local $hPen = _GDIPlus_PenCreate() _GDIPlus_PenSetLineJoin($hPen, $iLineJoinBevel) Local $i, $c For $i = 0 To $iW $c = Hex($i, 2) Switch $sColorChannel Case "L" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & $c & $c) Case "C" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & $c & $c) Case "R" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & "0000") Case "G" _GDIPlus_PenSetColor($hPen, "0xFF00" & $c & "00") Case "B" _GDIPlus_PenSetColor($hPen, "0xFF0000" & $c) EndSwitch _GDIPlus_GraphicsDrawLine($hCtxt, $i, 0, $i, $iH, $hPen) Next _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_PenDispose($hPen) If $bHBitmap Then Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>_GDIPlus_CreateColorGradient Func _GDIPlus_CreateCheckerboardTexture($iSquareSize = 80, $iCol1 = 0xFFECECEC, $iCol2 = 0xFFDFDFDF) Local $hPatternBitmap = _GDIPlus_BitmapCreateFromScan0(2 * $iSquareSize, 2 * $iSquareSize) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hPatternBitmap) Local $hBrush0 = _GDIPlus_BrushCreateSolid($iCol1) Local $hBrush1 = _GDIPlus_BrushCreateSolid($iCol2) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iSquareSize, $iSquareSize, $hBrush0) _GDIPlus_GraphicsFillRect($hCtxt, $iSquareSize, 0, $iSquareSize, $iSquareSize, $hBrush1) _GDIPlus_GraphicsFillRect($hCtxt, 0, $iSquareSize, $iSquareSize, $iSquareSize, $hBrush1) _GDIPlus_GraphicsFillRect($hCtxt, $iSquareSize, $iSquareSize, $iSquareSize, $iSquareSize, $hBrush0) Local $hTexture = _GDIPlus_TextureCreate($hPatternBitmap) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hPatternBitmap) _GDIPlus_BitmapDispose($hBrush0) _GDIPlus_BitmapDispose($hBrush1) Return $hTexture EndFunc ;==>_CreatePatternTexture GdipBitmapGetHistogram(), GdipBitmapGetHistogramSize() and 2 more GDI+ functions requires GDI+ v1.1 which means this will only run on Vista or higher operating systems. I hope the values are correct especially the value for luminosity. Br, UEZ
  8. Hello I have problem with my object drawn in gdi Func drawTriangle($tabName,$gui_active = 0) _GDIPlus_Startup() ;initialize GDI+ Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($sGUI[$gui_active]) ;create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEFEFEF) ;color format AARRGGBB (hex) Local $aPoints[5][3] $aPoints[0][0] = 4 $aPoints[1][0] = 0.0 ; left $aPoints[1][1] = 0.0 ; top $aPoints[2][0] = 0.0 ; left $aPoints[2][1] = 30.0 ; top $aPoints[3][0] = 80.0 ; left $aPoints[3][1] = 30.0 ; top $aPoints[4][0] = 110.0 ; left $aPoints[4][1] = 0.0 ; top _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) ;draw the triangle Local $fBrush = _GDIPlus_BrushCreateSolid(0xFFAAAAAA) ;color format AARRGGBB (hex) Local $sString = $tabName, $aInfo ; from the func param Local $hFormat, $hFamily, $hFont, $tLayout $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI") $hFont = _GDIPlus_FontCreate($hFamily, 12, 2) $tLayout = _GDIPlus_RectFCreate(6, 2) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $fBrush) ;_GDIPlus_GraphicsDrawString($hGraphics, $tabName, 6, 3, "Segoe UI", 12) ; write text ;cleanup GDI+ resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() EndFunc After this code execution I got new object rectangle Global $ma_border = GUICtrlCreateGraphic(100, 180, 40, 40) GUICtrlSetGraphic($ma_border, $GUI_GR_COLOR, 0x00000, $COLOR_BLUE) GUICtrlSetGraphic($ma_border, $GUI_GR_RECT, 0, 0, 40, 40) GUICtrlSetState(-1,$GUI_DISABLE) And what happens is first func = draw rectangle is pushed to parameters from GUICtrlCreateGraphic func. Left: 100, Top: 180. I can simplu reverse order of these func execution but There is too much things to change in my code. Can something be done to prevent this slipping?
  9. Here some useless graphical examples using GDI+, made for fun (my 1st GDI+ codes ): !Some examples may run slowly on WinXP machines (workaround in this thread)! Some examples using Hex() function need adjustment when running on AutoIt version 3.3.8.0+ otherwise colors are flashing (fixed versions in AiO package below)!!! #01 Flying Pearl Necklaces: Source code here (577 downloads previously)! Flying Pearl Necklaces.au3 #02 Flying Squares: Source code here (265 downloads previously)! Flying Squares.au3 #03 Rotating Squares: Source code here! Rotating_Squares.au3 #04 Plasma & Plasma Variant: Source codes here! Plasma: Plasma.au3 Plasma Variant: Plasma Variante.au3 #05 L-System Fractals: Source code here (382 downloads previously)! L-System Fractals.7z #06 Sinus Scroller: Source code here (218 downloads previously)! Sinus Scroller.au3 #07 Visualization: Analog Meter: download here (including source, needed files and compiled exe): Source code + needed files here (473 downloads previously)! Visualizer_Analog Meter.7z More GDI+ visualizations here by monoceres or by Eukalyptus Audio Visualization Collection (German site) #08 Particle Catapult: Source code here (70 downloads previously)! Particle_Catapult.au3 #09 Rotating Cube: Source code here (79 downloads previously)! Rotating_Cube.au3 #10 Simple Ball Collision Simulation: Source code here (35 downloads previously)! Simple_Ball_Collision_Simulation.au3 (it is not finished yet! look from time to time into this thread for an update! Nice tutorial here) #11 Particle Explosions: Source code here: Explosions__from_AutoIteroids_.au3 #12 Rotating Letters: Source codes here: Rotating Letters.au3 Transparent version (87 downloads previously): Rotating Letters Transparent.au3 #13 Rotating Cube 2: Source code here (53 downloads previously): Rotating Cube 2.au3 #14 Rotating Cube 2 with Textures: Source code here (68 downloads previously): Rotating Cube 2 + Textures.7z #15 Rotating Cube 2 with some examples from above on each surface: Source code here (55 downloads previously): Rotating Cube 2 + animated surfaces.7z #16 Rotating Cube 2 simple: Source code here: Rotating Cube 2 - Simple.au3 Or with background pic or Rotating Cube 2 simple + Background #17 Tramp of Particles: Source code here: Tramp of Particles.au3 #18 Twister: Source code here: Twister.au3 WinAPI version is 2.5x faster (look in AiO archive)! #19 Star Burst: Source code here: Star Burst.au3 #20 Warp Starfield: Source code here: Warp Starfield.au3 #21 Plasma 2: Source code here: Plasma 2.au3 #22 Isometric Level-3 Cube: Source code here: Isometric Level-3 Cube.au3 #23 Zoomer: Source code here (7 downloads previously): Zoomer.au3 GDIP.au3 needed for Zoomer! #24 Suspended Cloth Simulation: Source code here: Suspended Cloth Simulation.au3 #25 Visualizer: Oscilloscope Farbrausch: Source code here (30 downloads previously): Visualizer Oscilloscope Farbrausch.au3 To run Visualizer Oscilloscope Farbrausch.au3 properly you need following files: Bass.au3, BassExt.au3, Bass.dll and BassExt.dll. These files can be found in AiO package or on German AutoIt site! #26 Im- Exploding Particle Logo: Source code here: Im- Exploding Particle Logo.7z #27 Pixel Text Effect: Source code here (12 downloads previously): Pixel Text Effect.7z or with ♬chip sound♫ aka demo style (download from German AutoIt site or from AiO archive). #27 works best on Vista+ machines! #28 Star Wars Scroller: Source code here: Star Wars Scroller.au3 For a complete Star Wars Intro have a look to eukalyptus' Star-Wars Intro (see below!) #29 Rotated Letters Simple: Source code here: Rotated Letters Simple.au3 #30 Ballet of Letters: Source code here: Ballet of Letters.au3 #31 Perfect Illusion: Source code here: Perfect Illusion Variant 1.au3 Perfect Illusion Variant 2.au3 Perfect Illusion Variant 3.au3 Mesmerizing Squares Screensaver (previous downloads approx. 100): Mesmerizing_Squares_Screensaver.au3 (compiled version here): Don't stare too long on it or you will be mesmerized One more: Rotating triangle + vertical scroller + music (modification of monoceres' code): Magic Lines Screesaver (110 downloads previously): Magic Lines Screensaver.7z Another screensaver - 3D Star Scrolling Screensaver (83 downloads previously): GDI+ 3D Star Scrolling Screensaver.au3 !Some examples may run slowly on WinXP machines (workaround in this thread)! Some examples using Hex() function need adjustment when running on AutoIt version 3.3.8.0+ otherwise colors are flashing (fixed versions in AiO package below)!!! AiO download link ☞ AiO1 or AiO2 ☜ (all examples above compiled + source codes packed with 7-Zip) Have a look also to the game I made using GDI+: Link: AUTOITEROIDS v1.018 Build 2011-06-09 (Final) (a clone of the game Asteroids made by Atari 1979) I hope you like it! Any kind of comment is welcome!!! My examples are all done with AutoIt v3.3.0.0 on Vista x32! Kudos to: monoceres, smashly, malkey, Eukalyptus and Authenticity! Check out Some Graphical Examples using GDI+ Vol. II build 2016-01-25 More examples made by other members in this thread (thanks you very much!): Spinning Flying Pearl Necklaces by smashly: Spinning Flying Squares by smashly and ProgAndy LMP Visualization by youknowwho4eva: SineWorm by monoceres: Enterprise Warp by youknowwho4eva: Confused ASCII by monoceres: Lissajous Curve by monoceres: Butterfly Curve by monoceres: ParticleCollisionFun2 by crashdemons: Extreme nice physic engine by moritz1243 (German site): Lingering Line by MvGulik: Scroller Sine Blobs by Lakes: Cube surface and 3D axis and by Lakes: by eukalyptus: by eukalyptus: Two more examples by eukalyptus: and FEEL FREE TO POST YOUR GDI+ EXAMPLES HERE,TOO!!! Have fun and regards, UEZ ✌ PS: more modified examples also here in this topic History of my useless scripts above:
  10. wakillon

    Pic2Vector

    Version 1.0.1.4

    1,355 downloads

    Pic2Vector permit to easily convert bitmap Images to clean Vector Art and save it result to jpg, png, bmp or gif format. See Topic for more details and examples.
  11. Can someone please explain me why a graphic control can't overlap a picture? My gui uses a background picture and a graphic that overlaps. it doesn't matter what I try, the picture always overlaps the graphic control... this doesn't help either: Graphic control can be clicked so they should not overlap with other controls. If overlap is needed it is important to disable the graphic control : GUICtrlSetState(-1, $GUI_DISABLE).regards
  12. Can someone tell me why this code is not working? I am unable to copy the file to a directory. #include <GDIPlus.au3> #include <ScreenCapture.au3> Example() Func Example() Local $hBitmap, $hClone, $hImage, $iX, $iY ; Initialize GDI+ library _GDIPlus_Startup() ; Capture 32 bit bitmap $hBitmap = _ScreenCapture_Capture(@ScriptDir & "\temp.jpg", 300, 300, 900, 900) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; Create 24 bit bitmap clone $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hClone, @ScriptDir & "\GDIPlus_Image66.bmp") ; Clean up resources _GDIPlus_ImageDispose($hClone) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap) ; Shut down GDI+ library _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\GDIPlus_Image66.bmp") EndFunc ;==>Example .
  13. May be some of you know the shareware VectorMagic who permit to easily convert bitmap Images to clean Vector Art ! Pic2Vector 1.0.1.4 is free, and can give similar effects ! I was interested by some effects added to a photo. I'm not using gdi for the vectorization, but 2 command line tools : Autotrace 0.27 with ILDA file support for converting bitmap to vector graphics Custom Version at : http://www.raycomposer.de/en/ressources/autotrace/ More general infos : http://autotrace.sourceforge.net/ GPL Ghostscript 9.07 use here for converting vector graphics to Jpeg. More infos : http://www.ghostscript.com/doc/9.07/Use.htm# example 1 example 2 example 3 example 4 example 5 example 6 example 7 example 8 Free to you to play with settings for see changes.(Infos with tooltip added to each type of setting) If UAC Enable, use right click, execute as Admin. Click on vectorized Pic for display it in fullscreen with Windows picture Viewer. You can save result to jpg, png, bmp or gif format. Changes Version 1.0.1.4 Settings can be saved by creating a profil. No more appcrash window for autotrace.exe. New buttons for display compatibility with xp. Externals files are embedded, no more downloads needed. Some minor improvements. Added new examples to topic. Tested with WinXp, Win7 and Win 8.1. previous downloads : 666 source and executable are available in the Download Section Hope you like it !
  14. UDF provide graphical control based on static class. Button Progressbar v1.01. Fix on Syntax Error Checking Download Choose server where you will download: fxControl.zip - code.google.com (renamed from zettoControl_v1.02.zip) fxControl.zip - autoitscript.com The next version of this UDF will named as fxControl (Control Framework). Screenshot Sample Application using zettoControl Z-Compressor [link fixed] Clean PC Clean PC Source available in spoiler below 'Codice Sorgente' text, in that page. but download link: dead. Its still useful because at least the source are here while you able replace image file with what you have. zettoControl_v1.02.zip
×
×
  • Create New...