import java.io.InputStream;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
class GifDecoder
{
private int C6;
private int C7[];
private int C8;
private int C9;
private int CA;
private int CB;
private int CC;
private boolean CD;
private int CE[];
private int CF;
private int D0;
private int D1;
private int D2;
private int D3;
private boolean D4;
private boolean D5;
private int D6[];
private int D8;
private boolean D9;
private int DA;
private long DB;
private int DC;
private static final int DD[] = {
8, 8, 4, 2
};
private static final int DE[] = {
0, 4, 2, 1
};
int DF;
int E0;
byte E1[];
boolean E2;
MatrixImage matrix;
public GifDecoder(byte abyte0[])
{
C6 = -1;
C7 = new int[280];
C8 = -1;
C9 = 0;
CA = 0;
CB = 0;
CC = 0;
CD = false;
CE = null;
CF = 0;
D0 = 0;
D1 = 0;
D2 = 0;
D3 = 0;
D4 = false;
D5 = false;
D6 = null;
D8 = 0;
DC = 0;
E2 = false;
E1 = abyte0;
DF = E1.length;
E0 = 0;
}
public GifDecoder(InputStream inputstream)
{
C6 = -1;
C7 = new int[280];
C8 = -1;
C9 = 0;
CA = 0;
CB = 0;
CC = 0;
CD = false;
CE = null;
CF = 0;
D0 = 0;
D1 = 0;
D2 = 0;
D3 = 0;
D4 = false;
D5 = false;
D6 = null;
D8 = 0;
DC = 0;
E2 = false;
byte abyte0[][] = new byte[32][1];
int i = 0;
int j = 0;
do
{
abyte0[i] = new byte[1024];
try
{
j = inputstream.read(abyte0[i]);
}
catch(Exception exception)
{
j = 0;
}
DF += j;
if(j != 1024)
break;
i++;
} while(true);
E1 = new byte[DF];
E0 = 0;
int k = 0;
boolean flag = false;
for(int i1 = 0; i1 <= i; i1++)
{
int l;
if(i1 == i)
l = j;
else
l = 1024;
System.arraycopy(abyte0[i1], 0, E1, k, l);
k += l;
}
}
public MatrixImage decodeMatrix()
{
E2 = true;
decodeImage(0);
return matrix;
}
public Image decodeImage()
{
return decodeImage(0);
}
public Image decodeImage(int i)
{
Object obj = null;
if(i <= C6)
return null;
if(C6 < 0)
{
if(!C9())
return null;
if(!CA())
return null;
}
do
{
if(!CF(1))
return null;
int j = C7[0];
if(j == 59)
return null;
if(j == 33)
{
if(!CD())
return null;
} else
if(j == 44)
{
if(!CB())
return null;
Image image = C6();
C6++;
if(C6 < i)
image = null;
else
return image;
}
} while(true);
}
public void clear()
{
E1 = null;
matrix = null;
C7 = null;
CE = null;
D6 = null;
}
private Image C6()
{
int i = D1;
int j = D2;
boolean flag = false;
int j1 = 0;
int k1 = 0;
int ai[] = new int[4096];
int ai1[] = new int[4096];
int ai2[] = new int[8192];
if(!CF(1))
return null;
int k = C7[0];
Image image = null;
Graphics g = null;
if(!E2)
{
image = Image.createImage(i, j);
g = image.getGraphics();
} else
{
matrix = new MatrixImage(i, j);
}
int ai3[] = CE;
if(D4)
ai3 = D6;
if(C8 >= 0)
ai3[C8] = 0;
int l2 = 1 << k;
int j3 = l2 + 1;
int k2 = k + 1;
int l3 = l2 + 2;
int k3 = -1;
int j4 = -1;
for(int l1 = 0; l1 < l2; l1++)
ai1[l1] = l1;
int j2 = 0;
C8();
j1 = 0;
for(int i2 = 0; i2 < j; i2++)
{
int i1 = 0;
while(i1 < i)
{
if(j2 == 0)
{
int i4 = C7(k2);
if(i4 < 0)
return image;
if(i4 > l3 || i4 == j3)
return image;
if(i4 == l2)
{
k2 = k + 1;
l3 = l2 + 2;
k3 = -1;
continue;
}
if(k3 == -1)
{
ai2[j2++] = ai1[i4];
k3 = i4;
j4 = i4;
continue;
}
int i3 = i4;
if(i4 == l3)
{
ai2[j2++] = j4;
i4 = k3;
}
for(; i4 > l2; i4 = ai[i4])
ai2[j2++] = ai1[i4];
j4 = ai1[i4];
if(l3 >= 4096)
return image;
ai2[j2++] = j4;
ai[l3] = k3;
ai1[l3] = j4;
if(++l3 >= 1 << k2 && l3 < 4096)
k2++;
k3 = i3;
}
int l = ai2[--j2];
if(l < 0)
return image;
if(!E2)
{
g.setColor(ai3[l]);
g.drawLine(i1, j1, i1, j1);
} else
if(l == C8)
matrix.setColor(i1, j1, -1);
else
matrix.setColor(i1, j1, ai3[l]);
i1++;
}
if(D5)
for(j1 += DD[k1]; j1 >= j; j1 = DE[k1])
if(++k1 > 3)
return image;
else
j1++;
}
return image;
}
private int C7(int i)
{
while(DC < i)
{
if(D9)
return -1;
if(D8 == 0)
{
D8 = CE();
DA = 0;
if(D8 <= 0)
{
D9 = true;
break;
}
}
DB += C7[DA] << DC;
DA++;
DC += 8;
D8--;
}
int j = (int)DB & (1 << i) - 1;
DB >>= i;
DC -= i;
return j;
}
private void C8()
{
DC = 0;
D8 = 0;
DB = 0L;
D9 = false;
DA = -1;
}
private boolean C9()
{
if(!CF(6))
return false;
return C7[0] == 71 && C7[1] == 73 && C7[2] == 70 && C7[3] == 56 && (C7[4] == 55 || C7[4] == 57) && C7[5] == 97;
}
private boolean CA()
{
if(!CF(7))
return false;
C9 = D0(C7[0], C7[1]);
CA = D0(C7[2], C7[3]);
int i = C7[4];
CB = C7[5];
int