deflate

Deflate and inflate for PDF, using zlib C++

柔情痞子 提交于 2019-12-13 01:30:03
问题 I am trying to implement the "zlib.h" deflate and inflate functions to compress and decompress streams in PDF-file. Input: compressed stream from PDF-file. I implemented inflate function -- it's all right, I have uncopressed stream, after that I try to compress this stream again with deflate function, as output I have compressed stream, but it is not equal to input compressed stream and they are not equal to the length. What I'm doing wrong? This is a part of my code: size_t outsize =

LZ77 compression reserved bytes “< , >”

点点圈 提交于 2019-12-13 00:39:00
问题 I'm learning about LZ77 compression, and I saw that when I find a repeated string of bytes, I can use a pointer of the form <distance, length> , and that the "<", ",", ">" bytes are reserved. So... How do I compress a file that has these bytes, if I cannot compress these byte,s but cannot change it by a different byte (because decoders wouldn't be able to read it). Is there a way? Or decoders only decode is there is a exact <d, l> string? (if there is, so imagine if by a coencidence, we find

Does Deflater.setLevel() work?

半城伤御伤魂 提交于 2019-12-12 11:15:36
问题 Deflater.setLevel() does not work as expected for me. static void test1() throws Exception { byte[] output = new byte[20]; Deflater compresser = new Deflater(); // compresser.setLevel(Deflater.BEST_COMPRESSION); compresser.setInput("blah".getBytes("UTF-8")); compresser.finish(); int len = compresser.deflate(output); System.out.println("len="+ len+ " " +Arrays.toString(output)); } The above works ok for me (Java 7), but when I uncomment the compresser.setLevel() line, it breaks ( deflate()

DeflateStream not working with buffer processed from PHP implementation

时光怂恿深爱的人放手 提交于 2019-12-11 20:33:35
问题 I'm trying to decompress buffer compressed by php deflate implementation. Here's the code: public static void CopyTo(Stream src, Stream dest) { byte[] bytes = new byte[4096]; int cnt, i = 0; while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0 ) { dest.Write(bytes, 0, cnt); } dest.Flush(); } public static byte[] Unzip(byte[] bytes) { using (var msi = new MemoryStream(bytes)) using (var mso = new MemoryStream()) { using (var gs = new DeflateStream(msi, CompressionMode.Decompress)) { msi

Compressing js & css files where mod deflate not available

血红的双手。 提交于 2019-12-11 13:54:33
问题 I'm using a shared 1and1 package for a Magento website and it seems I can't use the standard approach of compressing css and js files via htaccess. I came across this http://mrrena.blogspot.co.uk/2009/01/how-to-compress-php-and-other-text.html which gave an interesting approach which seems to work. However, I need to put a php.ini file in every directory that has css or js files that I want compressed. For something like Magento, this is quite a pain. Is there any way I can use a hierarchical

Decoding a FlateDecoded section of text in a PDF document

此生再无相见时 提交于 2019-12-11 12:06:36
问题 Using peepdf I am analyzing two simple pdf files. Both files contain a single line of text ("ZYXWVUTSRQQRSTUVWXYZ") and were created on Mac OS X. The first file was created with TextEdit. There are only three streams, and looking at the first one (automatically decoded with peepdf) shows the text clearly. PPDF> stream 4 q Q q 72 707.272 468 12.72803 re W n /Cs1 cs 0 sc q 0.9790795 0 0 -0.9790795 72 720 cm BT 0.0001 Tc 11 0 0 -11 5 10 Tm /TT1 1 Tf (ZYXWVUTSRQQRSTUVWXYZ) Tj ET Q Q The second

Create 'HTTP Redirect Binding' SAML Request using Java

我的未来我决定 提交于 2019-12-11 10:21:49
问题 I am trying to implement the same algorithm in Java for SAML HTTP Redirect Binding which is described here: How do I correctly prepare an 'HTTP Redirect Binding' SAML Request using C# The algorithm is rather simple: Build a SAML string Compress this string Base64 encode the string UrlEncode the string. This should be the equivalent Java algorithm: public String encodeRedirectFormat( String samlXML ) throws IOException{ ByteArrayOutputStream os = new ByteArrayOutputStream();

Wrap deflated data in gzip format

核能气质少年 提交于 2019-12-11 09:19:04
问题 I think I'm missing something very simple. I have a byte array holding deflated data written into it using a Deflater: deflate(outData, 0, BLOCK_SIZE, SYNC_FLUSH) The reason I didn't just use GZIPOutputStream was because there were 4 threads (variable) that each were given a block of data and each thread compressed it's own block before storing that compressed data into a global byte array. If I used GZIPOutputStream it messes up the format because each little block has a header and trailer

Firefox 38.0.1 throws errors in console with JS and CSS htaccess compression enabled

我怕爱的太早我们不能终老 提交于 2019-12-11 07:07:41
问题 I have been working on improving performance on my Wordpress site, one of the things I have done, I switched to dynamic delivery of CSS and JS files (so they are compressed by PHP), which worked very well for performance tests, it seems as though firefox is throwing some errors but the website loads. Now, I have ALSO added this to the .htaccess in my JS and CSS folder (wp-incldues) on a wordpress site: <filesMatch "\.(js|css)$"> Header set Content-Encoding x-deflate # Header set Content

IDAT Chunk of PNG File Format

主宰稳场 提交于 2019-12-11 02:45:30
问题 I am currently developing a proprietary file format based on the png file format. I am done so far, except it doesn't work :-p The deflate decompressor I implemented works like a charm but the png decoder doesn't want to perform nicely so I took a look at the original png file. The standard says that after a IDAT header, the compressed data is following immediatly. So as the data is a deflate stream the first char after IDAT is 0x78 == 01111000 which means, a mode one block (uncompressed) and