/// <summary> /// Initializes a new PCXImage instance by loading a PCX image from a byte array. /// </summary> /// <param name="array">The byte array to load from.</param> /// <returns>The loaded PCX image.</returns> public static PCXImage Load(byte[] array) { var pcx = new PCXImage(); pcx.Read(array); return(pcx); }
/// <summary> /// Initializes a new PCXImage instance by loading a PCX image from a file. /// </summary> /// <param name="filePath">The path of the file to load from.</param> /// <returns>The loaded PCX image.</returns> public static PCXImage Load(string filePath) { var pcx = new PCXImage(); pcx.Read(filePath); return(pcx); }
/// <summary> /// Initializes a new PCXImage instance by loading a PCX image from a stream. /// </summary> /// <param name="stream">The stream to load from.</param> /// <returns>The loaded PCX image.</returns> public static PCXImage Load(Stream stream) { var pcx = new PCXImage(); pcx.Read(stream); return(pcx); }
private void ParseHeader(byte[] block) { if (block[0] != 0x0a) { throw new ArgumentException("file is not a valid PCX image"); } Version = block[1]; Encoding = block[2]; BitsPerPixel = block[3]; Xmin = BitConverter.ToInt16(block, 4); Ymin = BitConverter.ToInt16(block, 6); Xmax = BitConverter.ToInt16(block, 8); Ymax = BitConverter.ToInt16(block, 10); Hdpi = BitConverter.ToInt16(block, 12); Vdpi = BitConverter.ToInt16(block, 14); for (int i = 0; i < 16; ++i) { Palette[i] = PCXImage.ReadRGB(block, 16 + 3 * i); } NPlanes = block[65]; //BytesPerLine = BitConverter.ToInt16(block, 66); }