CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2008
    Posts
    7

    image concatenation

    I am making a program that amongst other things will need to be able to allow the user to vary voltages on a 7-segment display and display the output accordingly, I am not going to create the 128 different possible outcomes (256 if you count the dp!) as individual images. I thought that I should create an image of each part of the 7-seg-display as off or on and concatenate the relevant ones according to input. I can't simply put the different images together next to each other, I need them to actually be one image because the image is returned through an inherited, over-written method that returns a single Image object.

    To summarize:

    how can I concatenate an array of images into a single image object, placing the images in a 2x3 arrangement.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: image concatenation

    You could use a JPanel with a GridLayout manager. Alternatively you could forget the whole image idea and create your own 7 segment display component that just draws the appropriate display (If you google there's probably freely available 7 segment display components available online).

  3. #3
    Join Date
    Sep 2008
    Posts
    7

    Re: image concatenation

    I'm not sure how the JPanel idea woudl work? Do you mean place the images on JLabels and then add the JLabels to a JPanel which I in turn place where I want on my component canvas? at the moment component images get drawn on the canvas in a precise place (wherever they were dropped by the user) And I don't think you can place JPanels absolutely whereas you can with images. ( g.drawImage(c.img, c.x, c.y, this); )

    Your idea about just drawing on the 7-seg could work but can you call drawing methods from outside of the paint( Graphics g) method? Each component must be decoupled from the canvas onto which they are drawn. I could do somthing like:

    for (Component c: myComponents) c.paint();

    would something like that be possible?

    Very much appreciate your time and knowledge

    -Luke

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: image concatenation

    Maybe I've misunderstood what you are after, is the purpose of this to display a 7 seg display to the user or generate an image of a 7 seg display?

  5. #5
    Join Date
    Sep 2008
    Posts
    7

    Re: image concatenation

    Generate an image I suppose. Ultimately to be shown to the user but the 7-segment is a plug-in to a bigger more general purpose circuit simulator that takes for each component an image to display representing that components current state. I could change the main program to accept JPanels or whatever else if they could be positioned well, but its important that in the main program there are no explicit references to the 7-seg. I want to be able to plug in (and out) all sorts of different components that don't require you to edit the main program.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured