×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    problem in getting image from local resources..

    hello hi,

    i have a serious problem in getting imagefrom my pc.........pleasedocheck my code once.............

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.rms.*;
    import java.io.*;
    import org.bouncycastle.util.encoders.Base64;


    public class StoreImage extends MIDlet implements CommandListener {

    private Image image=null;
    private Display display=null;
    private Command storeImage=null;
    //private Command getImage=null;
    //private Command exit = null;
    //private Alert alert = null;
    private Form form=null;
    // private RecordStore record=null;

    public StoreImage() {
    form = new Form("Store Image");
    storeImage = new Command("StoreImage",Command.SCREEN,1);
    //getImage = new Command("GetImage", Command.SCREEN,1);
    //alert = new Alert("Image Stored");
    //exit = new Command("Exit", Command.EXIT,1);
    form.addCommand(storeImage);
    //form.addCommand(getImage);
    //form.addCommand(exit);
    form.setCommandListener(this);
    display = Display.getDisplay(this);
    }

    /*

    * This method opens the Record store

    */



    /* This method is used for storing the images into the RMS


    * "img.png" file should be in the resources dir


    */




    /* Retrieves the Image from the RMS and displays.

    */



    public void startApp() {
    display.setCurrent(form);
    }

    public void pauseApp() {

    }

    public void destroyApp(boolean b) {

    }

    public void commandAction(Command c, Displayable d) {
    if(c == storeImage) {
    storeImage();
    }

    }
    public void direct()throws Exception{


    ////////unable to load image into image object...........................
    Image image=Image.createImage("d:/direct/resourse/sunny/phone.png");
    form.append(image);


    }

    private void storeImage() {
    try {
    /////unable to load image into stream....
    InputStream inputStream = getClass().getResourceAsStream("C:/Documents and Settings/admin/Desktop/images/images12.png");
    ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
    int ch;
    byte[] imageBytes;
    while((ch = inputStream.read())!= -1 )
    byteOutStream.write(ch);
    imageBytes = byteOutStream.toByteArray();
    byte[] base64_data = Base64.encode(imageBytes);
    System.out.println(base64_data);
    } catch (Exception e) {
    //log("Err in Add Image to RMS"+e);
    } finally {
    //inputStream.close();
    }
    }



    }

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: problem in getting image from local resources..

    You want to access images from your PC ? Are you developing app for Mobile devices or PC ? ? Pls set your expectations clear.

    Regards
    Gopal

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: problem in getting image from local resources..

    ok.how could i get an image into my eclipse emulator from my pc.....is it possible or not...

  4. #4
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: problem in getting image from local resources..

    Have you tried to copy the images to the FileSystem of the emulator and access it from there ?

    Regards
    Gopal

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: problem in getting image from local resources..

    yes.but unable to access it...

    can u tell me..... how should i access images in mobile.....

  6. #6
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: problem in getting image from local resources..

    Its definitely possible to access files in the mobile device file system. You can access it using FileConnection API (JSR75). We have lot of articles and code samples in our Nokia Developer Wiki. Pls give a search or I can share the code samples once I have access to laptop later today.

    Regards
    Gopal

  7. #7
    Registered User
    Join Date
    Jul 2011
    Posts
    35

    Re: problem in getting image from local resources..

    ho thanku..i just had a look at jsr75 today....

  8. #8
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: problem in getting image from local resources..

    Incase you missed, have a look at this article - How to read an image from Gallery in Java ME

    Java PIM & Files/Data Articles

    Regards
    Gopal

Similar Threads

  1. How to display image from resources?
    By Juggle4Evr1 in forum Symbian User Interface
    Replies: 21
    Last Post: 2010-12-28, 17:28
  2. Replies: 5
    Last Post: 2010-09-01, 11:57
  3. problem in getting the image through URL
    By lakshmanraob in forum Mobile Java General
    Replies: 1
    Last Post: 2005-10-04, 10:28
  4. Series 60 Emulator, reading image from resources ?
    By kakoskin in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-02-05, 11:19
  5. Series60 SDKs - Image from resources
    By roshannoronha in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-11-22, 14:55

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×