×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    7

    How to store Images in RMS?

    Hi.

    I'm developing some image midlet.

    But I don't know how to store images in Rms.
    help me..

  2. #2
    Registered User
    Join Date
    Aug 2003
    Location
    London, UK
    Posts
    8
    in Pure MIDP1 you can not, in MIDP 2 you can use the Image.getRGB( ... ) and save the int array, and on Nokia phones (but only nokia phones) you could use a getPixels( .. ) and again save the array.

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Bangalore
    Posts
    117
    Hi...,

    How about reading it in the form of byte array and then storing it.


    Regards

    Chandu

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    14
    You can use DirectGraphics to get the pixel byte array, and save the byte array to RMS. like this:
    Image image = Image.createImage("foo.png");
    DirectGraphics dg = DirectUtils.getDirectGraphics(Image.getGraphics());
    byte[] b = new byte[image.getWidth(),image.getHeight()];
    b = dg.getPixels(...);

    and using RMS to store image.

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

    lightpop

    It all depends on where your image comes from. If it's a PNG from a network resource or the jar, it can be read as an array of bytes in the first place, and there's no need to mess about. As Chandu said, you can just store it.

    Even if you can grab an image in any other way, it's likely to be huge - getRGB() grabs an array of ints, that's 32 bits/pixel. If you're limited to 20k of RMS, that's not so many pixels.

    Can you tell us more about where your images are from, and what device you're targeting?

    Graham.

  6. #6
    Registered User
    Join Date
    Feb 2005
    Posts
    9
    what package do i have to import if i will use the DirectGraphics class?

    if the png file is in my network resource or jar, how can i read it as array bytes?

    thanks so much in advance.

Posting Permissions

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