private static Size DecodePng(BinaryReader binaryReader) { binaryReader.ReadBytes(8); int width = ByteHelper.ReadInt32BE(binaryReader); int height = ByteHelper.ReadInt32BE(binaryReader); return(new Size(width, height)); }
private static Size DecodeTiffBE(BinaryReader binaryReader) { int idfStart = ByteHelper.ReadInt32BE(binaryReader); binaryReader.BaseStream.Seek(idfStart, SeekOrigin.Begin); int numberOfIDF = ByteHelper.ReadInt16BE(binaryReader); int width = -1; int height = -1; for (int i = 0; i < numberOfIDF; i++) { short field = ByteHelper.ReadInt16BE(binaryReader); switch (field) { // https://www.awaresystems.be/imaging/tiff/tifftags/baseline.html default: binaryReader.ReadBytes(10); break; case 256: // image width binaryReader.ReadBytes(6); width = ByteHelper.ReadInt32BE(binaryReader); break; case 257: // image length binaryReader.ReadBytes(6); height = ByteHelper.ReadInt32BE(binaryReader); break; } if (width != -1 && height != -1) { return(new Size(width, height)); } } return(Size.Empty); }