MIDP 2.0 標準化提供 Image.getRGB() 可像素級操作 ARGB。
try {
image = Image.createImage("/ken.png"); // 載入原圖
} catch (IOException e) {}
int[] argb = new int[image.getWidth() * image.getHeight()];
image.getRGB(argb, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
for (int i = 0; i < argb.length; i++) {
// 保留 RGB,Alpha 設為 128 (50% 透明)
argb[i] = (argb[i] & 0x00FFFFFF) | 0x80000000;
}
Image translucent = Image.createRGBImage(argb, image.getWidth(), image.getHeight(), true);
// 繪製 translucent 即得半透明效果
getRGB 取得 ARGB 整數陣列 (高 8 位 Alpha)。& 0x00FFFFFF 清除原 Alpha,| 0x80000000 設定新 Alpha (0x80 = 128)。createRGBImage(..., true) 最後參數 true 表示資料含 Alpha。