Results 1 to 2 of 2
  1. #1
    Prime624 is offline Member
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    96
    Rep Power
    0

    Default IndexColorModel 255 Colors to BufferedImage

    I need to write an image to a .png with a 255-color indexed color model. I know usually do it like this:
    Java Code:
    BufferedImage img=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_INDEXED,model);
    but that doesn't work with models with 255 colors (as opposed to 256 colors). I'm fairly sure it is the BufferedImage creation that is the problem, as when I call model.getMapSize(), it returns the correct size.

    The extra color added to the image's index is 15,15,15.

    Should I be something other than a BufferedImage to write the image, or should I be using a different constructor for BufferedImage, or am I doing something else wrong?

  2. #2
    Prime624 is offline Member
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    96
    Rep Power
    0

    Default Re: IndexColorModel 255 Colors to BufferedImage

    Additional Information: I am drawing the BufferedImage by drawing a regular (BufferedImage.TYPE_INT_RGB) BufferedImage, pixel by pixel, then transposing it onto the indexed BufferedImage by drawing on it with a Graphics2D object.

Similar Threads

  1. Changing colors
    By leeroijenkiins in forum New To Java
    Replies: 2
    Last Post: 04-26-2013, 07:30 PM
  2. How do i add colors
    By ytrewqc in forum New To Java
    Replies: 1
    Last Post: 11-01-2011, 03:15 PM
  3. Animation with colors
    By musico in forum New To Java
    Replies: 2
    Last Post: 05-28-2011, 09:07 PM
  4. In Case You Want Colors!
    By angryboy in forum Forum Lobby
    Replies: 0
    Last Post: 08-29-2009, 11:06 PM
  5. Rectangle and Colors
    By urbim in forum Java Applets
    Replies: 0
    Last Post: 07-11-2009, 04:03 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
  •