public static ICC_Profile GetInstance(Stream file)
{
byte[] head = new byte[128];
int remain = head.Length;
int ptr = 0;
while (remain > 0) {
int n = file.Read(head, ptr, remain);
if (n <= 0)
throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
remain -= n;
ptr += n;
}
if (head[36] != 0x61 || head[37] != 0x63
|| head[38] != 0x73 || head[39] != 0x70)
throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
remain = ((head[0] & 0xff) << 24) | ((head[1] & 0xff) << 16)
| ((head[2] & 0xff) << 8) | (head[3] & 0xff);
byte[] icc = new byte[remain];
System.Array.Copy(head, 0, icc, 0, head.Length);
remain -= head.Length;
ptr = head.Length;
while (remain > 0) {
int n = file.Read(icc, ptr, remain);
if (n <= 0)
throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
remain -= n;
ptr += n;
}
return GetInstance(icc);
}