×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Lightbulb Create Image from String.

    Hello,
    Im looking for an example in how to create an Image from a string.

    Any Suggestions?

    Y

  2. #2
    Registered User
    Join Date
    Mar 2008
    Location
    Cairo-Egypt
    Posts
    23

    Re: Create Image from String.

    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
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Lightbulb Re: Create Image from String.

    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
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Create Image from String.

    Would this page help? Or this one?
    Last edited by bogdan.galiceanu; 2008-08-10 at 14:43.

  5. #5
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Lightbulb Re: Create Image from String.

    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
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Create Image from String.

    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
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Lightbulb Re: Create Image from String.

    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
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Create Image from String.

    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
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Create Image from String.

    ypele,

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

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

  10. #10
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Thumbs up Re: Create Image from String.

    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
    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
  •  
×