| 類別 | 套件 | 核心價值 |
|---|---|---|
FullCanvas | com.nokia.mid.ui | 全螢幕繪圖,Series 60 可用 176x208 完整解析度,隱藏標題列/軟鍵列 |
DirectGraphics | com.nokia.mid.ui | 增強繪圖:多邊形、翻轉、旋轉、Alpha 混合、像素級操作 |
DirectUtils | com.nokia.mid.ui | 可變動圖片建立、圖片像素存取、圖塊切割、反色效果 |
DirectGraphics dg = DirectUtils.getDirectGraphics(g); // g 為標準 Graphics
int[] polygonX = { 30, 50, 30, 10 };
int[] polygonY = { 10, 30, 50, 30 };
dg.drawPolygon(polygonX, 0, polygonY, 0, polygonX.length, 0);
dg.drawImage(img, x, y, anchor, DirectGraphics.FLIP_HORIZONTAL);
dg.drawImage(img, x, y, anchor, DirectGraphics.ROTATE_90);
支援 ROTATE_180、ROTATE_270、FLIP_VERTICAL、FLIP_HORIZONTAL 組合。
Image mutableImg = DirectUtils.createImage(width, height, 0x00000000); // 最後參數 ARGB,0x00=全透明
Graphics g = mutableImg.getGraphics();
// 繪製內容...
// fivemen.png: 60x12,包含 5 個 12x12 角色
Image fivemen = Image.createImage("/fivemen.png");
Image[] man = new Image[5];
for (int i = 0; i < 5; i++) {
man[i] = DirectUtils.createImage(12, 12, 0x00000000);
Graphics g = man[i].getGraphics();
// 負座標偏移實現「視窗裁切」
g.drawImage(fivemen, -12 * i, 0, Graphics.TOP | Graphics.LEFT);
}
Image createInvertedImage(Image src) {
int w = src.getWidth(), h = src.getHeight();
Image dst = DirectUtils.createImage(w, h, 0x00000000);
int numBytes = (w * h + 7) / 8; // 1 bit per pixel
byte[] pixels = new byte[numBytes];
byte[] mask = new byte[numBytes];
DirectGraphics dg = DirectUtils.getDirectGraphics(src.getGraphics());
dg.getPixels(pixels, mask, 0, w, 0, 0, w, h, DirectGraphics.TYPE_BYTE_1_GRAY_VERTICAL);
// 像素反轉邏輯(此處略)...
// 將 pixels 寫回 dst...
return dst;
}
Canvas.drawBitmap() + Matrix / Shader;DirectUtils 圖塊切割對應 Bitmap.createBitmap() 圖集切圖Nokia UI API 隨 S40/S60 版本演進,部分方法在早期固件缺失。發布前必須在目標機型矩陣上實機測試,並準備標準 LCDUI 降級渲染路徑。