I am writing aplha composite test app based on this example
/* Create an ARGB BufferedImage */
   BufferedImage img = (BufferedImage)image;//ImageIO.read(imageSrc);
   int w = img.getWidth(null);
   int h = img.getHeight(null);
   BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR_PRE);
   Graphics g = bi.getGraphics();
   g.drawImage(img, 0, 0, null);
   /* Create a rescale filter op that makes the image 50% opaque */
   float[] scales = { 1f, 1f, 1f, 1f };
   float[] offsets = new float[4];
   RescaleOp rop = new RescaleOp(scales, offsets, null);
   /* Draw the image, applying the filter */
   g2d.drawImage(bi, rop, 0, 0);
source link: http://download.oracle.com/javase/tutorial/2d/images/drawimage.html
It works fine with simple images but with photos (jpg etc) I get this exception like:
java.lang.IllegalArgumentException: Number of scaling constants does not equal the number of of color or color/alpha components
To be more clear... Here is my adapted test code class. This code style throws the exception...
public class ImageTest extends JLabel {
    public Image image;
    private BufferedImage bImage;
    ImageObserver imageObserver;
    float[] scales = {1f, 1f, 1f, 1f};
    float[] offsets = new float[4];
    RescaleOp rop;
    int width;
    int height;
    public ImageTest(ImageIcon icon) {
        width = icon.getIconWidth();
        height = icon.getIconHeight();
        this.image = icon.getImage();
        this.imageObserver = icon.getImageObserver();
        //this.bImage=(BufferedImage)image; //previous version (makes exception?)...
        this.bImage = new BufferedImage(
            width, height, BufferedImage.TYPE_INT_ARGB);
        this.bImage.createGraphics().drawImage(
            this.image, 0, 0, width, height, imageObserver);
        rop = new RescaleOp(scales, offsets, null);
        this.repaint();
    }
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g;
        g2d.drawImage(this.bImage, rop, 0, 0);
    }
    public void setRescaleOp(RescaleOp rop) {
        this.rop = rop;
    }
}//class end
I am not pretty sure where the exception comes from so I need your advice where to look at?
P.S. I suppose it is the IndexColorModel problem but if so I am not sure how to fix it...
Any useful comment is appreciated :)
Andrew
 
    
 
    