android-image-filter
android-image-filter copied to clipboard
Getting java.lang.OutOfMemoryError
Hi there,
Two things I would like to understand -
- After following the instructions (clean and building project),
I have tried this simple code -
im = (ImageView) findViewById(R.id.imageView1);
Bitmap bm = BitmapFactory.decodeResource(getResources(),R.drawable.pic);
Bitmap newBitmap = BitmapFilter.changeStyle(bm, BitmapFilter.BLUR_STYLE);
im.setImageBitmap(newBitmap);
The thing is that the app is crushing and i get the java.lang.OutOfMemoryError.
- Is it possible to save the bitmap with the filter (that are being shown at the ImageView)? and if so how can it be done?
The first problem, it the algorithm issue, I will try to fixed this by optimize the algorithm
and the second problem, the filter function output is a Bitmap
object, so I think you can save it in your phone you android API, for example, you can write a function like this:
public void saveMyBitmap(String fileName,Bitmap mBitmap){
File f = new File(Environment.getExternalStorageDirectory(), fileName);
FileOutputStream fOut = null;
try {
f.createNewFile();
fOut = new FileOutputStream(f);
} catch (IOException e) {
e.printStackTrace();
}
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
try {
fOut.flush();
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}