jasjisdo / gtge

Automatically exported from code.google.com/p/gtge
2 stars 2 forks source link

Add method in ImageUtil to easily convert an image to a specified transparency value. #22

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
ImageUtil currently does not have a method to easily convert a source image to 
another image with the same colors but a different transparency value.  This 
enhancement request asks that this method be added.

The suggested method signature is as follows:
RenderedImage/WritableRenderedImage* 
createTransparentImage(RenderedImage/WritableRenderedImage* source, short 
transparency);

* It is not known at this time which interface/abstract type can be used here.  
It may be sufficient to have a RenderedImage instance, or perhaps 
WritableRenderedImage must be used.

The use case of this is as follows.  Note that this method shouldn't be 
specific to BufferedImage - more image types not specifically extending 
BufferedImage should be allowed if possible*

BufferedImage source = // .. the source image comes from somewhere.
BufferedImage destination = source;
if(// some condition means we need transparency adjustment) {
     destination = (BufferedImage) ImageUtil.createTransparentImage(source, (short) transparency);
}

Note also that, depending on the interface that is ultimately used, this method 
may have to use a side-effect to alter the image - that is, the source instance 
may be altered as a result of this call.  The exact method of operation of this 
method is unknown at this time.

Original issue reported on code.google.com by MetroidF...@gmail.com on 27 Jun 2010 at 8:38