View Single Post
Old 09-18-2007, 05:19 AM   #1 (permalink)
streamh
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation zoom in the text on the image

Please Login to Remove!

Hi,everyone:

I'm research on how to zoom in the texts or lines which drawing on the image, and I want to know how to implement it .
Code:
public void OpenFile()
    {
        
        try {
            FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/ddd78e99bb07e70d6e068c9b.jpg");
            // If no exception is thrown, then the URI is valid, but the file may or may not exist.
            if (fconn.exists()) 
            {
                InputStream input = fconn.openInputStream();
                int available = (int)fconn.fileSize();
                byte[] data = new byte[available];
                input.read(data, 0, available);
                EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length);
                image.setScale(2); //zoom out the image to 50%    
                Bitmap b = image.getBitmap();  
                Graphics myGraphics = new Graphics(b);//draw a text! 
                myGraphics.setColor(0xFF0000);                
                myGraphics.drawText("myText", 20, 5); 
                BitmapField picture = new BitmapField(b);    
                //show the picture
            }
            else            
            {                
                System.out.println("Picture does not exist");
            }
            fconn.close();            
        }
        catch (Exception ioe) 
        {
            System.out.println("Error");
        } 
  }
As well know to all , we can zoom in or out the image by image.setScale(). I draw a text on the Bitmap got by the image.getBitmap() , but the when the image is zoomed in or out , the text is not changed , so how could I implement this?
In my opinion, I should change the bitmap b into EncodedImage after I draw the text on it. So I can call the method setScale() to zoom in or out the text with the origin image. But how can I change the bitmap b into EncodedImage?
Does anyone have any suggestions?
Thank you very much!!
Offline   Reply With Quote