Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Problem in thumbnail format

Hi all,

I have developed a camera application that captures image and store it in a folder say file:///store/home/user/pictures/

Now i want to add another feature into it that shows the captured image in a thumbnail format..

 

I tried it using  file picker method its working properly but with a single and that is when i capture image and open the view picture than it shows the image below the captured one.I want that it should display one image at a time.

 

Here is the code::

 

FilePicker filePicker;
                                filePicker=FilePicker.getInstance();

                                filePicker.setPath("file:///store/home/user/pictures/");
                                filePicker.setListener(new Listener()
                                {       
                                    public void selectionDone(String path)
                                    {
                                        bitmapField.setBitmap(getTheImage(path));
                                    }
                                });
                              filePicker.show();

                         bitmapField = new BitmapField();
                         add(bitmapField);

 

 

        private Bitmap getTheImage(String url)
        {
            Bitmap bitmap=null,scaleBitmap=null;
            InputStream inputStream=null;
            FileConnection fileConnection=null;     
            try
            {
                fileConnection=(FileConnection) Connector.open(url);
                inputStream=fileConnection.openInputStream();           
                byte[] data=new byte[(int)fileConnection.fileSize()];           
                data=IOUtilities.streamToBytes(inputStream);
                inputStream.close();
                fileConnection.close();
                bitmap=Bitmap.createBitmapFromBytes(data,0,data.length,5);

                //You can return this bitmap otherwise, after this you can scale it according to your requirement; like...
                scaleBitmap=new Bitmap(Display.getWidth(), Display.getHeight());
                bitmap.scaleInto(scaleBitmap, Bitmap.FILTER_LANCZOS);           
            }
            catch (Exception e)
            {
                try
                {
                    if(inputStream!=null)
                    {
                        inputStream.close();                
                    }
                    if(fileConnection!=null)
                    {
                        fileConnection.close();
                    }
                }
                catch (Exception exp)
                {

                }
                scaleBitmap=Bitmap.getBitmapResource("noimage.png");//Your known Image;     
            }
            return scaleBitmap;
        }

 

Thaks in advance.

 

 

 

 

 

 

 

Please use plain text.