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

OEM Vintage Apple Design Powered Speakers M2497 USED WORKING
$40.6
OEM Vintage Apple Design Powered Speakers M2497 USED WORKING pictureSquare Credit Card Readers for Apple and Android White Portable NEW OEM Sealed
$7.99
Square Credit Card Readers for Apple and Android White Portable NEW OEM Sealed picture(C21) Genuine OEM Apple AC Cord
$25.0
(C21) Genuine OEM Apple AC Cord picture2PCS Foxconn Oem Original Genuine Apple iPhone 7 iPhone Lightning USB Cable
$12.69
2PCS Foxconn Oem Original Genuine Apple iPhone 7 iPhone Lightning USB Cable pictureNew in Box OEM HoneyWell lyric Round Wi-Fi Thermostat Works with Apple HomeKit
$123.99
New in Box OEM HoneyWell lyric Round Wi-Fi Thermostat Works with Apple HomeKit picture






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