Results 1 to 3 of 3
  1. #1
    satanfx55 is offline Member
    Join Date
    May 2011
    Rep Power

    Default creating an image from scratch

    Here is what I have:
    2 dimensional array of colors with RGB values. (like pixels)

    Here is what I need:
    an image reflecting the contents of that 2d array.

    I have researched this a bit and read about images, bufferedImages, rasters, writableRasters, and the like but I dont quite understand how to use them. My ultimate goal is to create an image from scratch using the RGB values stored in the array and write them to a bitmap file or something.

    Any easy way to do this?


  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Create a BufferedImage, use the getGraphics() method to get its Graphics2D object. Draw on the Graphics2D object and use the ImageIO class to save the BufferedImage.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    For your problem, perhaps what you want to do is create a BufferedImage as Jos states above, but call getRaster() on it to extract the BufferedImage's WritableRaster object. Then you can draw via one of the many setPixel(s) method overloads to your heart's content.

Similar Threads

  1. java from scratch
    By waqar100 in forum New To Java
    Replies: 2
    Last Post: 10-06-2010, 09:05 AM
  2. gui builder vs from scratch
    By dinosoep in forum New To Java
    Replies: 5
    Last Post: 08-08-2010, 12:12 PM
  3. Replies: 1
    Last Post: 08-10-2009, 12:51 PM
  4. Creating a label with an image
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:40 PM
  5. Creating a caret (using an image) in SWT
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-02-2008, 08:51 PM

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