protected override void ReadChunkData(DjvuReader reader) { Width = reader.ReadInt16MSB(); Height = reader.ReadInt16MSB(); MinorVersion = reader.ReadSByte(); MajorVersion = reader.ReadSByte(); DPI = reader.ReadInt16(); // LSB Gamma = (float)reader.ReadByte() / 10; sbyte flag = reader.ReadSByte(); // B[3..0] PageRotation = (PageRotations)(flag & 0x07); }
/// <summary> /// Reads the compressed data from the djvu file /// </summary> /// <param name="reader"></param> /// <param name="count"></param> /// <param name="compressedSectionLength"></param> private void ReadCompressedData(DjvuReader reader, int count, int compressedSectionLength) { DjvuReader decompressor = reader.GetBZZEncodedReader(compressedSectionLength); // Read the component sizes for (int x = 0; x < count; x++) { _components[x].Size = decompressor.ReadInt24MSB(); } // Read the component flag information for (int x = 0; x < count; x++) { _components[x].DecodeFlags(decompressor.ReadSByte()); } // Read the component strings for (int x = 0; x < count; x++) { _components[x].ID = decompressor.ReadNullTerminatedString(); if (_components[x].HasName == true) { _components[x].Name = decompressor.ReadNullTerminatedString(); } if (_components[x].HasTitle == true) { _components[x].Title = decompressor.ReadNullTerminatedString(); } } _isInitialized = true; }
/// <summary> /// Decodes the palette data /// </summary> /// <param name="reader"></param> private void ReadPaletteData(DjvuReader reader) { sbyte header = reader.ReadSByte(); bool isShapeTable = (header >> 7) == 1; _version = header & 127; int paletteSize = reader.ReadInt16MSB(); // Read in the palette colors List <Pixel> paletteColors = new List <Pixel>(); for (int x = 0; x < paletteSize; x++) { sbyte b = reader.ReadSByte(); sbyte g = reader.ReadSByte(); sbyte r = reader.ReadSByte(); paletteColors.Add(new Pixel(b, g, r)); } _paletteColors = paletteColors.ToArray(); if (isShapeTable == true) { int totalBlits = reader.ReadInt24MSB(); DjvuReader compressed = reader.GetBZZEncodedReader(); // Read in the blit colors List <int> blitColors = new List <int>(); for (int x = 0; x < totalBlits; x++) { int index = compressed.ReadInt16MSB(); blitColors.Add(index); } _blitColors = blitColors.ToArray(); } }
protected override void ReadChunkData(DjvuReader reader) { sbyte flagByte = reader.ReadSByte(); // B[7] IsBundled = (flagByte >> 7) == 1; // B[6..0] Version = flagByte & 127; int count = reader.ReadInt16MSB(); ReadComponentData(reader, count); }
/// <summary> /// Reads the compressed text data /// </summary> private void ReadCompressedTextData() { if (Length == 0) { return; } using (DjvuReader reader = GetTextDataReader(_dataLocation)) { _textLength = reader.ReadInt24MSB(); byte[] textBytes = reader.ReadBytes(_textLength); _text = Encoding.UTF7.GetString(textBytes); _version = reader.ReadSByte(); _zone = new TextZone(reader, null, null, this); } _isDecoded = true; }
/// <summary> /// Decodes the palette data /// </summary> /// <param name="reader"></param> private void ReadPaletteData(DjvuReader reader) { sbyte header = reader.ReadSByte(); bool isShapeTable = (header >> 7) == 1; _version = header & 127; int paletteSize = reader.ReadInt16MSB(); // Read in the palette colors List<Pixel> paletteColors = new List<Pixel>(); for (int x = 0; x < paletteSize; x++) { sbyte b = reader.ReadSByte(); sbyte g = reader.ReadSByte(); sbyte r = reader.ReadSByte(); paletteColors.Add(new Pixel(b, g, r)); } _paletteColors = paletteColors.ToArray(); if (isShapeTable == true) { int totalBlits = reader.ReadInt24MSB(); DjvuReader compressed = reader.GetBZZEncodedReader(); // Read in the blit colors List<int> blitColors = new List<int>(); for (int x = 0; x < totalBlits; x++) { int index = compressed.ReadInt16MSB(); blitColors.Add(index); } _blitColors = blitColors.ToArray(); } }