Ouch! you were right... I was being over cautious I think, closed it before even using it! :)
On Oct 21, 12:57 pm, Alan Cassar <[email protected]> wrote: > I don't know whether this is your main problem, but you are closing the > fileDescriptor before you are actually using it > > AlanCassar, Software Engineer | Tel: +356 21334457 | Fax: +356 21 > 334156ricstonLtd., Northfields Suite 4, Independence Avenue,MostaMST9026 - > MALTA > > > > email: [email protected]| web:ricston.com > > > > ----------Disclaimer- This email and any files transmitted with it are > confidential and contain privileged or copyright information. You must not > present this message to another party without first gaining permission from > the sender. If you are not the intended recipient you must not copy, > distribute or use this email or the information contained in it for any > purpose other than to notify us. If you have received this message in error, > please notify the sender immediately and delete this email from your system. > We do not guarantee that this material is free from viruses or any other > defects although due care has been taken to minimise the risk. Any views > stated in this communication are those of the actual sender and not > necessarily those ofRicstonLtd. or its subsidiaries. > > > > > > > Samuh wrote:I am working on a small program that is supposed to : 1. Display > images on the SD card 2. Get the image chosen by the User and display it on > Canvas. 3. Since the image can be large, sub sample it/ scale it or something > appropriate I got the first two parts done using the following snippets: 1. > By launching an intent such as: Intent photoPickerIntent = new Intent( > Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); > startActivityForResult(photoPickerIntent, RQST_CODE); 2. The chosen image URI > is received in onActivityResult(..): Uri chosenImageUri = data.getData(); > Now, I can create a Bitmap object from this URI : > Media.getBitmap(this.getContentResolver(),chosenImageUri); The problem is: I > want to resize/sub sample this bitmap. I did a bit of reading and found a > certain BitmapFactory.Options class that has parameters whereby one can > specify the sample size. This "options" instance can be passed to one of > several overloaded BitmapFactory.decodeXX(..) methods, but none of these > methods take a URI as parameter. Is there a way to do this? I even tried > this: BitmapFactory.Options options = new BitmapFactory.Options(); > options.inSampleSize = 2; AssetFileDescriptor fileDescriptor =null; try { > fileDescriptor = this.getContentResolver().openAssetFileDescriptor > (chosenImageUri,"r"); } catch (FileNotFoundException e) { > e.printStackTrace(); } finally{ try { fileDescriptor.close(); } catch > (IOException e) { e.printStackTrace(); } } mBitmap = > BitmapFactory.decodeFileDescriptor (fileDescriptor.getFileDescriptor(), null, > options); But i am still getting null in mBitmap. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

