Discussion Board

Results 1 to 6 of 6

Thread: Saving Image

  1. #1
    Regular Contributor snehalpatil's Avatar
    Join Date
    Feb 2008
    Posts
    174
    Hello All,


    I am developing an application in which i am showing images on canvas. by 3-4 images i am creating one image..now i want to save this image in any format which is recognize by any handset. i want to save whole as a single image.
    is it possible. if yes then please tell me how can i save it in handset? or can we take snapshot of this screen.
    Regards,
    Snehal

  2. #2
    Registered User ektasrv's Avatar
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941
    Quote Originally Posted by snehalpatil View Post
    Hello All,


    I am developing an application in which i am showing images on canvas. by 3-4 images i am creating one image..now i want to save this image in any format which is recognize by any handset. i want to save whole as a single image.
    is it possible. if yes then please tell me how can i save it in handset? or can we take snapshot of this screen.
    Step 1: Create a big mutable image - fetch the graphics instance from it.
    Step 2: Paint all other Images on this image using its graphics instance.
    Step 3: refer to this FN wiki code - http://wiki.forum.nokia.com/index.ph...ing_in_Java_ME
    Step 4: Write the PNG formated data using file Connection to the phone gallery.
    Thanks,
    Ekta

  3. #3
    Regular Contributor snehalpatil's Avatar
    Join Date
    Feb 2008
    Posts
    174
    Quote Originally Posted by ektasrv View Post
    Step 1: Create a big mutable image - fetch the graphics instance from it.
    Step 2: Paint all other Images on this image using its graphics instance.
    Step 3: refer to this FN wiki code - http://wiki.forum.nokia.com/index.ph...ing_in_Java_ME
    Step 4: Write the PNG formated data using file Connection to the phone gallery.
    Hi,

    Thanks for the reply,


    How to fetch graphics instance?? actually i am not getting what u r saying
    Regards,
    Snehal

  4. #4
    Registered User ektasrv's Avatar
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941
    Quote Originally Posted by snehalpatil View Post
    Hi,

    Thanks for the reply,


    How to fetch graphics instance?? actually i am not getting what u r saying
    See the API doc - for Image class in j2me

    try something like this -
    Code:
        Image target= Image.createImage(tragetWidth, targetHeight);        // --- Step 1 create big image
    
        Graphics g = target.getGraphics();    // --- Step 1 - fetch the graphics instance
        
    g.drawImage(img1, 0, 0, TOP|LEFT); // Step 2
    g.drawImage(img2, 0, 0, TOP|LEFT);  
    g.drawImage(img3, 0, 0, TOP|LEFT);
    
    // Step 3 --- now you have a Image called target which has all these small images, do process it with png encoder
    Thanks,
    Ekta

  5. #5
    Regular Contributor snehalpatil's Avatar
    Join Date
    Feb 2008
    Posts
    174
    hi
    Thanks
    I did that.
    All images drawing,


    this is the code :- but after in try....nothing is happening..System confirmation alert is coming on emulator asking "this application wants to write the local file system. Is it ok to update your files??" and its hanging the emulator..


    byte[] pngData = PNGEncoder.toPNG(im, false);
    FileConnection filecon;
    try
    {
    System.out.println("In try ...");
    filecon = (FileConnection)Connector.open("file:///C:/Nokia/Images/testPic.png");
    if(!filecon.exists())
    {
    filecon.create();
    }
    System.out.println("after creating file...");
    OutputStream os = filecon.openOutputStream();
    System.out.println("after opening connection....");
    os.write(pngData);
    System.out.println("after writing data....");
    os.close();
    filecon.close();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    Last edited by snehalpatil; 2010-07-26 at 14:28.
    Regards,
    Snehal

  6. #6
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Try these points :

    1. Try to put the OS.flush() before you close the streams.
    2. Try to trace that whether there is any exception while you are wriitng the image,
    3. Also dont use the PNG encoder first you test that whether your code is creating the image if yes the you encode.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Saving an image
    By chandran.biju007 in forum Mobile Java General
    Replies: 6
    Last Post: 2011-01-12, 18:54
  2. Saving capture image
    By ckt in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-09-26, 19:47
  3. saving an image
    By gaurav17281 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-06-16, 05:28
  4. preView image without saving
    By kashifqasim in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-06-13, 12:39
  5. Image Preview without saving
    By kashifqasim in forum Mobile Commerce
    Replies: 2
    Last Post: 2003-06-11, 10:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved