Actually i know how to open PNG files as bitmaps. But my code doens't works for open JPG files, i dont know why.
I can't find correct examples on SO or google about how to do this.
I need to have a bitmap with the JPG file opened from a dir of the sdcard. For example "sdcard/images/01.jpg"
Thanks
A color JPG image can be converted to a color bitmap by saving it in the steps below as a color bitmap. Open Microsoft Paint by selecting Start > Programs > Accessories > Paint. Click File > Open. Find and select your logo then click Open.
Viewing BMP Files on AndroidThe Gallery app is the default file viewer for images on the stock version of Android, so this app opens whenever you tap on a BMP file (whether it's stored on an SD card or attached to an email).
File root = Environment.getExternalStorageDirectory(); ImageView IV = (ImageView) findViewById(R.id."image view"); Bitmap bMap = BitmapFactory.decodeFile(root+"/images/01.jpg"); IV.setImageBitmap(bMap);
Always try to use Environment.getExternalStorageDirectory();
instead of sdcard. You need an ImageView somewhere in your layout, however that's how I do this kind of things.
I use this code personally too, and it works here.
Any of the BitmapFactory.decode*
methods should be able to handle standard JPG files.
If you post some code it could be easier to see why it won't work.
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