This discussion is archived
3 Replies Latest reply: Sep 12, 2010 6:37 AM by 843802 RSS

Add two image ERROR!

843802 Newbie
Currently Being Moderated
Hi! i have some problem with this code:
     public BufferedImage combineYUV2(BufferedImage ydctmark, BufferedImage bi) {
          // Read the two images.
          ParameterBlock pb = new ParameterBlock();
          pb.addSource(ydctmark);
          RenderedImage src1 = (RenderedImage)JAI.create("stream", pb);
          pb = new ParameterBlock();
          pb.addSource(bi);
          RenderedImage src2 = (RenderedImage)JAI.create("stream", pb);
          // Create the ParameterBlock for the operation
          pb = new ParameterBlock();
          pb.addSource(src1);
          pb.addSource(src2);
          // Create the Add operation.
          RenderedImage dst = (RenderedImage)JAI.create("add", pb);

          int w=bi.getWidth();
          int h = bi.getHeight();
          int[] img = new int[w*h]; 
          dst.getData().getPixels(0, 0, w, h, img);
          BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_CUSTOM);
          WritableRaster raster = image.getRaster();
          raster.setPixels(0, 0, w, h, img);
          image.setData(raster);
          return image;

     }
and i don't understand why.

the error is : " Exception in thread "main" java.lang.IllegalArgumentException: operation "Stream" requires 2 parameter object(s).
     at javax.media.jai.JAI.createNS(JAI.java:1091)
     at javax.media.jai.JAI.create(JAI.java:977)
     at javax.media.jai.JAI.create(JAI.java:1399)" ext...

can some one help me?

to create this method i read this