Hi!

I'm developing an image editor for android. In the main activity, I
get to show all images by viewing the thumbnails to make the process
faster. The problem it's that I need to process the image later and I
would get the normal image ID (with the original size, which I think
is in MediaStore.Images.Media). I can't get the form of the query. The
code that I have is the following but I can't obtain the real image ID
(in the IDImage variable):

        int columnIndex = 0;
        String[] projection = {MediaStore.Images.Thumbnails._ID,
MediaStore.Images.Thumbnails.DATA};

        // It is necessary to use EXTERNAL_CONTENT_URI of Thumbnails
because it contains the
        // little image and not the original
        Cursor cursor =
managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
                                                         projection,
                                                         null,
                                                         null,
                                                         null);

        if(cursor != null)
        {
                cursor.moveToPosition(position);

                columnIndex =
cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.DATA);
                String imagePath = cursor.getString(columnIndex);

                columnIndex =
cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
                String _IDThumbnails = cursor.getString(columnIndex);

                String[] nProjection = {MediaStore.Images.Media._ID,
                                                                
MediaStore.Images.Media.PICASA_ID};
                String nSelection = MediaStore.Images.ImageColumns.PICASA_ID
+ " = " + _IDThumbnails;

                Cursor nCursor =
managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                                                                          
nProjection, nSelection, null, null);

                nCursor.moveToFirst();

                columnIndex =
cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
                String _IDImage = cursor.getString(columnIndex);

                FileInputStream is = null;
                BufferedInputStream bis = null;
                try
                {
                        is = new FileInputStream(new File(imagePath));
                        bis = new BufferedInputStream(is);

                        // Imagen is a class that I have defined
                        image = new Imagen(BitmapFactory.decodeStream(bis),
_IDImage);
                }
                catch(Exception e)
                {

                }
                finally
                {
                        try
                        {
                                if(bis != null)
                                        bis.close();

                                if(is != null)
                                        is.close();

                                cursor.close();
                                projection = null;
                        }
                        catch(Exception e)
                        {

                        }
                }
        }

Thank you. Regards,
Jesús

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to