> This is probably an offputtingly trivial question to someone who isn't
> as new to JAI as I am. I have a servlet that, depending on some
[quoted text clipped - 13 lines]
> picture. I understand that JAI doesn't have this dependency on X and
> would like to change my program to use JAI.
you don't need JAI for this.
There are a few ways to manipulate alpha.
With Java 1.x you can use RGBImageFilter.
With Java 2 and BufferedImage you can use getRGB() to get pixel values,
then change alpha and write it back with setRGB().
Note that BufferedImage must support alpha (TYPE_INT_ARGB for example)
something like
//alpha from 0 to 255
void setAlpha(BufferedImage bi, int alpha) {
int w = bi.getWidth();
int h = bi.getHeight();
int [] rgb = new int[w * h];
bi.getRGB(0, 0, w, h, rgb, 0, w);
int _alpha = (alpha & 0xFF) << 24;
for(int i = 0; i < rgb.length; i++) {
rgb[i] = (rgb[i] & 0xFFFFFF) | _alpha;
}
bi.setRGB(0,0,w, h, rgb, 0, w);
}
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Oliver Wong - 29 Jun 2006 22:22 GMT
>> This is probably an offputtingly trivial question to someone who isn't
>> as new to JAI as I am. I have a servlet that, depending on some
[quoted text clipped - 39 lines]
> bi.setRGB(0,0,w, h, rgb, 0, w);
> }
The JPG file format doesn't support an alpha channel. If the intent is
just to dim the picture, I'd get the RGB values, and then multiply them by a
constant (less than 1) and write them back. For example, divide every value
in half.
- Oliver
Andrey Kuznetsov - 30 Jun 2006 14:19 GMT
> The JPG file format doesn't support an alpha channel. If the intent is
> just to dim the picture, I'd get the RGB values, and then multiply them by
> a constant (less than 1) and write them back. For example, divide every
> value in half.
I just told how to change alpha.
That jpeg does not support alpha channes is clear.
I should read things with more attention ;-)
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities