AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Efficient binary objects embedding in AHK code - ASCII 85
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Mon Mar 17, 2008 10:14 am    Post subject: Efficient binary objects embedding in AHK code - ASCII 85 Reply with quote

Hi all

So here it is at last... Please read full (huge) post before asking...

With the library Ascii85, you can embed binary data into your AHK code at lower cost in size, and with the high speed of native assembly programming, thus allowing you to not use external references for eg icons, bitmaps, or any other ressource you might imagine. Explanation of ASCII85 code is there.

Code:

/*
    AHK Ascii 85 encoder/decoder - v1.0
    Recommanded fileName : Ascii85.ahk
    Author : LHdx 2008/03
    Permission is granted to use copy for commercial or non commercial use provided credit to author is explicitely given.

    USE AT YOUR OWN RISKS !

    Base reference : http://www.autohotkey.com/forum/viewtopic.php?t=21172

    Usage :
    1) Preliminary : needs MCode.ahk (see http://www.autohotkey.com/forum/viewtopic.php?p=180448#180448)
    2) To encode, either directly call Encoder() or call AhkEncoder()
    3) To decode, if you know the source you want to encode, you can call directly Decoder() but in this procedure there is strictly
       no check to protect from crash ! Or you can call DecodeSize() first to help you identify needed memory allocation and validity of
       source ASCII85 code, then allocate accordingly and finally call Decoder(). Or forget all this stuff and call AhkDecoder().
    4) Complements :
        * The low level code is BY DESIGN not Adobe compliant. To make it adobe-compliant for Encoder(), you must either prepend "<~" and
          append "~>" to text after calling Encoder(), or use high level AhkEncode(). If you wish to decode adobe-compliant ASCII85, you
          muse either remove manually <~~> *before* calling DecoderSize()/Decoder(). Failure to do so results in ASCII85 code
          not being decoded (since ~ is invalid in ASCII85).
        * This code does not support v4.2 extesion ('y' token to replace a 4 spaces block). You can have a workaround by replacing
          every "y" by "+<VdL" which is the encoding for 4 spaces using StringReplace.
        * The DecoderSize() and Decoder() both accept spaces in source ASCII85 buffer, where spaces are ' ', CR, LF.
        * Low level functions are not fully AHK-ready to enable their use not only to embed code, but to be able to use ASCII85
          for other general purposes.
*/

; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-
;  High level functions
; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-

/*
  Ascii85_AhkEncoder(ByRef SourceText, SourceSize, ByRef DestinationMemory, NbBytesPerLine=70, UseAdobeEncoding=0)
  Input :
    SourceText : variable containing binary data to encode (must be a variable)
    SourceSize : number of bytes to encode
    DestinationMemory : variable where encoded data will be stored. (Re-)Allocation is automatic
    NbBytesPerLine : will specify how many bytes to store in each line, lines will be separated by CR/LF. you may specify 0xFFFFFFFF to
      have no line break in output buffer.
    UseAdobeEncoding (optional) : specifies, if not 0, that we want the Adobe ASCII85 prefix and suffix in encoded data.
      In this case, for 1st and last lines of ASCII85 encoded data might be slightly larger than NbBytesPerLine.
  Output :
    Returns the number of bytes really stored into DestinationMemory
  Comments :
    This function should be safe
*/

Ascii85_AhkEncoder(ByRef SourceText, SourceSize, ByRef DestinationMemory, NbBytesPerLine=70, UseAdobeEncoding=0)
{
    Delta:=0 ; Dunno why this one is needed here, but is missing, bad results !
    MemNeeded := ((SourceSize + 3) // 4) * 5
    If (NbBytesPerLine)
        MemNeeded += (MemNeeded + NbBytesPerLine - 1) // NbBytesPerLine * 2 + 1 ; add 1 for trailing '\0'
    If (UseAdobeEncoding) {
        MemNeeded += 4
        Delta := 2
    }
    VarSetCapacity(DestinationMemory, MemNeeded)
    TotalBytes:=Ascii85_Encoder(&SourceText, SourceSize, &DestinationMemory + Delta, NbBytesPerLine)
    If (UseAdobeEncoding) {
        NumPut(0x7E3C, DestinationMemory, 0, "UShort")
        NumPut(0x3E7E, DestinationMemory, TotalBytes+Delta, "UShort")
    }
    NumPut(0, DestinationMemory, TotalBytes + Delta * 2, "UChar")
    VarSetCapacity(DestinationMemory, -1)
    Return TotalBytes + Delta * 2
}

/*
  Ascii85_AhkEmbedParser(ByRef SourceText, ByRef DestinationMemory)
  Input :
    SourceText : variable containing ASCII 85 encoded data
    SourceSize : number of bytes to encode
    DestinationMemory : variable where parsed data will be stored
  Output :
    none
  Comments :
    Use this function on data you just encoded to be able to copy/paste it into your AHK code
    This is mandatory to avoid AHK (tested : v1.0.47.5) complaining about mismatched '%', excessive ',' or invalid text after ')' in
    a continuation section.
*/
Ascii85_AhkEmbedParser(ByRef SourceText, ByRef DestinationMemory)
{
    StringReplace, DestinationMemory, SourceText, ``, ````, All
    StringReplace, DestinationMemory, DestinationMemory, `%, ```%, All
    StringReplace, DestinationMemory, DestinationMemory, `), ```), All
}

; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-

/*
  Ascii85_AhkDecoder(ByRef SourceText, ByRef DestinationMemory, SourceSize, NbBytesPerLine=70, UseAdobeEncoding=0)
  Input :
    SourceText : variable containing ASCI85 data to decode (must be a variable)
    DestinationMemory : variable where binary data will be stored. (Re-)Allocation is automatic
    SourceSize (optional) : number of bytes to decode. If missing, SourceText *must* be zero-terminated
  Output :
    Returns the number of bytes really stored into DestinationMemory
  Comments :
    This function should be safe
*/

Ascii85_AhkDecoder(ByRef SourceText, ByRef DestinationMemory, SourceSize=0xFFFFFFFF)
{
    BaseAddress := &SourceText
    If (NumGet(SourceText, 0, "UShort") = 0x7E3C) {
        ; We must check size if we don't have it : decoder doesn't recognize Adobe's pre/post-fixes so we'll remove them now
        If (SourceSize = 0xFFFFFFFF)
            SourceSize := StrLen(SourceText)
        If (NumGet(SourceText, SourceSize - 2, "UShort") = 0x3E7E) {
            BaseAddress += 2
            SourceSize -= 4
        }
    }
    Result := Ascii85_DecoderSize(BaseAddress, SourceSize)
    If (Result = 0 || Result >= 0xFFFFFFFE)
        Return Result
    VarSetCapacity(DestinationMemory, Result)
    Return % Ascii85_Decoder(BaseAddress, SourceSize, &DestinationMemory)
}

; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-
;  Low level functions
; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-

/*
  Ascii85_Encoder(SourceText, SourceSize, DestinationMemory, NbBytesPerLine)
  Input :
    SourceText : pointer to memory containing binary data to encode
    SourceSize : number of bytes to encode
    DestinationMemory : pointer to memory where encoded data will be put (must be pre-allocated with VarSetCapacity, for instance)
    NbBytesPerLine : will specify how many bytes to store in each line, lines will be separated by CR/LF. you may specify 0xFFFFFFFF to
      have no line break in output buffer.
  Output :
    Returns the number of bytes really stored into DestinationMemory
  Comments :
    WARNING : no capacity check is made on Output, so be sure memory buffer is large enough. For S source size reserve at least
    M0=I((S+3)/4)*5) where I means integral part (drop comma) [note : let x,n integers, (x+n-1)/n <=> x/n rounded up].
    To add line breaks every N chars, reserve (total) M0+I((M0+N-1)/N)*2
    If you whish to add C trailing '\0', reserve one more.
    If you wish to inject data into Adobe format, reserve 4 bytes more for header "<~" and trailer "~>", and add 2 to &DestinationMemory
    during Encoder() call.
*/

Ascii85_Encoder(SourceText, SourceSize, DestinationMemory, NbBytesPerLine)
{
    Static lMcode
    if (!lMcode) {
        lHcode := "60e81a0000000100000055000000391c0000ed5e0900b1841c030203041810085b89e583c51c83ec048b45148945e0fc8b75088b7d108b4d0c09c9745d83f904"
        lHcode := lHcode . "7231ad0fc809c0750cb07ae86a000000e9190000005131c9b10583c31483eb0431d2f733e84f00000089d0e2f05983e904ebc651c1e008ace2fa59518a4c0b16"
        lHcode := lHcode . "d3e0598a4c0b1383c31483eb0431d2f733e82200000089d0e2f08b451483f8ff740b3b45e0740666b80d0a66ab2b7d10897d0083c40461c30421aa8b45e083e8"
        lHcode := lHcode . "01750966b80d0a66ab8b45148945e0c3"
        MCode(lMcode, lHcode)
    }
    Return DllCall(&lMcode, "UInt", SourceText, "UInt", SourceSize, "UInt", DestinationMemory, "UInt", NbBytesPerLine, "cdecl UInt")
}

; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-

/*
  Ascii85_DecoderSize(SourceText, SourceSize)
  Input :
    SourceText : ASCII data to bring back to binary
    SourceSize : number of ASCII char to decode
  Output :
    -2 if the code is not pure ASCII85
    -1 if there is a problem while decoding (incomplete last block, for instance)
    >=0 is the size of memory buffer needed to decode the source file given.
  Comments :
    Call this function if unsure of decoded result size or validity. If you trust the source (you made the encoding yourself), you can
    skip this function and directly call Decoder() using the right data and rightly allocated memory buffer for destination.
*/

Ascii85_DecoderSize(SourceText, SourceSize)
{
    Static lMcode
    if (!lMcode) {
        lHcode := "608b6c240c83ed0431d231c9fc8b750809f6744b8b5d0ce84d00000074353c7a750583c204ebf0b1053c2172123c75770ee833000000e0f1740f83c204ebdfbafeffffffe9"
        lHcode := lHcode . "1b00000080f904741183c20429ca09db740d8b5d0c83fbff7405baffffffff89550061c309db7416ac4b08c074103c2074f23c0974ee3c0d74ea3c0a74e6c3"
        MCode(lMcode, lHcode)
    }
    Return DllCall(&lMcode, "UInt", SourceText, "UInt", SourceSize, "cdecl UInt")
}

; -=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-

/*
  Ascii85_Decoder(SourceText, SourceSize, DestinationMemory)
  Input :
    SourceText : ASCII data to bring back to binary
    SourceSize : number of ASCII char to decode
    DestinationMemory : pointer to memory where decoded binary data will be put (must be pre-allocated with VarSetCapacity, for instance)
  Output :
    The number of bytes written in DestinationMemory.
  Comments :
    Call this function using a large enough buffer for MemoryDestination - use DecoderSize if you're unsure of the buffer capacity needed.
    Decoder() does no check and can therefor crash AHK if misused (invalid input buffer or insufficient allocation for DestinationMemory).
    The functions have been separated only for those who know exactly what they do to be able to achieve higher decoding speed.
*/

Ascii85_Decoder(SourceText, SourceSize, DestinationMemory)
{
    Static lMcode
    if (!lMcode) {
        lHcode := "608b6c240c83ed0431d231c9fc8b75088b7d108b5d0c31c0e84f00000074453c7a750531c0abebeeb1042c2189c231c0e83700000074132c215031c0b055f7e25a01d0e2"
        lHcode := lHcode . "e70fc8abebcc5131c0b055f7e283c05489c2e2f359f7d983c104c1c008aae2fa2b7d10897d0061c309db7416ac4b08c074103c2074f23c0974ee3c0d74ea3c0a74e6c3"
        MCode(lMcode, lHcode)
    }
    Return DllCall(&lMcode, "UInt", SourceText, "UInt", SourceSize, "UInt", DestinationMemory, "cdecl UInt")
}


To run this library, you'll need the MCode library (here's mine ASM coded, or the original AHK one posted by Lazslo there).

To achieve the highest possible efficency, use "low level" functions. To simplify your code at most without needing to worry, use "high level" functions.

There are samples both for encoding and for decoding, using either low level or high level. For full documentation, read inside source code.

Low level encoding :
Code:

; Find it here...
#include Ascii85.ahk

; Find it at http://www.autohotkey.com/forum/viewtopic.php?p=44718#44718
#include BinReadWrite.ahk

; Here starts the sample
; We need the following "standard" libraries :
;  - MCode : http://www.autohotkey.com/forum/viewtopic.php?p=180448#180448 or http://www.autohotkey.com/forum/viewtopic.php?p=135302#135302
;  - PhilLo's binary files routines : http://www.autohotkey.com/forum/viewtopic.php?p=44718#44718
;  - (of course) Ascii85

LineLength=70

; read PNG
VarSetCapacity(Input, 100000)
h:=OpenFileForRead("AutoHotkey_logo.png") ; file taken at http://www.autohotkey.com/docs/images/AutoHotkey_logo.gif
BinarySize:=ReadFromFile(h, Input, 0, FILE_BEGIN)
CloseFile(h)

; compute converted size
neededmemory := (BinarySize+3)/4*5 ; Cost of BIN->ASCII85 conversion
neededmemory += (neededmemory + LineLength - 1) / LineLength * 2 ; Cost of adding CR/LF if wanted
neededmemory += 5 ; if you want to add Adobe 'prefix "<~" and postfix "~>" and string ending \0

; allocate memory
VarSetCapacity(Output,neededmemory)

; convert PNG to ASCII85
OutputSize:=Ascii85_Encoder(&Input, BinarySize, &Output, LineLength)

; append '\0' and inform AHK of text size
NumPut(0, Output, OutputSize, "char")
VarSetCapacity(Output, -1)

; convert to enable AHK inlining
Ascii85_AhkEmbedParser(Output, Output)

; Write ASCII85 conversion of png
FileDelete, logo.asc
FileAppend, %Output%, logo.asc


High level encoding :
Code:

; Find it here...
#include Ascii85.ahk

; Find it at http://www.autohotkey.com/forum/viewtopic.php?p=44718#44718
#include BinReadWrite.ahk

; Here starts the sample
; We need the following libraries :
;  - MCode : http://www.autohotkey.com/forum/viewtopic.php?p=180448#180448 or http://www.autohotkey.com/forum/viewtopic.php?p=135302#135302
;  - PhilLo's binary files routines : http://www.autohotkey.com/forum/viewtopic.php?p=44718#44718
;  - (of course) Ascii85

LineLength=70

; read PNG
VarSetCapacity(Input, 100000)
h:=OpenFileForRead("AutoHotkey_logo.png") ; file taken at http://www.autohotkey.com/docs/images/AutoHotkey_logo.gif
BinarySize:=ReadFromFile(h, Input, 0, FILE_BEGIN)
CloseFile(h)

; convert it
OutputSize:=Ascii85_AhkEncoder(Input, BinarySize, Output, LineLength)

; convert to enable AHK inlining
Ascii85_AhkEmbedParser(Output, Output)

; Write ASCII85 conversion of png
FileDelete, logo.asc
FileAppend, %Output%, logo.asc


Low level decoding and use :
Code:

#include Ascii85.ahk

; This one is AHK's, snapshoted out of forum main page - Hope Chris won't fire me out of forum :-)
Logo =
(
   M,6r;`%14!\!!!!.8Ou6I!!!#[!!!"Q#Qk&,!.5rc5QCcd!`)Q?g75ct\<26sqdF_p2``ocaT
   EP0\6CMT$amtQ(n^<"B;ZFn?5k+&0<6^4[nda6/(pTqos<`%jJiMhtP@>&703N0^!-UrfX<
   XH/CRFaJJC\@-e`)hUpc@U>YVBs8Um7jT#8\zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
   zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
   zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!2h:Q#64
   ``($#iF<ErZ1J&c_n>&cpG:If'0G`)K/285u``*!m9L*0UH#GOG\`%.58P*2("6':[bGul0``ho
   /pG3?QrFf3tR@-jZ/Yq.SU\Gm`)(_s\Y^Y:0E"OO[FHs0$sSWjt!`)IXLY"!0Zhs@n/$JnHj
   \*aD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[(^&gZEUeRqU4+qR\K\@=ZnTog``aQb`%4
   ,PL9?T<e`)9Y(``XMkUdN?E(<Ki@C6gYDbI-u8R-q4_GD[h"8R0*ALM"DhOc>k.XM,-/@Wkq
   ie`)gr*2hJs!/iKGL[ieqe8`%$Ic3oJ-D<J(MSA*BLi!o]`%(7!Lhbo``2i>:XaG$^=ASX383i
   mSqYD4'BU*+f!TIY[aTG<(`)?,W2ZG!_XXuj3O[i5IZ#O1k9bnr_:iQm`%eESp-c9i``^a>I2
   &qUuS4[$IT7`%`%Vd4'Lq,G30G?G=^u9Huqe5q:pBK+:VS8IL[(":b"ltP6I0-5-UZ<P-;fu
   V;1[F0]Mbe45$25DL;f<^@H+4`)RXp=(-]h^\4EB"SV\\jDE@`)J(EN``u,MK32tZ<T9b35*,
   aqq.'Is2FN.<LC>I+CPIljU<W]_85Y"&J.?L:SH8@?._BR@4ahC8_\p(8`%HL+s11KaiY2D
   '_``pnp$3(QJDZU0or/`%Z"IeAgcb&s/buJ@p:=jDQI/'*C:C/NaU#-R\ojnbeVlqa?\C'p+
   fjD1:L=N9G1/rt?OT`%gbs'3H7l\kl:\``!(fUS7'8jaJc
)

NeededBytes:=Ascii85_DecoderSize(&Logo, 0xFFFFFFFF) ; here : 0xFFFFFFFF (aka (unsigned long) -1) says to use terminating '\0' as end of input
VarSetCapacity(BinLogo, NeededBytes)
DecodedBytes:=Ascii85_Decoder(&Logo, 0xFFFFFFFF, &BinLogo)
/*
  --------- code by Sean & SKAN taken from http://www.autohotkey.com/forum/topic27410.html ------------- and adapted :-) ------------------
*/
;http://www.autohotkey.com/forum/viewtopic.php?p=148231#148231

Gui -Caption
Gui, Margin, 0, 0
Gui, Add, Text, x0 y0 w228 h133 +0xE hWndPic1 ; +0xE is SS_BITMAP

hData := DllCall("GlobalAlloc", UInt,2, UInt, DecodedBytes )
pData := DllCall("GlobalLock",  UInt,hData )
DllCall( "RtlMoveMemory", UInt,pData, UInt,&BinLogo, UInt,DecodedBytes )
DllCall( "GlobalUnlock", UInt,hData )
DllCall( "ole32\CreateStreamOnHGlobal", UInt,hData, Int,True, UIntP,pStream )

DllCall( "LoadLibrary", Str,"gdiplus" )
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall( "gdiplus\GdiplusStartup", UIntP,pToken, UInt,&si, UInt,0 )

DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
DllCall( "gdiplus\GdipCreateHBITMAPFromBitmap", UInt,pBitmap, UIntP,hBitmap, UInt,0 )

SendMessage, (STM_SETIMAGE:=0x172), (IMAGE_BITMAP:=0x0), hBitmap,, ahk_id %Pic1%
SoundPlay, *16, 1
Gui, Show,, Just for fun

DllCall( "gdiplus\GdipDisposeImage", UInt,pBitmap )
DllCall( "gdiplus\GdiplusShutdown", UInt,pToken )
DllCall( NumGet(NumGet(1*pStream)+8 ), UInt,pStream )

Return                                                    ; // End of Auto-Execute section

GuiEscape:
  ExitApp


High level decoding and use :
Code:

#include Ascii85.ahk

; This one is AHK's, snapshoted out of forum main page - Hope Chris won't fire me out of forum :-)
Logo =
(
   M,6r;`%14!\!!!!.8Ou6I!!!#[!!!"Q#Qk&,!.5rc5QCcd!`)Q?g75ct\<26sqdF_p2``ocaT
   EP0\6CMT$amtQ(n^<"B;ZFn?5k+&0<6^4[nda6/(pTqos<`%jJiMhtP@>&703N0^!-UrfX<
   XH/CRFaJJC\@-e`)hUpc@U>YVBs8Um7jT#8\zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
   zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
   zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!2h:Q#64
   ``($#iF<ErZ1J&c_n>&cpG:If'0G`)K/285u``*!m9L*0UH#GOG\`%.58P*2("6':[bGul0``ho
   /pG3?QrFf3tR@-jZ/Yq.SU\Gm`)(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Vnm!RT[e?r1TK
   ZEI$f5$oT]I@B!"ruL``d#R8dC<D.of/D'eY'dD[(^&gZEUeRqU4+qR\K\@=ZnTog``aQb`%4
   ,PL9?T<e`)9Y(``XMkUdN?E(<Ki@C6gYDbI-u8R-q4_GD[h"8R0*ALM"DhOc>k.XM,-/@Wkq
   ie`)gr*2hJs!/iKGL[ieqe8`%$Ic3oJ-D<J(MSA*BLi!o]`%(7!Lhbo``2i>:XaG$^=ASX383i
   mSqYD4'BU*+f!TIY[aTG<(`)?,W2ZG!_XXuj3O[i5IZ#O1k9bnr_:iQm`%eESp-c9i``^a>I2
   &qUuS4[$IT7`%`%Vd4'Lq,G30G?G=^u9Huqe5q:pBK+:VS8IL[(":b"ltP6I0-5-UZ<P-;fu
   V;1[F0]Mbe45$25DL;f<^@H+4`)RXp=(-]h^\4EB"SV\\jDE@`)J(EN``u,MK32tZ<T9b35*,
   aqq.'Is2FN.<LC>I+CPIljU<W]_85Y"&J.?L:SH8@?._BR@4ahC8_\p(8`%HL+s11KaiY2D
   '_``pnp$3(QJDZU0or/`%Z"IeAgcb&s/buJ@p:=jDQI/'*C:C/NaU#-R\ojnbeVlqa?\C'p+
   fjD1:L=N9G1/rt?OT`%gbs'3H7l\kl:\``!(fUS7'8jaJc
)

DecodedBytes:=Ascii85_AhkDecoder(Logo, BinLogo)
/*
  --------- code by Sean & SKAN taken from http://www.autohotkey.com/forum/topic27410.html ------------- and adapted :-) ------------------
*/

Gui -Caption
Gui, Margin, 0, 0
Gui, Add, Text, x0 y0 w228 h133 +0xE hWndPic1 ; +0xE is SS_BITMAP

hData := DllCall("GlobalAlloc", UInt,2, UInt, DecodedBytes )
pData := DllCall("GlobalLock",  UInt,hData )
DllCall( "RtlMoveMemory", UInt,pData, UInt,&BinLogo, UInt,DecodedBytes )
DllCall( "GlobalUnlock", UInt,hData )
DllCall( "ole32\CreateStreamOnHGlobal", UInt,hData, Int,True, UIntP,pStream )

DllCall( "LoadLibrary", Str,"gdiplus" )
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall( "gdiplus\GdiplusStartup", UIntP,pToken, UInt,&si, UInt,0 )

DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
DllCall( "gdiplus\GdipCreateHBITMAPFromBitmap", UInt,pBitmap, UIntP,hBitmap, UInt,0 )

SendMessage, (STM_SETIMAGE:=0x172), (IMAGE_BITMAP:=0x0), hBitmap,, ahk_id %Pic1%
SoundPlay, *16, 1
Gui, Show,, Just for fun

DllCall( "gdiplus\GdipDisposeImage", UInt,pBitmap )
DllCall( "gdiplus\GdiplusShutdown", UInt,pToken )
DllCall( NumGet(NumGet(1*pStream)+8 ), UInt,pStream )

Return                                                    ; // End of Auto-Execute section

GuiEscape:
  ExitApp


Thanks go to Lazslo for idea and Sean/Skan for the code I borrowed in the samples. I hope I forgot no one in credits.

Comments are welcome. Please, be constructive while criticizing Wink .

Edit : corrected URL to ASCII85 specs, which was missing.


Last edited by Azerty on Tue Mar 18, 2008 1:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Mon Mar 17, 2008 2:02 pm    Post subject: Reply with quote

Thx.
_________________
Back to top
View user's profile Send private message MSN Messenger
SKAN



Joined: 26 Dec 2005
Posts: 5887

PostPosted: Tue Mar 18, 2008 1:00 pm    Post subject: Reply with quote

Dear Azerty, Smile

First of all: Many thanks for developing this solution. I have been waiting for this.

I need one clarification.
After calling the encoder function, the ASCII 85 byte stream ( DestinationMemory ) seems to contain linefeeds and carriage returns. Is this alright ?

Please confirm.

Smile
Back to top
View user's profile Send private message
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Tue Mar 18, 2008 1:20 pm    Post subject: Reply with quote

Hi.

1st, you're both welcome Smile

Wow... 130 reads, 2 replies...

SKAN wrote:
After calling the encoder function, the ASCII 85 byte stream ( DestinationMemory ) seems to have linefeeds and carriage returns. Is this alright ?


Yes : in either high level or low level function, you can pass the NbBytesPerLine parameter with either ((unsigned) -1) meaning you want no CR/LF, or another value specifying the expected ascii bytes per line (defaults to 70 in high level function, no default in low level). This has been made to facilitate embeding in AHK source without having to manually split lines.

Please note that if you want to be "adobe compatible" (i.e. with <~ and ~> delimiters) in high level function, these are not counted, so first and last line might be, by design, slightly longer. I judged it was not worth the computing cost to readjust line lengths in this case.

You may also notice that using low level function to encode may lead to ascii code that's not directly embedable into AHK source code because of AHK syntax parser (that's taken into account in the high level interface only, since I wanted low level ASM code function to be usable outside of AHK or with "neutral" external ASCII85 files in AHK that would be compatible with some unknown other app, just in case...).
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Tue Mar 18, 2008 3:55 pm    Post subject: Reply with quote

interesting stuff..

in case helpful to anyone, offer this. (code adopted, ie. not my work). may even be reasons why the simplification is bad. anyhow
Code:


MCode(ByRef bin, hex = "") { ;  MCode(Function)
   Static fun
     if hex =
      hex := bin
   If (fun = "") {
      h:="568b74240c8a164684d2743b578b7c240c538ac2c0e806b109f6e98ac802cac0e104880f8"
       . "a164684d2741a8ac2c0e806b309f6eb80e20f02c20ac188078a16474684d275cd5b5f5ec3"
      VarSetCapacity(fun,StrLen(h)//2)
      Loop % StrLen(h)//2
         NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char")
   }
   VarSetCapacity(bin,StrLen(hex)//2)
   dllcall(&fun, "uint",&bin, "Str",hex, "cdecl")
}


; result := Ascii85_Encode( Bin_Var_to_Encode)

Ascii85_Encode( SourceText, NbBytesPerLine = "", SourceSize = "" ) { ; returns binary encoded as ascii85,  include size if not same as setcapacity of source text...
    Static lMcode
    if (!lMcode) {
        lMcode := "60e81a0000000100000055000000391c0000ed5e0900b1841c030203041810085b89e583c51c83ec048b45148945e0fc8b75088b7d108b4d0c09c9745d83f904"
   . "7231ad0fc809c0750cb07ae86a000000e9190000005131c9b10583c31483eb0431d2f733e84f00000089d0e2f05983e904ebc651c1e008ace2fa59518a4c0b16"
   . "d3e0598a4c0b1383c31483eb0431d2f733e82200000089d0e2f08b451483f8ff740b3b45e0740666b80d0a66ab2b7d10897d0083c40461c30421aa8b45e083e8"
      . "01750966b80d0a66ab8b45148945e0c3"
      
        MCode(lMcode)
    }
   
    if !SourceSize
   SourceSize := varsetcapacity( SourceText )
    varsetcapacity(DestinationMemory, SourceSize *2,0)
   
 DllCall(&lMcode, "UInt", &SourceText, "UInt", SourceSize, "STR", DestinationMemory, "UInt", NbBytesPerLine, "cdecl UInt")

   
 
   
    return DestinationMemory
}

; size_of_return := Ascii85_Decode( The_stuff )
; The_Stuff is converted from ascii 85 to bin

Ascii85_Decode(byref SourceText) {  ; Converts ascii85 string to it's binary & returns binary length
    Static lMcode
    if (!lMcode) {
        lMcode := "608b6c240c83ed0431d231c9fc8b75088b7d108b5d0c31c0e84f00000074453c7a750531c0abebeeb1042c2189c231c0e83700000074132c215031c0b055f7e25a01d0e2"
        . "e70fc8abebcc5131c0b055f7e283c05489c2e2f359f7d983c104c1c008aae2fa2b7d10897d0061c309db7416ac4b08c074103c2074f23c0974ee3c0d74ea3c0a74e6c3"
        MCode(lMcode)
    }
   
    SourceTemp := SourceText
    return DllCall(&lMcode, "STR", SourceTemp, "UInt", strlen(SourceTemp) , "UInt", &SourceText, "cdecl UInt")
   
   
}

_________________
Joyce Jamce
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Tue Mar 18, 2008 5:02 pm    Post subject: Reply with quote

I also support your ideas to merge this and MCode, and eventualy other similar functions you may make in the meantime. Some formal method of documentation would be more appropriate.
_________________
Back to top
View user's profile Send private message MSN Messenger
SKAN



Joined: 26 Dec 2005
Posts: 5887

PostPosted: Tue Mar 18, 2008 9:50 pm    Post subject: Reply with quote

Azerty wrote:
using low level function to encode may lead to ascii code that's not directly embedable into AHK source code because of AHK syntax parser


True.. Sad
I have been trying to write an error-free auto-ascii85-script-generator for past 20 hours .. in vain.
With continuation sections, my script is not even able to handle 5mb of binary data... Executables are the worst to handle ...

I wish we had a simple facility like:

Code:
var=
( TEXT JOIN
sadsadsadsdlaskdllkiweooeiqwoeoqwoeiowqe
qweowqeiowiqe
qwekfjdf8ud83erpojtiuhidsfkosdf
sdifgu8urtewooksofusdlfkdlskf
op9wr998efkoldkf
dfoisdofofsdi90989erioweri9w0ei9rwie9ri
ENDTEXT )


Anyways! I will be posting my script shortly since it works fine with image files .. Many thanks for the clarifications, Azerty!

Smile

Edit: Done!

Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Tue Mar 18, 2008 11:18 pm    Post subject: Reply with quote

SKAN wrote:

I wish we had a simple facility like:

Code:
var=
( TEXT JOIN
sadsadsadsdlaskdllkiweooeiqwoeoqwoeiowqe
qweowqeiowiqe
qwekfjdf8ud83erpojtiuhidsfkosdf
sdifgu8urtewooksofusdlfkdlskf
op9wr998efkoldkf
dfoisdofofsdi90989erioweri9w0ei9rwie9ri
ENDTEXT )



here...

Code:

AutoUnJoiner:

   controlgettext,SText, Scintilla1,ahk_class SciTEWindow
;_autoJoined = %_autoJoined%`n
;( %`
   SText :=regexreplace(SText,"s)\Q" .  "_autoJoined =  " . "\E" 
                  . "|\Q" . "`n_autoJoined = %_autoJoined%``n`n( %```n" . "\E"
                  . "|\Q`n)`n\E","")
   
   controlsettext, Scintilla1, %SText%,ahk_class SciTEWindow

return
AutoJoiner:
   controlgettext,SText, Scintilla1,ahk_class SciTEWindow

   SText := "_autoJoined =  "    regexreplace(SText,"s)(.{1,16000}(\n|$))","`n_autoJoined = %_autoJoined%``n`n( %```n$1`n)`n")
   controlsettext, Scintilla1, %SText%,ahk_class SciTEWindow

return

_________________
Joyce Jamce
Back to top
View user's profile Send private message
Sarah



Joined: 12 Jul 2007
Posts: 90
Location: Hawaii, USA

PostPosted: Thu Mar 20, 2008 1:05 pm    Post subject: Reply with quote

Quote:

... or any other resource you might imagine. Explanation of ASCII85 code is there.



Azerty, those demos are very neat!

.....but how about making ASCII85 work on this slice?

see: http://www.filecrunch.com/file/~5yunad

It is actually the binary version of this code,

Code:

Msgbox, Hello



.... or maybe you can get something on your end to work like this Smile

Code:

FileRead, BinData, RUNTHISDATA.BIN

; .. then integrated run under ASCII85? :)

Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Thu Mar 20, 2008 6:59 pm    Post subject: Reply with quote

I suggest creting utility that will let you add files (and maybe entire folder structure) to be encoded into single Resource.ahk file together with functions needed to use files in the resource or unpack them to HD.

Then everybody would be able just to include Resource.ahk or even create set of different resources (kind of themes) and use it in uniformed manner.

After this work, creating such utility isn't difficult and will make entire operation standardized and more useful to everybody.
_________________
Back to top
View user's profile Send private message MSN Messenger
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Thu Mar 20, 2008 10:59 pm    Post subject: Reply with quote

majkinetor : looks like it's exactly the purpose of skan's AxC : Pack and Unpack Binary files which offers the following functionnality :
Quote:
AxC_UnPackToMem( packfile, filename, byref bin )
loads a single file available in an AxC file into AutoHotkey memory.
Back to top
View user's profile Send private message
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Thu Mar 20, 2008 11:14 pm    Post subject: Reply with quote

sarah : see above : you may use skan's lib with
Quote:
AxC_UnPack( packfile, destination )
Unpacks a single file available in an AxC file.


In fact, ASCII85's purpose is not to embed multiple files/binary resources into a separate "cabinet" file (zip libs would be better for it, they compress instead of expanding size, and are natively supported by OS) but to embed the resources into an AHK source file, then to use them directly from memory.

If you want to regenerate the exe when it's extracted from AHK, you may use ASCII85 in conjunction with PhilLo's BinReadWrite.ahk functions.

As for the resource you give a link to, it seems to be a standalone .EXE/.DLL (which I've not binary reencoded) by the MZ signature in the first two bytes. Exe/Dll cannot be used from memory because of the way relocation is done (I explained a little bit this matter here. Relocation is done through tables which are stored into a specific par of exe/dll but never fully loaded into memory. To learn more about it, google "PE relocation table" where PE stands for "Portable Executable".
Back to top
View user's profile Send private message
Sarah



Joined: 12 Jul 2007
Posts: 90
Location: Hawaii, USA

PostPosted: Fri Mar 21, 2008 2:41 am    Post subject: Reply with quote

Azerty wrote:
majkinetor : looks like it's exactly the purpose of skan's AxC : Pack and Unpack Binary files which offers the following functionnality :
Quote:
AxC_UnPackToMem( packfile, filename, byref bin )
loads a single file available in an AxC file into AutoHotkey memory.


I'm loving it! Smile Can this be used this way? >> I see how to regenerate, but can I pack a file and use it this way::

Code:


AXC_UnPackToMem("hello.axc","hello.exe", byref bin)



Not sure how to interpret that last part... suggestions? Very Happy
Back to top
View user's profile Send private message
Azerty



Joined: 19 Dec 2006
Posts: 72
Location: France

PostPosted: Fri Mar 21, 2008 9:09 am    Post subject: Reply with quote

Idea Sarah : I suggest you move your questions about AXC lib to Skan's Topic, not to confuse this one. Thanx.

I can't respond to you directly since I've not had time to dig into Skan's lib. Sorry Sad
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Fri Mar 21, 2008 9:54 am    Post subject: Reply with quote

Quote:
majkinetor : looks like it's exactly the purpose of skan's AxC : Pack and Unpack Binary files which offers the following functionnality :

Not in the manner I proposed. Its completely different project, looking similar at first glance
_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group