BitmapFactory.decodeFile不能在一类解决
问题描述:
我想2个图像合并,所以我搜查,看到了一个代码在这里snipplet combining two png files in androidBitmapFactory.decodeFile不能在一类解决
Bitmap bottomImage = new BitmapFactory.decodeFile("myFirstPNG.png");
Bitmap topImage = new BitmapFactor.decodeFile("myOtherPNG.png");
Canvas comboImage = new Canvas(bottomImage);
// Then draw the second on top of that
comboImage.drawBitmap(topImage, 0f, 0f, null);
// bottomImage is now a composite of the two.
// To write the file out to the SDCard:
OutputStream os = null;
try {
os = new FileOutputStream("/sdcard/DCIM/Camera/" + "myNewFileName.png");
image.compress(CompressFormat.PNG, 50, os)
} catch(IOException e) {
e.printStackTrace();
}
我试图使用它,但出于某种原因位图底图=新的BitmapFactory.decodeFile(“myFirstPNG.png”);是给错误BitmapFactory不能resovlved成类型,但我已经有两个
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
我使用PhoneGap的,我把这个在主要活动,以测试
答
decodeFile
是需要一个静态方法在类范围内被称为如下:
Bitmap bottomImage = BitmapFactory.decodeFile("myFirstPNG.png");
Bitmap topImage = BitmapFactor.decodeFile("myOtherPNG.png");
(注意到new
关键字已被删除)
删除位图中的“新”bottomImage = new BitmapFactory.decodeFile(“myFirstPNG.png”); 位图topImage = new BitmapFactor.decodeFile(“myOtherPNG.png”); – Pragnani 2013-02-22 05:50:55