//x,y,width,height,需要绘制的坐标,宽高
//color,添上去的颜色
//transparence,半透明的程度 [0,16]
private void alpha_fade(int x, int y, int width, int height, int color,
int transparence) {
int i;
//把RGB颜色,转换成4444格式的颜色
int r = (color & 0xff0000) >> 20; //得到添加颜色的高位R
int g = (color & 0x00ff00) >> 12; //得到添加颜色的高位G
int b = (color & 0x0000ff) >> 4; //得到添加颜色的高位B
short m_color = (short) ((r << 8) | (g << 4) | b);
short pixels[] = new short[width];
for (i = 0; i < width; i++) {
pixels[i] = (short) ((transparence << 12) + m_color);
}
//再绘制到屏幕上
for (i = 0; i < height; i++) {
dg.drawPixels(pixels, true, 0, width, x, i + y, width, 1, 0, 4444);
}
pixels = null;
}
看到过这么个源代码。
不过要用Nokia的dg
private void alpha_fade(int x, int y, int width, int height, int color,
int transparence) {
int i;
int r = (color & 0xff0000) >> 20;
int g = (color & 0x00ff00) >> 12;
int b = (color & 0x0000ff) >> 4;
short m_color = (short) ((r << 8) | (g << 4) | b);
short pixels[] = new short[width];
for (i = 0; i < width; i++) {
pixels[i] = (short) ((transparence << 12) + m_color);
}
for (i = 0; i < height; i++) {
dg.drawPixels(pixels, true, 0, width, x, i + y, width, 1, 0, 4444);
}
pixels = null;
}