BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-30-2007, 07:19 AM   #1 (permalink)
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
Question draw text on a picture

Please Login to Remove!

Hi,everyone:

I'm trying to draw something on a picture showed on BB, and I'm confused how to do it. Firstly, I read a picture from card and show it on BB; and now I want to draw text on the picture by a menu "write", could anyone help me ?
Thank you very much!
Code:
import net.rim.device.api.ui.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.microedition.io.*;
import javax.microedition.io.file.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
import net.rim.device.api.math.*;

class picViewer extends UiApplication
{
    public static void main(String[] args)
    {
        //create a new instance of the application
        //and start the application on the event thread
        picViewer theApp = new picViewer();
        theApp.enterEventDispatcher();
    }
    
    public picViewer() 
    {    
        pushScreen(new ViewScreenDemo());
    } 
    
    class ViewScreenDemo extends MainScreen
    {        
        private WriteMenuItem _writeMenuItem;
        private EncodedImage image;
        
        private class WriteMenuItem extends MenuItem 
        {
            private WriteMenuItem() 
            {
                super("write",100000, 5);
            }                  
            public void run() 
            {                
                onWrite();
            }
        } 
        
        public ViewScreenDemo() 
        {
            _writeMenuItem = new WriteMenuItem();
            try 
            {
                FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/1.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);   
                    Bitmap b = image.getBitmap();
                    BitmapField picture = new BitmapField(b);  
                    add(picture);             
                }
                else {
                    add(new LabelField("Picture does not exist"));
                }
                fconn.close();
                }
            catch(Exception ioe)
            { System.out.println("error!");}
        }        
        protected void makeMenu(Menu menu, int instance) 
        {            
            menu.add(_writeMenuItem);
            super.makeMenu(menu, instance);
        } 
        public void onWrite()
        {
            //?????????
        }  
    }
    
}
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Allen Bradley 2711P-RP1A /F PanelView Plus Logic Module AC 64MB Flash/RAM
$489.0
Allen Bradley 2711P-RP1A /F PanelView Plus Logic Module AC 64MB Flash/RAM  pictureLOT OF 6 RAM TECHNOLOGIES PFC310PCX 12V ATX 310W MEDICAL/LAB GRADE POWER SUPPLY
$100.0
LOT OF 6 RAM TECHNOLOGIES PFC310PCX 12V ATX 310W MEDICAL/LAB GRADE POWER SUPPLY picture50Pcs Ht1621b Ssop-48 Ht1621 Ssop48 Holtek Ram Mapping Controller Ic New A
$6.4
50Pcs Ht1621b Ssop-48 Ht1621 Ssop48 Holtek Ram Mapping Controller Ic New A pictureMassey Ferguson 165 Tractor 3pt Ram Rod & Rocker Bracket
$30.0
Massey Ferguson 165 Tractor 3pt Ram Rod & Rocker Bracket pictureOliver 1850 Tractor 3pt Ram Rod
$40.0
Oliver 1850 Tractor 3pt Ram Rod picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.