Results 1 to 3 of 3
  1. #1
    Goseph is offline Member
    Join Date
    Dec 2008
    Posts
    8
    Rep Power
    0

    Default [SOLVED] Image drawing, saving

    My problem is I need to draw a 7 segment display with the appropriate bits lit up and then pass a single Image Object of this to a different object. I have thought of a couple of ways of doing this but am unable to implement either:

    1) (preferred) Draw the appropriate representation of the 7-seg using paint( Graphics G) and then somehow get an Image representation of what I have drawn. Perhaps this would involve saving as a temporary .gif and reloading the image?

    2) concatenate 7 images representing the appropriate bits of the 7 seg either turned on or off (so I would have to have 14 images pre-saved to build from)

    Please help!

    PS. am I posting in the correct forum?

  2. #2
    neilcoffey is offline Senior Member
    Join Date
    Nov 2008
    Posts
    286
    Rep Power
    7

    Default

    A couple of approaches:
    (1) Look at the BufferedImage class. You construct a BufferedImage, call createGraphics() on the image, then make normal graphics calls. You can pass BufferedImage to wherever, and any paintComponent() method (or any other thing with a Graphics) can draw it.
    (2) Instead of an actual image, you can pass around a Shape, which you can then ask a given Graphics to render at any time. Look at the java.awt.geo.GeneralPath class.
    (3) Do you actually need to pass around an IMAGE or shape, or do you just need to pass around some object that knows how to draw a given digit to a given Graphics at a given position?

  3. #3
    Goseph is offline Member
    Join Date
    Dec 2008
    Posts
    8
    Rep Power
    0

    Default

    ah thankyou very much for directing my attention to using the BufferedImage class, this helped alot.

Similar Threads

  1. Saving JFrame
    By jralexander in forum New To Java
    Replies: 7
    Last Post: 12-03-2008, 10:19 PM
  2. Saving changes done through a program
    By xcallmejudasx in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 05:53 PM
  3. drawing an image to an offscreen image
    By hunterbdb in forum Java 2D
    Replies: 9
    Last Post: 10-30-2008, 07:17 PM
  4. Saving Values
    By Sysem in forum New To Java
    Replies: 10
    Last Post: 06-02-2008, 07:29 PM
  5. Replies: 0
    Last Post: 01-08-2008, 06:29 PM

Posting Permissions

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