public byte[] GetBitmap24Data(Stream stream, out int width) { width = 0; if (Extension == "PCX") { byte[] array; if (newVal == null) { byte[] bts = new byte[Size]; stream.Position = Offset; stream.Read(bts, 0, Size); array = ZlibWrapper.UnZlib(bts); } else { array = newVal; } var file = new PcxFile(array); try { return(file.GetBitmap24Bytes(out width)); } catch { return(null); } } return(null); }
public void AppendToStream(byte[] bts, Stream stream) { Offset = (int)stream.Position; byte[] comp = ZlibWrapper.Zlib(bts); Size = comp.Length; RealSize = bts.Length; stream.Write(comp, 0, Size); }
public void SaveToStream(Stream input, Stream output) { if (!HasChanged || Created) { int len = Size == 0 ? RealSize : Size; byte[] bytes = new byte[len]; input.Position = Offset; input.Read(bytes, 0, len); Offset = (int)output.Position; output.Write(bytes, 0, len); } else { var temp = ZlibWrapper.Zlib(newVal); Size = temp.Length; Offset = (int)output.Position; output.Write(temp, 0, temp.Length); } }
public DefFile GetDefFile(Stream stream) { if (newVal == null) { stream.Position = Offset; if (Size != 0) { var bts = new byte[Size]; stream.Read(bts, 0, Size); newVal = ZlibWrapper.UnZlib(bts); } else { newVal = new byte[RealSize]; stream.Read(newVal, 0, RealSize); } } return(new DefFile(this, newVal)); }
public Bitmap GetBitmap(Stream stream) { if (Extension == "PCX") { byte[] array; if (newVal == null) { if (Size != 0) { byte[] bts = new byte[Size]; stream.Position = Offset; stream.Read(bts, 0, Size); array = ZlibWrapper.UnZlib(bts); } else if (RealSize != 0) { array = new byte[RealSize]; stream.Position = Offset; stream.Read(array, 0, RealSize); } else { throw new Exception("Image size unknown"); } } else { array = newVal; } var file = new PcxFile(array); try { return(file.GetBitmap()); } catch (Exception ex) { return(null); } } return(null); }
public byte[] GetRawData(Stream stream) { if (HasChanged && !Created) { return(newVal); } if (Size != 0) { byte[] bts = new byte[Size]; stream.Position = Offset; stream.Read(bts, 0, Size); return(ZlibWrapper.UnZlib(bts)); } else { byte[] bts = new byte[RealSize]; stream.Position = Offset; stream.Read(bts, 0, RealSize); return(bts); } }