for(int iter = 0 ; iter < rgb.length ; iter++) {
if(rgb[iter] == transColor) {
imageRGB[iter] = 0;
}
}
g.drawImage(new RGBImage(imageRGB, width, height), x, y);
} else {
int foreground = g.getColor();
if(c.hasFocus()) {
g.setColor(s.getBgSelectionColor());
} else {
g.setColor(s.getBgColor());
}
// Its opaque much easier job!
if(s.getBgTransparency() == ((byte)0xff)) {
g.fillRoundRect(x, y , width, height, arcWidth, arcHeight);
} else {
// if its transparent we don't need to do anything, if its
// translucent... well....
if(s.getBgTransparency() != 0) {
Image i = Image.createImage(width, height);
int[] imageRgb;
if(g.getColor() != 0xffffff) {
Graphics imageG = i.getGraphics();
imageG.setColor(g.getColor());
imageG.fillRoundRect(0, 0 , width, height, arcWidth, arcHeight);
imageRgb = i.getRGB();
} else {
// background color is white we need to remove a different color
// black is the only other "reliable" color on the device
Graphics imageG = i.getGraphics();
imageG.setColor(0);
imageG.fillRect(0, 0, width, height);
imageG.setColor(g.getColor());
imageG.fillRoundRect(0, 0 , width, height, arcWidth, arcHeight);
imageRgb = i.getRGB();
}
int removeColor = imageRgb[0];
int size = width * height;
int alphaInt = ((s.getBgTransparency() & 0xff) << 24) & 0xff000000;
for(int iter = 0 ; iter < size ; iter++) {
if(removeColor == imageRgb[iter]) {
imageRgb[iter] = 0;
continue;
}
if((imageRgb[iter] & 0xff000000) != 0) {
imageRgb[iter] = (imageRgb[iter] & 0xffffff) | alphaInt;
}
}
g.drawImage(new RGBImage(imageRgb, width, height), x, y);
}
}
g.setColor(foreground);
}