Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor ypele's Avatar
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100
    Hello,
    Im looking for an example in how to create an Image from a string.

    Any Suggestions?

    Y

  2. #2
    Registered User lamiaaMB's Avatar
    Join Date
    Mar 2008
    Location
    Cairo-Egypt
    Posts
    23
    Quote Originally Posted by ypele View Post
    Im looking for an example in how to create an Image from a string.
    Do you mean that " Image.createImage(String name)" ??
    If yeas, you pass the url of the image you wanna add to ypur midlet to this method, something like this:

    Image photo=Image.createImage("/res/Photoes.png");

    If no, please explain what you want.

    Lamiaa
    http://movi-az2.blogspot.com/

  3. #3
    Regular Contributor ypele's Avatar
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100
    OK,
    I have a Piece of String (Image) - which transfers via a servlet in XML.
    after Getting the data from Server, i extract the data from the XML element into a String.
    Code:
    pe = parser.read();
    than keen of doing the followings:
    Code:
    imageByteArray = Base64.decode(pe.getText());
    imageLenght = imageByteArray.length;
    icon.createImage(imageByteArray, 0, imageLenght);
    After this, it should create an Image object named "icon".
    Then, i would like to put this Image object into RMS.

    Please Advice.
    Y

  4. #4
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    Would this page help? Or this one?
    Last edited by bogdan.galiceanu; 2008-08-10 at 14:43.

  5. #5
    Regular Contributor ypele's Avatar
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100
    Hi,
    Didnt find any relative issue in your link, sorry...
    My Use Case is :

    1. Get an String from an XML. it contains Image DATA.
    2. Somehow, Convert the data into An Image, with All relavent data like Width & Higth
    3. After Success, Add the Image into a RMS.


    Thanks
    Y

  6. #6
    Nokia Developer Champion hartti's Avatar
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192
    ypele, to me your use case sounds like it could be solved with the first link provied by bogdan galiceanu. Could you take a second look at that link..

    If you are still sure that does not solve your problem, then maybe you should provide us with some example parts of the string you mention, so we could really understand your problem

    Hartti

  7. #7
    Regular Contributor ypele's Avatar
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100
    Hartti,
    I have Manage to convert the string into an Image:
    Code:
    imageByteArray = Base64.decode(ImageString);
    imageLenght = imageByteArray.length;
    Image.createImage(imageByteArray, 0, imageLenght);
    the issue begins when i like to get its WIDTH or HEIGHT( to add it into the RMS)
    Code:
    int height, width;
    height = icon.getHeight();
    width = icon.getWidth();
    The code crashes with : java.lang.NullPointerException

  8. #8
    Nokia Developer Champion jappit's Avatar
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,391
    Hi ypele,

    from your Exception and your previous code, it seems that you're not correctly initializing the icon variable with the newly created Image.

    For example, this line:
    Code:
    Image.createImage(imageByteArray, 0, imageLenght);
    should look something like:
    Code:
    icon = Image.createImage(imageByteArray, 0, imageLenght);
    If you already do this, then you should consider about possible Exceptions thrown by the createImage method itself.

    Pit

  9. #9
    Nokia Developer Champion hartti's Avatar
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192
    ypele,

    where do you create the icon object?
    shouldn't this be

    Code:
    icon = Image.createImage(imageByteArray, 0, imageLenght);
    Hartti

  10. #10
    Regular Contributor ypele's Avatar
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100
    Hartti & Jappit,
    Wicked!
    previously i have creted the " Image icon object" but havent initiated it properly. your examples light the solution.

    Thanks Mates.
    Yaniv

Similar Threads

  1. Image - byte[] - String (re)conversion
    By lampz in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-02-19, 11:47
  2. Replies: 2
    Last Post: 2007-06-21, 05:34
  3. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  4. Create imutable image from mutable causes Exception
    By rikard_wigforss@hotmail.com in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2004-07-19, 09:04
  5. how to create image buffers in symbian?
    By withlove74 in forum Symbian C++
    Replies: 1
    Last Post: 2003-11-19, 08:24

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