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

problem in scaling the image

Hey i have developed the camera application that capture images and save it.The problem is when i zoom in and takes the picture the image is displayed into the half screen.But when i captured it without zooming it displays into the whole screen.

 

The code is:

 

 

 

public class ImageScreen extends MainScreen
{
    
        private static final int IMAGE_SCALING = 5;
        private static final String FILE_NAME = System.getProperty("fileconn.dir.photos") + "IMAGE";
        private static final String EXTENSION = ".bmp";
        private SaveMenuItem _saveMenuItem;
        
        private static int _counter;
        
        
        public ImageScreen( final byte[] raw,EncodedImage image )
        {
        
            Bitmap image1 = Bitmap.createBitmapFromBytes( raw, 0, -1, IMAGE_SCALING );
            BitmapField imageField = new BitmapField( image1 );
            add(imageField);
            
            _saveMenuItem = new SaveMenuItem("Save", raw);
            addMenuItem(_saveMenuItem);
            
        }
            
        private final class SaveMenuItem extends MenuItem
        {        
            private byte[] _raw;
         
            SaveMenuItem(String text, byte[] raw)
            {            
                super(new StringProvider(text), 0x230010, 0);
                
                _raw = raw;
                setCommand(new Command(new CommandHandler()
                {
                    public void execute(ReadOnlyCommandMetadata metadata, Object context)
                    {
                        try
                        {       
                          
                            FileConnection file = (FileConnection)Connector.open(FILE_NAME + _counter + EXTENSION);
            
                            while(file.exists())
                            {
                                file.close();
                                ++_counter;
                                file = (FileConnection)Connector.open(FILE_NAME + _counter + EXTENSION);
                            }
            
                  
                            file.create();
            
                            OutputStream out = file.openOutputStream();
                            out.write(_raw);
            
                     
                            out.close();
                            file.close();                                         
                            
                    
                            Dialog.inform("Saved to " + FILE_NAME + _counter + EXTENSION);                       
                     
                        }
                        catch(IOException ioe)
                        {
                            Dialog.alert("ERROR " + ioe.getClass() + ":  " + ioe.getMessage());
                        }
                    }
                }));
            }        
        }   
}

 

 

Thanks in advance