我想創建一個png
圖像作爲LWUIT窗體的背景圖像。問題在於圖像被改變:將圖像設置爲窗體的背景圖像後,圖像中有污點。下面是代碼:當設置爲LWUIT窗體的背景圖像時,PNG圖像染色嚴重
public class DetailPhotoClient extends Form implements ActionListener {
private Command options, delete, back, annuler, ok;
private GaleriePhotos backForm;
private FileConnection fcFile;
private Image sourceImage, fullImage;
private InputStream is;
private PopupMenu popup;
public DetailPhotoClient(GaleriePhotos prevForm, String absolutePathphotoName)
{
super();
back = new Command("Retour");
options = new Command("Options");
this.addCommand(back);
this.addCommand(options);
this.addCommandListener(this);
delete = new Command("Supprimer");
annuler = new Command("Annuler");
ok = new Command("Ok");
backForm = prevForm;
try {
fcFile = (FileConnection) Connector.open(absolutePathphotoName, Connector.READ);
is = fcFile.openInputStream();
sourceImage = Image.createImage(is);
fullImage = createThumbnail(sourceImage);
setBgImage(fullImage);
is.close();
fcFile.close();
} catch (IOException ex) {
handleException();
} catch (OutOfMemoryError oom) {
handleOOM();
}
}
private Image createThumbnail(Image image) {
Image thumb = image.scaled(this.getPreferredW(), this.getPreferredH());
return thumb;
}
...
}
我注意到,當我手動打開照片,就是從手機存儲的照片文件夾,然後將照片不會被改變!
那麼如何在設置窗體背景圖像時不改變圖像呢?
圖像總是改變,即使我用'scaledSmallerRatio(this.getWidth(),this.getHeight());' – pheromix