I am using Universal-Image-Loader and there is this functionality that access the file cache of the image from sd card. But I don't know how to convert the returned file cache into bitmap. Basically I just wanted to assign the bitmap to an ImageView.
File mSaveBit = imageLoader.getDiscCache().get(easyPuzzle);
Log.d("#ImageValue: ", ""+mSaveBit.toString());
mImageView.setImageBitmap(mSaveBit);
Error: "The method setImageBitmap(Bitmap) in the type ImageView is not applicable for the arguments (File)"
You can convert vector objects and text into bitmaps, and then use bitmap filters to apply effects. The process of converting vector objects into a bitmap is called Rasterization.
To create a bitmap from a resource, you use the BitmapFactory method decodeResource(): Bitmap bitmap = BitmapFactory. decodeResource(getResources(), R. drawable.
You should be able to use BitmapFactory
:
File mSaveBit; // Your image file
String filePath = mSaveBit.getPath();
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
mImageView.setImageBitmap(bitmap);
Define File
String fileName = "/myImage.jpg";
File file = new File(fileName);
get Bitmap of Image
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
Set Bitmap to ImageView
myImageView.setImageBitmap(bitmap);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With