protected void ReadImage()
{
ix = ReadShort(); // (sub)image position & size
iy = ReadShort();
iw = ReadShort();
ih = ReadShort();
int packed = inp.ReadByte();
lctFlag = (packed & 0x80) != 0; // 1 - local color table flag
interlace = (packed & 0x40) != 0; // 2 - interlace flag
// 3 - sort flag
// 4-5 - reserved
lctSize = 2 << (packed & 7); // 6-8 - local color table size
m_bpc = NewBpc(m_gbpc);
if (lctFlag) {
m_curr_table = ReadColorTable((packed & 7) + 1); // read table
m_bpc = NewBpc((packed & 7) + 1);
}
else {
m_curr_table = m_global_table;
}
if (transparency && transIndex >= m_curr_table.Length / 3)
transparency = false;
if (transparency && m_bpc == 1) { // Acrobat 5.05 doesn't like this combination
byte[] tp = new byte[12];
Array.Copy(m_curr_table, 0, tp, 0, 6);
m_curr_table = tp;
m_bpc = 2;
}
bool skipZero = DecodeImageData(); // decode pixel data
if (!skipZero)
Skip();
Image img = null;
img = new ImgRaw(iw, ih, 1, m_bpc, m_out);
PdfArray colorspace = new PdfArray();
colorspace.Add(PdfName.INDEXED);
colorspace.Add(PdfName.DEVICERGB);
int len = m_curr_table.Length;
colorspace.Add(new PdfNumber(len / 3 - 1));
colorspace.Add(new PdfString(m_curr_table));
PdfDictionary ad = new PdfDictionary();
ad.Put(PdfName.COLORSPACE, colorspace);
img.Additional = ad;
if (transparency) {
img.Transparency = new int[]{transIndex, transIndex};
}
img.OriginalType = Image.ORIGINAL_GIF;
img.OriginalData = fromData;
img.Url = fromUrl;
GifFrame gf = new GifFrame();
gf.image = img;
gf.ix = ix;
gf.iy = iy;
frames.Add(gf); // add image to frame list
//ResetFrame();
}