Editing images in Java - a bit further

ok, thanks to the help provided on this forum i can now edit and change images using Java2D but i have another question concerning this.

i’ve found that unless the image already has a transparent pixel, it isn’t possible to colour an image transparent. This, i believe, is attributed to the ColorModel used to create the “copy” of the image. So my question is, is there anyway to create my own ColorModel that will allow transparent pixels if wanted.

Mike Lomax

Use GraphicsConfiguration.createCompatibleImage(int width, int height, int transparency) to create a new BufferedImage of the same size as your existing image, but with the transparency that you want and then draw your old image into the new image. Voila, you have now added the possibility of transparency to your image.

Alternatively use the appropriate constructor/type in BufferedImage to create a new image with a specific type (that naturally allows transparency).

ah i see, i was duplicating the image, adjusting it, and then converting it wrongly. thanks that has helped in a great deal of ways.