ZLib bekomm ich nicht auf die Reihe
Übersicht

![]() |
BtbNBetreff: ZLib bekomm ich nicht auf die Reihe |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich habe jetzt ca. 2h rumgebastelt und nix laufendes hinbekommen.
Ich möchte ne Bank mit der ZLib komprimieren. Ich weiß, das ich Byte-Arrays benutzen muss, ich weiß auch, das der dest-buffer 100,1%+12 groß sein muss. Aber wie geht das richtig, hilfe bitte. |
||
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Method Zip(rate:Int=5)
Local stdsz:Long = BankSize(self.bank) Local outsz:Long = Ceil(stdsz*1.001)+12 Local fromarr:Byte[] = BankArray(self.bank) Local toarr:Byte[outsz] Local szbank:Int = CreateBank(8) PokeLong(szbank,0,outsz) Local cprret:Int = compress2(Varptr(toarr),szbank,Varptr(fromarr),stdsz,rate) 'If cprret <> 0 Then Return cprret outsz = PeekLong(szbank,0) Print "ALT" Print stdsz Print "NEU" Print outsz 'Local tobank:TBank = ArrayBank(toarr) Return cprret End Method So, hab ma etwas gebastelt, gibbt aber immer -5(Z_BUF_ERROR) zurück. Wieso? Und wie gehts richtig? |
||
![]() |
TheShadowModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
hust warum 100.1% ??? | ||
AMD64 3500+ | GeForce6600GT 128MB | 1GB DDR | WinXPsp2 |
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
ZLib Help hat Folgendes geschrieben: Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes.
Und um 0,1% erhöhhen is das selbe wie auf 100,1% erhöhen. Deshalb. |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Dann solltest du es vielleicht richtig umsetzen, was du liest, meinste net? ![]() 100,1% von SrcLen + 12 nicht (100,1 von Src) + 12 wie du es gemacht hast ![]() |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wenn das das Problem is renn ich gegen ne Wand!
Edit: Code: [AUSKLAPPEN] Method Zip(rate:Int=5)
Local stdsz:Long = BankSize(self.bank) Local outsz:Long = Ceil((stdsz+12)*1.001) Local fromarr:Byte[] = BankArray(self.bank) Local toarr:Byte[outsz] Local szbank:Int = CreateBank(8) PokeLong(szbank,0,outsz) Local cprret:Int = compress2(Varptr(toarr),szbank,Varptr(fromarr),stdsz,rate) 'If cprret <> 0 Then Return cprret outsz = PeekLong(szbank,0) Print "ALT" Print stdsz Print "NEU" Print outsz 'Local tobank:TBank = ArrayBank(toarr) Return cprret End Method Macht keinen Unterscheid, kommt der selbe Error! |
||
![]() |
soli |
![]() Antworten mit Zitat ![]() |
---|---|---|
Vielleicht hilft dir das:
Zitat: ; "savetozip.bb" include file ; by snarkbait ; snarkbait66 @ gmail.com ; needs the correct version of zlib.dll in the current folder ; actually uses a modified build of zlib.dll found here: ; www.winimage.com/zLibDll/zlib123dll.zip ; often named 'zlibwapi.dll' but I change the name to ; zlib.dll (for no good reason other than the previous ; authors of blitz zlib wrappers did so) ; needs the following .decls file ; ; zlib.decls ; .lib "zlib.dll" ; or use "zlibwapi.dll" if you don't change the name ; ; Zlib_zipOpen%( filename$, append ):"zipOpen" ; Zlib_zipOpenNewFileInZip%( fh, filename$, fileinfo*, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment$, method, level ):"zipOpenNewFileInZip" ; Zlib_zipWriteInFileInZip%( fh, buf*, buflen):"zipWriteInFileInZip" ; Zlib_zipCloseFileInZip%( fh ):"zipCloseFileInZip" ; Zlib_zipClose%( fh ):"zipClose" ; ; usage: ; success = LoadFolderToZip("subfoldername","destfilename.zip") ; ; folder zipped must be a subfolder of the current running directory ; do not use full path name or trailing backslash ; i.e. LoadFolderToZip("Test","test.zip") ; will load all the files in the subfolder 'Test' to a file called test.zip ; ignores further subfolders, could easily be modified to include them also Const Z_DEFLATED = 8 Const Z_DEFAULT_COMPRESSION = -1 Const APPEND_STATUS_CREATE = 0 Const APPEND_STATUS_CREATEAFTER = 1 Const APPEND_STATUS_ADDINZIP= 2 Function SaveToZip(filename$, filetozip$, append = APPEND_STATUS_CREATE) file = Zlib_zipOpen (filename$,append) If Not file Return False zipfile = OpenFile(filetozip$) If Not zipfile Return False zipsize = FileSize(filetozip$) fbank = CreateBank(zipsize) ibank = CreateBank(100) ReadBytes fbank,zipfile,0,zipsize Zlib_zipOpenNewFileInZip( file, filetozip$,ibank,0,0,0,0,"",Z_DEFLATED,Z_DEFAULT_COMPRESSION) Zlib_zipWriteInFileInZip( file , fbank, BankSize(fbank)) Zlib_zipCloseFileInZip( file) Zlib_zipClose(file) FreeBank fbank FreeBank ibank Return True End Function Function LoadFolderToZip(folder$,destfile$) If FileType(folder$) = 2 a = 0 zipdir = ReadDir(folder$) Repeat thisfile$ = NextFile$(zipdir) If thisfile$ = "" Exit If FileType(folder$ + "\" + thisfile$) = 1 If a = 0 success = savetozip(destfile$,folder$ + "\" + thisfile$) If Not success Return False Else success = savetozip(destfile$,folder$ + "\" + thisfile$,APPEND_STATUS_ADDINZIP) If Not success Return False EndIf a = a + 1 EndIf Forever Return True Else Return False EndIf End Function |
||
solitaire |
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hilf mir nicht weiter, erstens isses kein BMax und ich hab nur 3 Funktionen:
compress() compress2() uncompress() |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Such mal im englischen Modulforum nach der ZipEngine oder wie das Modul heisst, dass die komplette ZLib einbindet. Mit der standard implementation kannst du nix anfangen!
ABER: Wenn du sie nutzt, pack die mitgebrachte ZLIb an einen anderen Ort und pass es entsprechend an! BM wirds sonst bei jedem Syncmod wieder kaputt machen. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
soli |
![]() Antworten mit Zitat ![]() |
---|---|---|
BORNtobeNAMELESS hat Folgendes geschrieben: Hilf mir nicht weiter, erstens isses kein BMax und ich hab nur 3 Funktionen:
compress() compress2() uncompress() Ich weiss das es kein BMax ist, aber wieso kannst du das nicht anpassen? Im englischen Forum gibt es noch mehr Beispiele, allerdings ist die Suchfunktion dort sehr gewöhnungsbedürftig. |
||
solitaire |
![]() |
Henry |
![]() Antworten mit Zitat ![]() |
---|---|---|
@Dreamora: Wieso kann man zLib in BMax vergessen?! ![]() ZLib Funktionalität für compress und uncompress ist in BMax doch enthalten, man brauch keine zLib.dll bei seinen Spielen hinzufügen oder ein 3rd Party Modul verwenden. Im Gegensatz zu BlitzBasic kann man in BMax alle Speicherbereiche nutzen, die man mit einem Pointer adressieren kann...also Arrays, Banks und MemAlloc. |
||
Aiya Eärendil Elenion Ancalima!
All you have to decide is what to do with the time that is given to you. • Robsite.de ist eine Anlaufstelle für Tutorials und Tools, die Noobs das Leben leichter machen! • Forensuche ist nicht nur als Lückenfüller in den oberen Links gedacht! |
![]() |
Henry |
![]() Antworten mit Zitat ![]() |
---|---|---|
@BORNtobeNAMELESS:
Hab' Deine PM gerade erst gelesen...hier mal mein Code zum packen und entpacken einer Datei. Code: [AUSKLAPPEN] ' Compressing a bank ' Strict Framework brl.basic Import pub.zlib Local SourceFile:TStream = OpenStream("test.bmp") Local SourceBank:TBank = TBank.Create( SourceFile.Size() ) Local SourceSize:Int = SourceBank.Size() Local SourceBankStream:TBankStream = CreateBankStream( SourceBank ) CopyStream( SourceFile, SourceBankStream ) SourceFile.Close() Local DestinationSize:Int = (SourceSize + SourceSize / 10 + 32) Local DestinationBank:TBank = TBank.Create( DestinationSize ) compress2( DestinationBank.Buf()+4, DestinationSize, SourceBank.Buf(), SourceSize, 9 ) DestinationBank.PokeByte( 0, SourceSize ) DestinationBank.PokeByte( 1, SourceSize Shr 8) DestinationBank.PokeByte( 2, SourceSize Shr 16) DestinationBank.PokeByte( 3, SourceSize Shr 24) DestinationBank.Resize( DestinationSize + 4 ) Local DestinationFile:TStream = WriteStream("packed.dat") DestinationBank.Save( DestinationFile ) DestinationFile.Close() End Code: [AUSKLAPPEN] ' Uncompressing a bank ' Strict Framework brl.basic Import pub.zlib Local SourceFile:TStream = OpenStream("packed.dat") Local SourceBank:TBank = TBank.Create( SourceFile.Size() ) Local SourceSize:Int = SourceBank.Size() Local SourceBankStream:TBankStream = CreateBankStream( SourceBank ) CopyStream( SourceFile, SourceBankStream ) SourceFile.Close() Local DestinationSize:Int DestinationSize:|SourceBank.PeekByte(0) DestinationSize:|SourceBank.PeekByte(1) Shl 8 DestinationSize:|SourceBank.PeekByte(2) Shl 16 DestinationSize:|SourceBank.PeekByte(3) Shl 24 Local DestinationBank:TBank = TBank.Create( DestinationSize ) uncompress( DestinationBank.Buf(), DestinationSize, SourceBank.Buf()+4, SourceSize-4 ) Local DestinationFile:TStream = WriteStream("test_uncomp.bmp") DestinationBank.Save( DestinationFile ) DestinationFile.Close() End Man kann sich recht einfach eigene Ressourcen Dateien oder Level Formate damit erstellen. |
||
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Dankedankendanke!
Das ist, was ich gesucht habe! |
||
![]() |
Henry |
![]() Antworten mit Zitat ![]() |
---|---|---|
Keine Ursache! ![]() |
||
Aiya Eärendil Elenion Ancalima!
All you have to decide is what to do with the time that is given to you. • Robsite.de ist eine Anlaufstelle für Tutorials und Tools, die Noobs das Leben leichter machen! • Forensuche ist nicht nur als Lückenfüller in den oberen Links gedacht! |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Weil die ZLib eigentlich noch aus einigem mehr besteht, wie du feststellen würdest, wenn du die ZipEngine mit der richtigen ZLib reinpackst.
Diese benötigt übrigens genau so wenig eine DLL wie die jetzige, da beides direkt compiliert wird von GCC. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
Henry |
![]() Antworten mit Zitat ![]() |
---|---|---|
Das ist mir schon klar. Aber für das, was BtbN umsetzen wollte (einfach einen Speicherbereich komprimieren), reicht die Standard-Implementierung aus, wie Du siehst. | ||
Aiya Eärendil Elenion Ancalima!
All you have to decide is what to do with the time that is given to you. • Robsite.de ist eine Anlaufstelle für Tutorials und Tools, die Noobs das Leben leichter machen! • Forensuche ist nicht nur als Lückenfüller in den oberen Links gedacht! |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group