2011-12-29 97 views

回答

1

首先創建這樣

EncodedImage ei = EncodedImage.getEncodedImageResource("res/helpscreen.png"); 

一個編碼圖片,然後通過這個編碼圖像傳遞給下面的功能

EncodedImage ei1= scaleImage(ei,reqWidth,requiredHeight); 


public EncodedImage scaleImage(EncodedImage source, int requiredWidth, int requiredHeight) 
    { 
     int currentWidthFixed32 = Fixed32.toFP(source.getWidth()); 
     int requiredWidthFixed32 = Fixed32.toFP(requiredWidth); 
     int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32); 
     int currentHeightFixed32 = Fixed32.toFP(source.getHeight()); 
     int requiredHeightFixed32 = Fixed32.toFP(requiredHeight); 
     int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32); 
     return source.scaleImage32(scaleXFixed32, scaleYFixed32); 
    } 

這會給你一個編碼圖像。然後將其轉換使用

 BitmapField logoBitmap = new BitmapField(ei1.getBitmap()); 
0

要縮放Bitmap圖像嘗試Bitmap.scaleInto(...)爲位圖。 API Link.

Bitmap targetBm = new Bitmap(Display.getWidth(), Display.getHeight()); 
srcBitmap.scaleInto(targetBm, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_STRETCH); 
相關問題