Bin2Data - Crossplattform DataSection Maker, OpenSource

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by wilbert »

ts-soft wrote:Thx, but i will not add this to official, the packroutines in pb not crossplattform-compatible in result :cry:
I didn't know that :shock:
So data packed on OS X can not be unpacked on windows ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by ts-soft »

The data packed on windows x86 can't be unpack on windows x64 :?
The other ways not tested, but i think the a not compatible as the should.

x86 use jCalg and x64 use BriefLZ

we can use zlib, is crossplattform, but i will not always import this lib, is ~20x bigger as pb packer.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by wilbert »

@ts-soft,
Cross platform was the goal so zlib might be better.
Here's one with zlib support
http://www.w73.nl/pb/Bin2Data_zlib.pb

Previous example modified for zlib :

Code: Select all

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Linux
    #ZLIB_Filename = #PB_Compiler_Home + "purelibraries/linux/libraries/zlib.a"
  CompilerCase #PB_OS_MacOS
    #ZLIB_Filename = "/usr/lib/libz.dylib"
  CompilerCase #PB_OS_Windows
    #ZLIB_Filename = "zlib.lib"
CompilerEndSelect

ImportC #ZLIB_Filename
  uncompress(*dest, *destLen, *source, sourceLen)
EndImport


If OpenWindow(0, 0, 0, 600, 300, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 10, 10, 580, 280)
  
  msize = 1868 : *mem = AllocateMemory(msize); 1868 = original size
  uncompress(*mem, @msize, ?Install_txt_start, 873); 873 = compressed size
  SetGadgetText(0, PeekS(*mem, 1868, #PB_Ascii))
  FreeMemory(*mem)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

DataSection
  Install_txt_start:
    ; compressed size : 873 bytes
    ; original size : 1868 bytes
    Data.q $38DB6F4D54ADDA78,$6A0102CC57EBBD10,$E0F402DCDDB4A901,$176B170B606A2C7C,$4D088B234B416DC8
    Data.q $7DF6FE97C565240A,$1A97B02CD38E4943,$DE6F37999C8B61B6,$D119657BAFE3ECBC,$C6A2BA0A9DF3DEB7
    Data.q $B29E86F5AAAAFA79,$21B2B415595697EC,$01FF66CED454632A,$4FEC8F899E518EE3,$93D7274D7F76D5B1
    Data.q $C53863D23A29AE65,$07D8EB8C9701E996,$6AEF74F16813389C,$33AECB40EEF1A9CE,$876A36951D42D94C
    Data.q $2BD12FC4B292CEDF,$43AEEAD0A6B87FBA,$3BD0986E76C741DA,$1173D412957A49EE,$82F391D051DE06CA
    Data.q $EDF21544EEB95496,$57235538D60DC770,$E596DDD8C6DF00CB,$CA1DCA8AA948B439,$80AA7CA6D7FD7AED
    Data.q $81D29462B6D6C8B3,$9960615BE59DAEF0,$13B1C749C680F7D3,$70AB05A4787AB301,$E89F72E60448199A
    Data.q $D7C5D3ED5E0F4E53,$D13F9D1573DAD631,$40B1B2838D095090,$3307AE6103FB0A4C,$C3FBE967ABA32B1F
    Data.q $CEA9575FEA43FC39,$B7AA3778341960B5,$1737FAC62A433B55,$5274A84AE8332FF5,$1D569FC0943FA3D9
    Data.q $A36CB2839781D259,$1C99465275C2D139,$8D65C028EF044519,$417E0B140CB432F3,$80A01F5357F066B8
    Data.q $8476D0B8FFEA6E7C,$C22E2E3EBF03BAD3,$4CD092E728431DD7,$19C6CE480509804D,$8AE8439DBB6006E3
    Data.q $3E73406FF3B42A76,$372DDE3F7FEFB7D2,$7E3EBFACBE7FFBAB,$3F3013B3007651FE,$EF92BE7CBF6E5C5F
    Data.q $69D3042541B7ABDB,$72DB7BF190C6EE83,$DE6A8B2DA321BA60,$78129397E54BC2A3,$429E341686BB9894
    Data.q $F0ED79D53359076F,$6E6BF0A3C8845151,$422D245065226F54,$30CF2FCC8B537AEB,$646E2F7E9F2EB4D8
    Data.q $F56379B11DCED467,$3E689FBA63814E5D,$F33967140D90542A,$DCD09F9FC11C0580,$D261BAD9ECAC5A70
    Data.q $E809822743935CAE,$BF5D549CAA4E279D,$38F831795BCAF34D,$B2B038599DB15315,$E17E71B1AAD8B281
    Data.q $B98F6A0034828FAA,$07DA612EFD2E7B6B,$554926BC0C1932D0,$4D8F3BE23CC253D9,$901CFF3835BE2437
    Data.q $BA4DCD1A73164BCF,$1FD024C15938FAED,$A69463F0F3732165,$F08FF1FBD1A97605,$DD53056CFFD88728
    Data.q $574CD9FB29689DF4,$D1486C6E569FCA4D,$9454148EC2A587AE,$3486AE38DA278992,$2C958C622E213B3B
    Data.q $0FEE94353666B926,$C94A86AE2D9338A1,$B05A787BDA261543,$7950E6B9A271ACE2,$8378BE77BD88093D
    Data.q $196D1907C3098C0C,$B30D3A68C39EFDFA,$92173AF0CB33FEC1,$D3CD40340A9AA4A4,$914E94E7BF316ED6
    Data.q $813CF3369B7E9171,$41D29FB84FE86D69,$6D610507135C6D33,$48F0905FEC8A1D59
    Data.b $12
  Install_txt_end:
EndDataSection
Last edited by wilbert on Wed May 31, 2017 3:12 pm, edited 1 time in total.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by ts-soft »

thx, i have changed to your version in first post :D
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by SFSxOI »

Does this work? Got the code, tried it, doesn't work. Starts up and displays the window but ya can't drop anything on it, no menu's or anything. Whats the trick?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by ts-soft »

You can only drop files!
Here a small example with the PB.ico:

Code: Select all

EnableExplicit

DataSection
  PB_ico_start:
    ; size : 1150 bytes
    Data.q $1010000100010000,$0468002000010000,$0028000000160000,$0020000000100000,$0000002000010000
    Data.q $0000000000000000,$0000000000000000,$0000000000000000,$0000000000000000,$0000000000000000
    Data.q $0000000000000000,$0000010000000000,$0000230000000B00,$0000000000000800,$0000000000000000
    Data.q $0000000000000000,$0000000000000000,$0000000000000000,$0000050000000000,$2320691506042300
    Data.q $0101E46E211CBD64,$00000E0000008404,$0000000000000000,$0000000000000000,$0000000000000000
    Data.q $0201160000000200,$3A34A54D19155007,$5A5CFEDB5451E6A1,$2F29FFD7595CFFDB,$000093090302F694
    Data.q $0000000000001300,$0000000000000000,$100D230000000000,$4E42D68C30278B35,$5B54FFE6594FFBD9
    Data.q $6061FFE05C5AFFE3,$6060FFDE686DFFDE,$0302F6AB372CFFD4,$000001000000540A,$0000000000000000
    Data.q $5847899230260000,$5B4CFFED5847FFF3,$5E56FFE95E53FFEA,$5148FFD85750FFE1,$231BB799362BF4D1
    Data.q $000025300F0C6E6F,$0000000000000300,$0000000000000000,$4A3C0B34100C0000,$493DFFED5A49D4D0
    Data.q $2C24EFB0453AFFC6,$02024C461914987C,$0000020000001207,$0000000000000000,$0000000000000000
    Data.q $0000000000000000,$1F18000000000000,$4B40F3E456462A5F,$0000E6521914FFD1,$0D0B7F1D07057100
    Data.q $000055000000AC2F,$0000000000000300,$0000000000000000,$0000000000000000,$0000000000000000
    Data.q $6250AA62211B1300,$5047FFDE5549FFEE,$4E4BFFDE5C56FCCD,$0000E2561B16FFCC,$0000010000004A00
    Data.q $0000000000000000,$0000000000000000,$251D000000000000,$624EFEEC5B464F6E,$695EFFEF6958FFED
    Data.q $6666FFDD5F5AFFEC,$1613FFC9504EFFDE,$00002F000000D444,$0000000000000000,$0000000000000000
    Data.q $0101000000000000,$5F4BB3B845370104,$6A5CFFEC6856FFE9,$423BFFCA514BFFEC,$2720C5973B34FBA9
    Data.q $0000170200008578,$0000000000000000,$0000000000000000,$0000000000000000,$4435184B1C170000
    Data.q $473B8585372D9EA3,$2D27FFC24038F0C9,$00009F0D0504FA8E,$0000010000001C00,$0000000000000000
    Data.q $0000000000000000,$0000000000000000,$0000000000000000,$1310460000001A00,$3932FFB831289E3D
    Data.q $1210F99A2F29FFB8,$000038000000CC39,$0000000000000000,$0000000000000000,$0000000000000000
    Data.q $211B000000000000,$362BF8A72E25906D,$362CFFBC362DFEBE,$3932FFB73830FFB8,$0000C52E0F0DFEB2
    Data.q $0000000000002300,$0000000000000000,$0000000000000000,$1E19000000000000,$382EF5C03A2F2451
    Data.q $372EFFBC382EFFC0,$3730FFB5362DFFB9,$0806FDAA352EFFB2,$000014000000AB17,$0000000000000000
    Data.q $0000000000000000,$0000000000000000,$3A2F71842F270000,$3F35FFBD392FFFC1,$423DFFBA413BFFBD
    Data.q $362DFFB74742FFB8,$00005E070202F7A4,$0000000000000100,$0000000000000000,$0000000000000000
    Data.q $4136031209070000,$352A82913D337E96,$32265F7F31267188,$211B3C672D234E76,$00000C1207052B50
    Data.q $1FFE000000000000,$07C041AC0FF841AC,$078041AC038041AC,$1FC041AC3F8041AC,$0FC041AC0FC041AC
    Data.q $0FE041AC0FC041AC,$07F041AC0FF041AC,$01F841AC03F041AC
    Data.b $AC,$41,$F8,$03,$AC,$41
  PB_ico_end:
EndDataSection

Define ico = CatchImage(#PB_Any, ?PB_ico_start)

OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "")
SendMessage_(WindowID(0), #WM_SETICON, 0, ImageID(ico))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
idle
Always Here
Always Here
Posts: 5089
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by idle »

Thanks very useful
Windows 11, Manjaro, Raspberry Pi OS
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by SFSxOI »

ts-soft wrote:You can only drop files!
that's what i'm saying, that it doesn't do anything at all here, not even drop
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by ts-soft »

Works fine here on winxp sp3, win7 ultimate sp1 (x64) and some Linux-Distribution.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
codeprof
User
User
Posts: 65
Joined: Sun Sep 16, 2012 12:13 pm

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by codeprof »

hi ts-soft

really cool tool! However there is one feature I miss :P
It would be cool if your tool has an option to make the shortest possible datasection.

Here a few tips what I mean:
e.g. sometimes a constant is the shortet
like #Blue instead of $FF0000
or 1<<31 instead of $80000000
or 'Z2de57' instead of $5A3264653537
or 0 instead of $0
or -1 instead of $FFFFFFFFFFFFFFFF
and leading zeros should be removed
...
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by Josh »

codeprof wrote:really cool tool! However there is one feature I miss :P
It would be cool if your tool has an option to make the shortest possible datasection.
Hähhh? The only difference would be to have a horrible looking code
sorry for my bad english
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by ts-soft »

Josh wrote:Hähhh? The only difference would be to have a horrible looking code
And a horrible slowdown in code-generation :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
codeprof
User
User
Posts: 65
Joined: Sun Sep 16, 2012 12:13 pm

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by codeprof »

the code would be smaller then :wink:
hm then I have to program it myself...

A few other ways to make files smaller (at least images):
http://www.kraken.io/ (Optimizes PNG,JPG files online)
http://pnggauntlet.com/ (Optimizes PNG-Files)
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by Josh »

codeprof wrote:the code would be smaller then :wink:
hm then I have to program it myself...
Maybe you can place the texts from your examples in a way, that we can see a naked women. In this case your work would make sense because you will not get a shortener datasection :mrgreen:
sorry for my bad english
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Bin2Data - Crossplattform DataSection Maker, OpenSource

Post by J. Baker »

removed post
Last edited by J. Baker on Sun May 11, 2014 12:09 am, edited 1 time in total.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Post Reply