private boolean checkPng() throws IOException { final byte[] PNG_MAGIC = { 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a }; byte[] a = new byte[27]; if (read(a) != 27) { return false; } if (!equals(a, 0, PNG_MAGIC, 0, 6)) { return false; } format = FORMAT_PNG; width = getIntBigEndian(a, 14); height = getIntBigEndian(a, 18); bitsPerPixel = a[22] & 0xff; int colorType = a[23] & 0xff; if (colorType == 2 || colorType == 6) { bitsPerPixel *= 3; } progressive = (a[26] & 0xff) != 0; return true; }
private boolean checkRas() throws IOException { byte[] a = new byte[14]; if (read(a) != a.length) { return false; } final byte[] RAS_MAGIC = {0x6a, (byte) 0x95}; if (!equals(a, 0, RAS_MAGIC, 0, 2)) { return false; } format = FORMAT_RAS; width = getIntBigEndian(a, 2); height = getIntBigEndian(a, 6); bitsPerPixel = getIntBigEndian(a, 10); return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 24); }
private boolean checkRas() throws IOException { byte[] a = new byte[14]; if (read(a) != a.length) { return false; } final byte[] RAS_MAGIC = { 0x6a, (byte) 0x95 }; if (!equals(a, 0, RAS_MAGIC, 0, 2)) { return false; } format = FORMAT_RAS; width = getIntBigEndian(a, 2); height = getIntBigEndian(a, 6); bitsPerPixel = getIntBigEndian(a, 10); return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 24); }
private boolean checkPng() throws IOException { final byte[] PNG_MAGIC = {0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}; byte[] a = new byte[31]; if (read(a) != 31) { return false; } if (!equals(a, 0, PNG_MAGIC, 0, 6)) { return false; } format = FORMAT_PNG; width = getIntBigEndian(a, 14); height = getIntBigEndian(a, 18); bitsPerPixel = a[22] & 0xff; int colorType = a[23] & 0xff; if (colorType == 2 || colorType == 6) { bitsPerPixel *= 3; } progressive = (a[26] & 0xff) != 0; // we are past IHDR chunk, validate the others until you find unknown chunk if (pngValidateMetadata) { return validatePngMetaData(); } else { return true; } }
private boolean checkPsd() throws IOException { byte[] a = new byte[24]; if (read(a) != a.length) { return false; } final byte[] PSD_MAGIC = {0x50, 0x53}; if (!equals(a, 0, PSD_MAGIC, 0, 2)) { return false; } format = FORMAT_PSD; width = getIntBigEndian(a, 16); height = getIntBigEndian(a, 12); int channels = getShortBigEndian(a, 10); int depth = getShortBigEndian(a, 20); bitsPerPixel = channels * depth; return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 64); }
private boolean checkPsd() throws IOException { byte[] a = new byte[24]; if (read(a) != a.length) { return false; } final byte[] PSD_MAGIC = { 0x50, 0x53 }; if (!equals(a, 0, PSD_MAGIC, 0, 2)) { return false; } format = FORMAT_PSD; width = getIntBigEndian(a, 16); height = getIntBigEndian(a, 12); int channels = getShortBigEndian(a, 10); int depth = getShortBigEndian(a, 20); bitsPerPixel = channels * depth; return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 64); }
if (!equals(a, 0, IFF_RM, 0, 2)) { return false;
if (!equals(a, 0, IFF_RM, 0, 2))
if (equals(APP0_ID, 0, data, 0, 5)) { if (data[7] == 1) { setPhysicalWidthDpi(getShortBigEndian(data, 8));
if (equals(APP0_ID, 0, data, 0, 5))