Ow .. that's stupid, the example was wrong .. I understand the error checking now. It seems my experiment returned a ZIPAPI_BUF_ERROR.
However, I don't understand why. When I poke random data in a bank, size 5000, the compressed version of the bank can be uncompressed. However, when I leave the original bank empty, or fill it with predicable numbers, it can't. Is that right ?
I think the structure you chose is a good solution. I don't think is it necessary to be able to compress banks with a length of zero. If any error occurs, it might be better to abort, it will make debugging much easier I think.
However, I don't understand why. When I poke random data in a bank, size 5000, the compressed version of the bank can be uncompressed. However, when I leave the original bank empty, or fill it with predicable numbers, it can't. Is that right ?
; Include required libraries Include "../Blitz_Basic_Bank.bb" Include "../Blitz_File_FileName.bb" Include "../Blitz_File_ZipApi.bb" ;create bank bank = CreateBank(5000) ; ;without these lines, it returns a data error ; ;but with them, the bank can be extracted ; ; For i = 0 To BankSize(bank) / 2 ; PokeByte bank, i, Rand(255) ; Next ;compress bank1 = ZipApi_Compress(bank) bank2 = ZipApi_UnCompress(bank1) Print "org:" + BankSize(bank) Print "cmp:" + BankSize(bank1) ;cmp. ratio Print "scale = " + BankSize(bank) / Float(BankSize(bank1)) Print "error? " + bank2 If bank2 > 0 Then ;test uncompressed bank Print "unc:" + BankSize(bank2) End If FreeBank bank FreeBank bank1 FreeBank bank2 WaitKey() End
I think the structure you chose is a good solution. I don't think is it necessary to be able to compress banks with a length of zero. If any error occurs, it might be better to abort, it will make debugging much easier I think.