Ejemplo n.º 1
0
        private void InitializeBitmapSector()
        {
            TheStore.TheFile.Position = BitmapToPos(Ix);

            StreamUtils.WriteUInt8(TheStore.TheFile, (byte)Store.SectorTypes.Bitmap);
            StreamUtils.WriteInt32(TheStore.TheFile, Store.LAST_SECTOR_IN_CHAIN);
            NextBitmap = null;

            SectorData = new byte[(int)TheStore.SectorDataSize];
            StreamUtils.Write(TheStore.TheFile, SectorData);
        }
Ejemplo n.º 2
0
        public static byte[] BCGZipCompress(byte[] buf)
        {
            using (var ms = new MemoryStream())
            {
                ms.WriteByte(0x1f);
                ms.WriteByte(0x8b);
                ms.WriteByte(0x08);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x02);
                ms.WriteByte(0xFF);

                using (var gzs = new ZOutputStream(ms, 6, true))
                {
                    gzs.Write(buf, 0, buf.Length);
                    gzs.Flush();
                }

                var crc = LZUtils.CRC32(buf);

                // ZOutputStream closes the outer stream...
                using (var ms2 = new MemoryStream())
                {
                    StreamUtils.Write(ms2, ms.ToArray());
                    StreamUtils.WriteUInt32(ms2, crc);
                    StreamUtils.WriteInt32(ms2, buf.Length);

                    var msb = ms2.ToArray();

                    /*
                     * using ( var foos = new FileStream( "test.gz", FileMode.Create, FileAccess.Write ) )
                     * {
                     * foos.Write( msb );
                     * }
                     */

                    return(msb);
                }
            }
        }