透明效果的設(shè)計,是開發(fā)游戲以及UI的常談話題,小弟整理了下關(guān)于透明效果的嗲們,有興趣的朋友可以看看
代碼
/**
*
* @author Jagie
*
*/
public class ShadowMIDlet extends MIDlet {
Canvas c = new ShadowCanvas();
public ShadowMIDlet() {
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(c);
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
}
/**
*
* @author Jagie
*
*/
class ShadowCanvas extends Canvas implements Runnable {
int w, h;
// 原始圖片
Image srcImage;
// 原始圖片的像素數(shù)組
int[] srcRgbImage;
// 漸變圖片的像素數(shù)組
int[] shadowRgbImage;
int imgWidth, imgHeight;
int count;
public ShadowCanvas() {
w = this.getWidth();
h = this.getHeight();
try {
srcImage = Image.createImage("/av.png");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgWidth = srcImage.getWidth();
imgHeight = srcImage.getHeight();
// 制造原始圖片的像素數(shù)組,用一個int來代表每一個像素,按位表示方式是:0xAARRGGBB
代碼
/**
*
* @author Jagie
*
*/
public class ShadowMIDlet extends MIDlet {
Canvas c = new ShadowCanvas();
public ShadowMIDlet() {
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(c);
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
}
/**
*
* @author Jagie
*
*/
class ShadowCanvas extends Canvas implements Runnable {
int w, h;
// 原始圖片
Image srcImage;
// 原始圖片的像素數(shù)組
int[] srcRgbImage;
// 漸變圖片的像素數(shù)組
int[] shadowRgbImage;
int imgWidth, imgHeight;
int count;
public ShadowCanvas() {
w = this.getWidth();
h = this.getHeight();
try {
srcImage = Image.createImage("/av.png");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgWidth = srcImage.getWidth();
imgHeight = srcImage.getHeight();
// 制造原始圖片的像素數(shù)組,用一個int來代表每一個像素,按位表示方式是:0xAARRGGBB