if (size < 1)
throw new IllegalArgumentException("size < 1");
map_size = size;
- rgb = new int[size];
+ rgb = createColorMap(bits, size);
for (int i = 0; i < size; i++)
{
rgb[i] = (0xff000000
map_size = size;
opaque = (alphas == null);
- rgb = new int[size];
+ rgb = createColorMap(bits, size);
if (alphas == null)
{
for (int i = 0; i < size; i++)
map_size = size;
opaque = !hasAlpha;
- rgb = new int[size];
+ rgb = createColorMap(bits, size);
if (hasAlpha)
{
int alpha;
throw new IllegalArgumentException("size < 1");
map_size = size;
opaque = !hasAlpha;
- rgb = new int[size];
+ rgb = createColorMap(bits, size);
if (!hasAlpha)
for (int i = 0; i < size; i++)
rgb[i] = cmap[i + start] | 0xff000000;
this.trans = -1;
this.validBits = validBits;
- rgb = new int[size];
+ rgb = createColorMap(bits, size);
if (!hasAlpha)
for (int i = 0; i < size; i++)
rgb[i] = cmap[i + start] | 0xff000000;
}
}
}
+
+ private int[] createColorMap(int bits, int size)
+ {
+ // According to a Mauve test, the RI allocates at least 256 entries here.
+ int realSize = Math.max(256, Math.max(1 << bits, size));
+ return new int[realSize];
+ }
}