I was just wondering if you've already done a QB version. If you have, I'll be interested to learn something from the algorithms used. Anything similar to PNGCRUSH will be good.
Thanks in Advance.
P.S--
A complete page with all of your QB code will look really good. Your code can sometimes help educationally. :)
Awesoken at
Sorry, I am not ready to release the algorithms to PNGOUT for any language. Also, my algorithms require way too much CPU power and memory for QB to handle. If you want to learn how the compression algorithm in PNG works, I suggest you study this document: http://www.faqs.org/rfcs/rfc1951.html That's how I learned it.
I still plan to make a QB games page sometime. It just takes time to document things so they're usable by people other than myself. : )
counting_pine at
Ken, I'm not sure I understand your general philosophy about releasing source code. It puzzles me why you release the source code to some of your projects, but not others.
(Don't get me wrong, though, It doesn't bother me that some of your projects are closed source; my C literacy is probably far too low to make sense of it)
...But I digress.
I've made a program in QBASIC which converts 24-bit BMPs to PNG format. Ken is right about QBASIC's limitations. My program has no filter types, and uses RLE-style Fixed-Huffman compression (which is nowhere near as good as other programs). It does produce valid PNG files though, if that's what you want.
It's undocumented, but I think most of it should be simple enough to follow, and I can answer any questions you have about it. You can probably get a lot more out of it if you know the PNG/Deflate Specs first.
If anyone's interested, I'll post it up here. It's about 13KB, but I can gzip it down to about 3KB, and post it in Hex.
fruitbag at
Please do. I'll be interested to take a look...
counting_pine at
Here it is. You'll need to make a gzip file out of it. Let me know if you have any problems, or find any bugs in the code.
1F8B0808B854974200004249504F2E42415300BD5A6D6FDACA12FE5EA9FF612EA727B51392621B12424B255E4C820E0104446DA5AB2BD1E2346E8841E0B4C9FD
F577C6FB6AD67649D55B3E24F6CC33B333B3B36FB37EDDEE8F4727EDD6148EA1D4BE1A433F82F1F002460F71E9E58BD72D586F565F37F37B8857F065157D0F36
31B8D5E3CF610C88DE1299E037ABCDFD3C46015473358FE3DBE007F482F9265A064F65702B95DACB17C89DDDCEA3BB44E89F208269B8FC1EA05C04D66D1CAF1B
6FDECC17DFB74FDB932888DFDC05918D12A8186E83E53A8CBEC27D005F8318B6F17C13070B5238FB34F6A11DC6D3788380972F00805EB780FE0C46C30B461904
D1D7F89668FDE1CCBFF0272F5FF8C32E90B05432B96873F1E54340D0E96CD247C70EC161F48B4D1044598C49B04893B3B5B77E9F7A22B796EBDB7951BB5DBF33
684D7CE85D0F3BB3FE6808EDA73898FE98AF0FC0EA7E586D162246B689C546B163B6018512E1C387FBCFC146E0CB663C3515D3EB36B4168BCEEA7EBD09B6DB60
81E2C10F6ABB103FC07CB2F04F312888BAE116818601654046B1B03F6A83B543EE4C3AE307D4877F0A2D24204B3101676F2AFE3BF824C084D5436DA0AEE67701
0D1E2B833E9B7F5E065B8345963EDCDC041BB4379BDDEFB6666E359383E99149BFEC4EB2E883F9566BCC405CAF17F338C0C8782E589DDBF9261D3E04F7AF607A
89F02E8C573F828D6B55603602CFB5453C5218D4844E338C5BAB658330453AAB459042A909200D0DA204EA3168BD004AC993601DC2560B9089BB9996B5164B47
0E117ACB84A15A1ED3FC36AE1980F9E8D46C2DAE69DC78B5952DA214BEEA4382E6E12FB718853CF9C9C027C7F3D81FC285D27E19845F6F63F5DE5EAF536D89F1
1EAE2205A2E9637473B30DE2EC505C8D7BE1529B0DCBB494E8242E40C8CB60BE08363A83B2B10737D1F476E218731A34250593FEE0F2AC97FC7C1BFE0D2E8C26
48AA56D82F4130EC3BA8685AEB7B6AAD5412ADB553A6B75EA0B5DD0D6F6EFE062B8C6227153F24B81A015BE2A0E38465F3067B3DF2BB339826FF5A8381365710
69D01FFAA8637C3D83523F5A3F248B3450481B502AD30B7BEEF760D0694DFD57D600A379F5CA9AB07F1C60DB644029881625985DFA43C09983D48FC6F8CC31D0
436FDBFD616BF2095A9D8E3F9DC2C46F75C989BF1C020380EA385207506AC0853F437E199CB2622658B249C1DFBDA7DD086F7D8C1D8E0E0D5731CCE1FB7C8989
89FB8FFBF9FA5FA8B033184D7D6830130140B5E0E819B8C33B2F537EA789AE27F27C877E9EE47B9AE839A9A447878513346EDE35A182D9C0D5B157DD957EC4DC
5884F74144F25BC315A68D1AA660B8D52C79F20F16C11AD742EBCB3C8255B47C82EDC37ABD4A766914253B47B16E7C4AF575C415040BF8A261E2A77560E84AB4
3149ED51A4C85BEC709460349E68387A5F591822DB46EE63E96D8ACEC265DB5932188844869CDAC21A73641D3E06CB52CA082825A9B90DFF1B3448F7A8673924
F49956CB92061452720C8DD99442DEE1F669FA693AF3AF88B0DF7E46A8A3C9AAF3B0494FBA65486F6C3858CEF36C1E1F7693B9BE095CBDCA283951BF0736AD24
02C78ADC64F41C85926CA5E56C09A1EEE7CDD14F2D1C4DF578048E8290559285EDD3F26A6891E1553B374BC894A5111C6FB65CD17451B2619382E20FA6BE6EC0
3BF08CD67176123DA1BCA005B502D8B5633876726D0D636B27645C938C98ADCB0EFD8F330EC8096245375C62F60D8F699EC8403BBF35336889274DF64F752602
44C2B17E3C3522490DF39DB245DB1AB6D6D9F9008A12426AF910E7673A1CA543CF82092E59229D2543F95669B05D5051C84939F259234720220957A32E9CD66A
AED32088CB212E4208A9F1CDE8D2134E13F4A8CE1A1CA6F67B27FCD0D234494770A6CF47E6DEDB68E5D9C721D31C7CC240ED124613B16FE65A6D463F145B7885
E7FC67B8B9AB9A3374DF770E38FB9BADF6F0F4F03BAD4E6BDECF68BDB78A4EB86A1012277FFCC9A432937ACFF050D32CF6E1CFA3C3C3B37F8874E59C6A8C933D
C3B54FBD422DB66D42CC82FBB5E06A21D577EAF50AFB25D1D5A49A09EF2047E6C084ABE7D144D3CB9BCD85EE9E1B48263937E09BC35E9EA3A0D7D3C49F2F7A60
C3A1262942FD33A3A514FD44B789FEA2F7E29A4AAAE344C14095AF1A8CD684CEE5E49510B7F5C4D14B0E12C0D874E2F9CB2D433951628CC0FD2A38CA3A64A64F
D3C4E4DB0AC16C42522D18F843A58E5B9369706BDAB1AEFADD570A5DE6AACAE0D834E6C46E8293459BCA37296938985F7232B430A4A9416D83551CF0551EBC55
57D53944B265AFE18038B7E1084AC829C19120766DF5DCD29E9D96CE90A6EAA758AC43D33116F5C9632CBD141F631150748CA53692A32CC725BD3ABA9E518374
7C75F929879E2430E7CCFB61D29FF94C4AA8D6A3ED945590D2B9212A6F069557F032E89AF9DA8907BAAB884E66B92720579D80B8B874CFC802BDF8A8274298DA
5D7C4BBDDDA98ACF523CEAE3258426B0CA5F451A2F969E907AC885FF40A8D29F9E3588E710464DB50DC9708951319AE2A5C1061AD614BA04E09B18B67545E753
FF1DDBDD279942A2A2B464DDD9F03199ECFD6EBB5EF7DC4AB2FEEE4076CE03DFE43BAF6B324FEF742FF30C57A2537FE0776640294E70DD60A23109A7EA7196FA
C90539B4F996402FE95B218EBA6ABD0C75BB4852ADF875B36D6CB6CAED7D7EEBC7B4D129C3F99ECD9FA70E823C2A4591F4926CABD5F78E2493702AA63DD4CB89
C51E4D558E09402B0B7CBD2BC3995D20A4BC64670033CC4E62593DDF328424F5C703B4EFDC842D0926702CC50FEC5F728376044B5AA9DDFA7E1ED5B33D3A4F7A
A75AE4D1397954258F1C2FD32585238FBC833FE3D079A6435E8D1C3A3D2D4A9E1A39544F1C3A2B708870E4D0D91F72C8A9647A747A96249D53D0478821979C53
F2C975727D22A0A89BFC29A79C9C91544BBCF20A463981945BCEB9FB7FF3AB2EFCA2A9704FBFDC6CBF3C874DC467457E79C924E1B9CCAF824145503EAA9C3FE5
9897E518CA67CF7A68FFD92F19B6F7ACF5DCF5865D1B4A295631285E009D32D4ECB48461494D6FD3DCAAE5D44A3E5CF607BE79487F0FF5BCAA5EBA5A204B6F7B
D7175835EF7935836365CE0774CBF44EED84F57DE8A3DA6B3E8947C9A5CF2CC67429801C7A560CDA13E389CA94B89A3F7E34A97DBCA050548DAEDFCC9EE917B3
0A4336673645DB77C9507AC9021A7AD8248D992A550393C582B1C91462130C599EBC0964BF0E57230AC6081583495AD2C40CF6FFB15C5B30E8954E2702817A59
90557D549541D96CC92FBE9BAA6E9E3E5197485549632191F6EC00AFB17250DF213B5D223BB9D53DEF20B73EE7E55E3A953AECF324B4887F9574727252D287EA
1334F98D1C0DC0D4654003FBA4D39AF9D0994EF0F8590627EB0E4A0A3F2557516F72AEAFDEEE5E443C8ADDFD5943E6D0A34DC4061BDD8F0A9FBE6CAAE4AAA284
20379807C60C2A32BEA9DFC21F61080E9394C2C7C7DD3B1DED7A538897E5905230D348AA6C08DCC92458D87B8393AF9EF687D3C753E6DDCB2351E4DB935E314A
2BB3709612E2B25E228B5FD6703463692E3062C8AA11943D7EF2140AF16301A4FECA18861C973D0712D3B0D91894594392244BFB396B364BA58954BD6EB55C6D
664F6BBDA097DCAF77E9FAD9AC94E9272E797BAED6F6FE14DE19E74AD5068D739DA51A6A6628734EF3F5B8B97AEA3B5ADCEAEFD0E2B9F95A4E8BB5E8BB8DFC2C
753C3ABEED37295327EE4ECA38F88DAAB3E059568AABD61A3B0F960F4288E4A44DE07370811512601A5280CCC731548E39B21F74A2EAB71D70A5F8ED57869B79
DFB7C78D58BF97B5C563F71B7BEEF30E93C29B558763C8BA012ADCCF550A368795C22BD25FFEC6549F8D50285D9F57AC49DBB80E624B271712EBA7DC87EA6BA0
90A69AE4A178415169DE507ECBC8B4D9B4554B5352AB11A37192EE3234B9FAEC7B94E2CF2B8D0980D7182DF64ED54A92B0E5569E48E2A3362B330FFF07067AF0
80082E0000
[EDIT: Why complicate things? [url=http://fileanchor.com/2312-r]Here's a FileAnchor link - much simpler to use, should've done that in the first place.]
It shouldn't be too difficult to add support for other BMP bit depths or a dX filter type, but I left them out to make the code simpler and shorter.
Couple of notes:
Filenames need to be in DOS 8.3 format, e.g. C:\SCREEN~1.BMP
RLEDist is the distance that the compressor checks for matches. It can be set between 1 and 4. For RGB (unfiltered) data it's probably best to set it to 3.
Edited at
Frobozz at
Awesoken said
Sorry, I am not ready to release the algorithms to PNGOUT for any language. Also, my algorithms require way too much CPU power and memory for QB to handle. If you want to learn how the compression algorithm in PNG works, I suggest you study this document: http://www.faqs.org/rfcs/rfc1951.html That's how I learned it.
I still plan to make a QB games page sometime. It just takes time to document things so they're usable by people other than myself. : )
Too much CPU and memory for even FreeBASIC? :D
FreeDOSfan at
PNGOUT
Awesoken wrote:
Sorry, I am not ready to release the algorithms to PNGOUT for any language
Would be nice if you did, anyway one has to accept if you don't.
But could you release a DOS executable ? Just compile to DOS (DOS/4GW for ex.) ...
No need to UPX - I know how to to this myself.
Thanks for KZIP again. :)
Awesoken at
To Ken: A QBasic version of PNGCRUSH...?
I'm going to regret this:
http://advsys.net/ken/util/pngout_dos.exe Don't expect any kind of support or future releases. : P
FreeDOSfan at
Thanks
Nothing to regret - thanks. :) :)
Tested some files:
- one PNG could be recompressed by factor almost 1.5 !!!
- some others too
- some GIFs converted and smaller
- 1 PNG failed (in Winedowns too)
- 1 GIF crashed (in Winedowns too)
I would call this prog instead of PNG OUT
rather PNG OPT or PNG IN - efficient compression is
always " IN" , in DOS even more ! :)
FreeDOSfan at
Great progs / Basic
To Ken:
I also downloaded your MP3 - player supporting ANY
soundcard, including none - no need to create a DOS version - it
already works ! :)
To BASIC-freaks:
QBASIC is really incredibly slow. A 32KB buffer, as standard Deflate uses, would fit
into memory, but the compression would progress very slowly. More advanced
compression would be difficult: little buffer space, need for TMP files, ... ->
nonrecomended.
FreeBASIC should be OK - almost as fast a "C" and almost (in DOS) all memory. :idea:
I'll try it soon.
counting_pine at
To Ken: A QBasic version of PNGCRUSH...?
- 1 PNG failed (in Winedowns too)
- 1 GIF crashed (in Winedowns too)
It's quite rare for PNGOut to have problems with images. Are you sure they're valid images?
QBASIC is really incredibly slow. A 32KB buffer, as standard Deflate uses, would fit
into memory, but the compression would progress very slowly. More advanced
compression would be difficult: little buffer space, need for TMP files, ... ->
nonrecomended.
Actually, at least in my quick experiment, QBASIC can't even hold a 32KB buffer. I can get to about 30 thousand bytes before it runs out of memory. This limits its effectiveness as even a decompressor for deflated files.
I've been looking a bit at FreeBASIC, attracted by its better speed and memory capacity. I might start using it a lot more, although I'm still a bit wary. I'd say it's about 95% compatible with QBASIC, so some QB programs will need some adjustment to get them working. Also, at this stage there's no debugger, and I think the project has yet to reach a stable plateau, so there are still bugs to worry about, along with the possibility that changes in the compiler might break older FreeBASIC programs.
OK, you're right, it can.
The method I was trying ("dim a as string*32767") wouldn't work for me for some reason, which led me to assume that QBASIC had a 32KB upper limit, but the help file says it can manage 65535 bytes.
I've just tried another method ("dim a(0 to 1) as string*16384") which did work.
But I couldn't find a way of getting it to hold a 32768 byte buffer in a convenient form - neither "dim a as string*32768" or "dim a(0 to 32767) as string*1" seem to work.
So anyway, I've decided I don't trust QBASIC to cope with that much memory.
Frobozz at
Are you guys using it in dynamic or static memory? Because I think you can hit more with dynamic turned on. Also there are several EMS libraries available for QB that you could use. :wink: