×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Drawing Lines on an Image (image graphics object returns null)

    Guys i have a problem here. i have been able to read an image display it on my form. what i want to do now is draw lines on the image which i am showing. ihave few xy points which i have to draw on my image. Here is the CODE

    CurrentImage=Image.createImage(b,0,b.length);
    ImageItem image = new ImageItem("Image",CurrentImage, ImageItem.LAYOUT_CENTER, "Image Exceeds size");
    form.append (image);

    where b is the byte array containg image data.

    i thought by getting the grahpics object of my image

    Graphics g=CurrentImage.getGraphics();

    i might be able to draw lines on it, but this function returns the graphics object as null. Am i missing something? any kind of help or code will be appreciated. i can use its d.drawline function to draw my lines on the image. i am using Nokia 6680
    Last edited by nicenouman; 2006-09-19 at 11:46.
    Regards
    Nouman

  2. #2
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Drawing Lines on an Image (image graphics object returns null)

    I manage to solve the problem by first creating an empty image of same size and then getting its graphics object. using the graphics objects drawimage method i drew my image into it. as this method takes an image and then using graphics object draw lines method i drew the necessary lines. it wasnt difficult.
    Regards
    Nouman

  3. #3
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Drawing Lines on an Image (image graphics object returns null)

    Hi nicenouman,
    i suppose you have succeded in drawing the line by replacing the form with a canvas.

    thanks
    Soku

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: Drawing Lines on an Image (image graphics object returns null)

    Quote Originally Posted by nicenouman
    i might be able to draw lines on it, but this function returns the graphics object as null. Am i missing something?
    Just to clear up any doubts: you were trying to draw on an immutable Image. From the Image docs:
    Images are either mutable or immutable depending upon how they are created. Immutable images are generally created by loading image data from resource bundles, from files, or from the network. They may not be modified once created. Mutable images are created as blank images containing only white pixels. The application may render on a mutable image by calling getGraphics() on the Image to obtain a Graphics object expressly for this purpose.
    shmoove

  5. #5
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Drawing Lines on an Image (image graphics object returns null)

    your 110% right shmoove. that was exactly the case.
    Regards
    Nouman

Similar Threads

  1. Please its veru urgent on nokia 3250
    By siva_guduru in forum Mobile Java General
    Replies: 8
    Last Post: 2008-05-01, 10:24
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  4. A BUG!!! Drawing to image graphics (3650)
    By palmcrust in forum Mobile Java General
    Replies: 2
    Last Post: 2004-02-23, 02:12
  5. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52

Posting Permissions

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