×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Unhappy [moved] Store and retrieve Images

    Hello everyone,
    i want to store many images on my Midlet and then retrieve them one after one. There are many example showing how to store an image from a jar file. But i didn't see any example showing how to store efficiently many images from a jar file. Please i'm new in J2ME and i want to learn how to store and retrieve images from a jar file. I need your help and hope i have explain my problem very well .
    I will be very thankful for any kind of suggestion.
    Please help me
    Your fye_08

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Store and retrieve Images

    Hi Fye_08,

    I've received the email but I'm afraid I'm not able to help you. Just be patient and I'm sure you will receive advice from a Java developer.

    However, your use case is a bit strange, I think. How would the 2000 images get to be in that jar and how will the jar get on the phone? That would presumably be quite a huge jar file ...
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: Store and retrieve Images

    Hi ltomuta,
    thanks for your prompt response. I think, i can use an external card to extend the memory card. I'm using N95 and i hope that i can find a 32GB card for example to store this huge jar file within. The problem is that, i don't know how to store all those Pictures... I'm still waiting ...
    Thanks very much
    Fye_08

  4. #4
    Super Contributor
    Join Date
    Jun 2007
    Location
    Mumbai
    Posts
    539

    Re: [moved] Store and retrieve Images

    Hi Fye_08,
    can u explain a little wats ur issue? cause for retriving images from jar u just need to create Image using api Image.createImage("/filename"); i believe that u know this already. so explain ur issue a little.
    Prakash

  5. #5
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    104

    Re: [moved] Store and retrieve Images

    Hi Fye_08

    I think you want to save image in your mobile from the jar.You should open the file connection like this

    FileConnection filecon = (FileConnection)
    Connector.open("file:///+"path");
    //path===>where u want to save the image and by which name mention in path // Then get the file from jar like this

    InputStream inputStream=getClass().getResourceAsStream("/*resource address*/");

    // use OutputStream class for write the data

    OutputStream outputStream=filecon.openOutputStream();

    // then write the file by this code
    int i;
    while((i=inputStream.read())!=-1)
    {
    outputStream.write(i);
    }
    outputStream.close();
    filecon.close();

    Your Image will be save on your given address and name . Please try to do this type. I hope It will be done by you.

    Thanks
    shravan

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Unhappy Re: [moved] Store and retrieve Images

    Hello everyone,
    thank you very much for your suggestions.
    @Prakash: I already know this api. The problem is that, i have many images to store. I can use createImage() to create one or ten images from the jar. But i don't know how to do this if i have something like thousand images(or a video) to store and retrieve. I know, that it's very ugly to call createImage()several times in the file just to create images. How can i create many images and store them with this api? It's that possible to do that?
    @sharvan1981, i don't want to store my images to a specific path. I want to create images and retrieve them any time i want to do that. I thought that, i can use hashtable to store images into but first of all i have to create this images with createImage() and then store all that with my hashtable. How can i create so many images?
    Please help me. I'm new in j2me.
    Best regards
    Fye_08

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: [moved] Store and retrieve Images

    Yes, you can store images in a Hashtable.

    But, ultimately, you must call createImage() in order to get an Image object.

    You can combine multiple small images into one large on, call createImage() once, then draw portions of it using drawRegion().

    Be aware that images take a lot of memory. Between two and four bytes per pixel, much more than the size of the PNG or JPEG file.

    Depending on your file naming scheme, you can of course load images like:

    PHP Code:
    Image[] images = new Image[IMAGE_COUNT];
    for (
    int i 0IMAGE_COUNTi++) {
        
    images[i] = Image.createImage("picture" ".png");

        
    // if there are many images, you might want some progress to the user
        
    progressPercent = (100) / IMAGE_COUNT;
        
    repaint();
        
    serviceRepaints();

    Do you have a specific concern about this?

    Cheers,
    Graham.

  8. #8
    Super Contributor
    Join Date
    Jun 2007
    Location
    Mumbai
    Posts
    539

    Re: [moved] Store and retrieve Images

    U can create as many image using the API thats not a problem, though it will be little slow. but as u talking about thousand images, are u sure all of them can be on heap and u wont get OutOfMemory? wat kind of size u talking about?
    Prakash

  9. #9
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Unhappy Re: [moved] Store and retrieve Images

    Hi Graham,
    thank you for your reply. I understand what you want me to do. But i'm confused. All my images are saved somewhere inside my computer and i want to load each image to a jar file. I store a folder inside my Netbeans's project containing my images and i want to load each image one by one without using an array. To hold one image on this folder is possible, the second one ist also possible if i just have two or three images inside this folder. I don't want anytime to write createImage()in order to hold each image and it's also cumbersome to do like that. What do you think about it? I'm looking for a mechanism, that can help to load images inside my folder. How can i do that please? Can you please give me the j2me version of your php code? .
    Best regards
    Fye_08

  10. #10
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: [moved] Store and retrieve Images

    That is J2ME code... I use the "PHP" tags because it colours the code nicely.

    You can store as many images in a JAR as you want. There is no limit. A JAR file is really just a ZIP file.

    What you cannot do, is get a list of files in the JAR, from J2ME.

    You could create a text file, containing a list of the images, and put the text file in the JAR. Then you can read the text file, and create the images.

    Does this make sense?

  11. #11
    Registered User
    Join Date
    Nov 2008
    Posts
    13

    Re: [moved] Store and retrieve Images

    Hey,
    Your suggestion is interesting. I will write the code now and let you know the issues. But if you have any other suggestions or code snippet, please let me know.
    Thank you all again ...
    Best regards
    Fye_08

Similar Threads

  1. Store string in Record Store
    By Nourayn in forum Mobile Java General
    Replies: 15
    Last Post: 2010-08-21, 04:08
  2. Save image in record store
    By nim_esh in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-03-09, 23:09
  3. retrieve & store data in Nokia 3100
    By business2share in forum Mobile Java General
    Replies: 0
    Last Post: 2004-09-29, 16:04
  4. series of images
    By j2me_raj in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2003-09-12, 06:04
  5. series of images from http site
    By j2me_raj in forum Mobile Java General
    Replies: 0
    Last Post: 2003-09-12, 06:02

Posting Permissions

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