private byte readImageDescriptor(InputStream is) throws Exception { int nindex = 0; byte ides[] = new byte[9]; IOUtils.readFully(is, ides, 0, 9); image_x = (ides[nindex++] & 0xff) | ((ides[nindex++] & 0xff) << 8); image_y = (ides[nindex++] & 0xff) | ((ides[nindex++] & 0xff) << 8); width = (ides[nindex++] & 0xff) | ((ides[nindex++] & 0xff) << 8); height = (ides[nindex++] & 0xff) | ((ides[nindex++] & 0xff) << 8); return ides[nindex++]; }
private void readLocalPalette(InputStream is, int num_of_color) throws Exception { int index1 = 0; int bytes2read = num_of_color * 3; byte brgb[] = new byte[bytes2read]; IOUtils.readFully(is, brgb, 0, bytes2read); rgbColorPalette = new int[num_of_color]; for (int i = 0; i < num_of_color; i++) rgbColorPalette[i] = ((255 << 24) | ((brgb[index1++] & 0xff) << 16) | ((brgb[index1++] & 0xff) << 8) | (brgb[index1++] & 0xff)); }
void readHeader(InputStream is) throws Exception { int nindex = 0; byte bhdr[] = new byte[13]; IOUtils.readFully(is, bhdr, 0, 13); for (int i = 0; i < 3; i++) signature[i] = bhdr[nindex++]; for (int i = 0; i < 3; i++) version[i] = bhdr[nindex++]; screen_width = ((bhdr[nindex++] & 0xff) | ((bhdr[nindex++] & 0xff) << 8)); screen_height = ((bhdr[nindex++] & 0xff) | ((bhdr[nindex++] & 0xff) << 8)); flags = bhdr[nindex++]; bgcolor = bhdr[nindex++]; aspectRatio = bhdr[nindex++]; // The end }