private void ProcessParameters()
{
type = JPEG2000;
originalType = ORIGINAL_JPEG2000;
inp = null;
try {
if (rawData == null){
WebRequest w = WebRequest.Create(url);
w.Credentials = CredentialCache.DefaultCredentials;
inp = w.GetResponse().GetResponseStream();
}
else{
inp = new MemoryStream(rawData);
}
boxLength = Cio_read(4);
if (boxLength == 0x0000000c) {
boxType = Cio_read(4);
if (JP2_JP != boxType) {
throw new IOException(MessageLocalization.GetComposedMessage("expected.jp.marker"));
}
if (0x0d0a870a != Cio_read(4)) {
throw new IOException(MessageLocalization.GetComposedMessage("error.with.jp.marker"));
}
Jp2_read_boxhdr();
if (JP2_FTYP != boxType) {
throw new IOException(MessageLocalization.GetComposedMessage("expected.ftyp.marker"));
}
Utilities.Skip(inp, boxLength - 8);
Jp2_read_boxhdr();
do {
if (JP2_JP2H != boxType) {
if (boxType == JP2_JP2C) {
throw new IOException(MessageLocalization.GetComposedMessage("expected.jp2h.marker"));
}
Utilities.Skip(inp, boxLength - 8);
Jp2_read_boxhdr();
}
} while (JP2_JP2H != boxType);
Jp2_read_boxhdr();
if (JP2_IHDR != boxType) {
throw new IOException(MessageLocalization.GetComposedMessage("expected.ihdr.marker"));
}
scaledHeight = Cio_read(4);
Top = scaledHeight;
scaledWidth = Cio_read(4);
Right = scaledWidth;
bpc = -1;
}
else if ((uint)boxLength == 0xff4fff51) {
Utilities.Skip(inp, 4);
int x1 = Cio_read(4);
int y1 = Cio_read(4);
int x0 = Cio_read(4);
int y0 = Cio_read(4);
Utilities.Skip(inp, 16);
colorspace = Cio_read(2);
bpc = 8;
scaledHeight = y1 - y0;
Top = scaledHeight;
scaledWidth = x1 - x0;
Right = scaledWidth;
}
else {
throw new IOException(MessageLocalization.GetComposedMessage("not.a.valid.jpeg2000.file"));
}
}
finally {
if (inp != null) {
try{inp.Close();}catch{}
inp = null;
}
}
plainWidth = this.Width;
plainHeight = this.Height;
}