提交 caf6c986 编写于 作者: B bae

8227816: More Colorful ICC profiles

Reviewed-by: andrew
上级 bb5a86c4
...@@ -43,7 +43,9 @@ import sun.java2d.cmm.ProfileDataVerifier; ...@@ -43,7 +43,9 @@ import sun.java2d.cmm.ProfileDataVerifier;
import sun.java2d.cmm.ProfileDeferralMgr; import sun.java2d.cmm.ProfileDeferralMgr;
import sun.java2d.cmm.ProfileDeferralInfo; import sun.java2d.cmm.ProfileDeferralInfo;
import sun.java2d.cmm.ProfileActivator; import sun.java2d.cmm.ProfileActivator;
import sun.misc.IOUtils;
import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -1019,42 +1021,25 @@ public class ICC_Profile implements Serializable { ...@@ -1019,42 +1021,25 @@ public class ICC_Profile implements Serializable {
static byte[] getProfileDataFromStream(InputStream s) throws IOException { static byte[] getProfileDataFromStream(InputStream s) throws IOException {
byte profileData[];
int profileSize;
byte header[] = new byte[128]; BufferedInputStream bis = new BufferedInputStream(s);
int bytestoread = 128; bis.mark(128);
int bytesread = 0;
int n;
while (bytestoread != 0) { byte[] header = IOUtils.readNBytes(bis, 128);
if ((n = s.read(header, bytesread, bytestoread)) < 0) {
return null;
}
bytesread += n;
bytestoread -= n;
}
if (header[36] != 0x61 || header[37] != 0x63 || if (header[36] != 0x61 || header[37] != 0x63 ||
header[38] != 0x73 || header[39] != 0x70) { header[38] != 0x73 || header[39] != 0x70) {
return null; /* not a valid profile */ return null; /* not a valid profile */
} }
profileSize = ((header[0] & 0xff) << 24) | int profileSize = ((header[0] & 0xff) << 24) |
((header[1] & 0xff) << 16) | ((header[1] & 0xff) << 16) |
((header[2] & 0xff) << 8) | ((header[2] & 0xff) << 8) |
(header[3] & 0xff); (header[3] & 0xff);
profileData = new byte[profileSize]; bis.reset();
System.arraycopy(header, 0, profileData, 0, 128); try {
bytestoread = profileSize - 128; return IOUtils.readNBytes(bis, profileSize);
bytesread = 128; } catch (OutOfMemoryError e) {
while (bytestoread != 0) { throw new IOException("Color profile is too big");
if ((n = s.read(profileData, bytesread, bytestoread)) < 0) {
return null;
}
bytesread += n;
bytestoread -= n;
} }
return profileData;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册