/// <summary> /// Duplicate InterWaveMap /// </summary> /// <returns></returns> public InterWaveMap Duplicate() { InterWaveMap retval = null; try { retval = new InterWaveMap { BlockHeight = BlockHeight, Blocks = (InterWaveBlock[])Blocks.Clone(), BlockWidth = BlockWidth, Height = Height, Width = Width, BlockNumber = BlockNumber, Top = Top }; //IWBlock[] blocks = (IWBlock[])this.Blocks.Clone(); //((IWMap)retval).Blocks = blocks; for (int i = 0; i < BlockNumber; i++) { retval.Blocks[i] = Blocks[i].Duplicate(); } } catch { } return(retval); }
public InterWaveEncoder(InterWaveMap map) : base(map) { _EMap = new InterWaveMap(map.Height, map.Width); }
public InterWaveDecoder(InterWaveMap map) : base(map) { Init(map); }
public void Decode(IBinaryReader reader) { if (_YDecoder == null) { _CSlices = _CSerial = 0; _YMap = null; } byte serial = reader.ReadByte(); byte slices = reader.ReadByte(); if (serial != _CSerial) { throw new DjvuFormatException( $"{nameof(IInterWavePixelMap)} received out of order data. Expected serial number {_CSerial}, actual {serial}"); } int nslices = _CSlices + slices; if (_CSerial == 0) { int major = reader.ReadByte(); int minor = reader.ReadByte(); if ((major & 0x7f) != InterWaveCodec.MajorVersion) { throw new DjvuFormatException("File has been compressed with an incompatible codec"); } if (minor > InterWaveCodec.MinorVersion) { throw new DjvuFormatException("File has been compressed with a more recent codec"); } int w = (reader.ReadByte() << 8); w |= reader.ReadByte(); int h = (reader.ReadByte() << 8); h |= reader.ReadByte(); int crcbDelay = 0; if ((major & 0x7f) == 1 && minor >= 2) { crcbDelay = reader.ReadByte(); if (minor >= 2) { _CrCbDelay = (crcbDelay & 0x7f); } } if (minor >= 2) { _CrCbHalf = ((crcbDelay & 0x80) != 0 ? false : true); } if ((major & 0x80) != 0) { _CrCbDelay = -1; } _YMap = new InterWaveMap(w, h); _YDecoder = new InterWaveDecoder(_YMap); if (_CrCbDelay >= 0) { _CbMap = new InterWaveMap(w, h); _CrMap = new InterWaveMap(w, h); _CbDecoder = new InterWaveDecoder(_CbMap); _CrDecoder = new InterWaveDecoder(_CrMap); } } IDataCoder coder = DjvuSettings.Current.CoderFactory.CreateCoder(reader.BaseStream, false); for (int flag = 1; flag != 0 && _CSlices < nslices; _CSlices++) { flag = _YDecoder.CodeSlice(coder); if (_CrDecoder != null && _CbDecoder != null && _CrCbDelay <= _CSlices) { flag |= _CbDecoder.CodeSlice(coder); flag |= _CrDecoder.CodeSlice(coder); } } _CSerial++; }