Skip to main content

problem with writableraster and renderedOp

1 reply [Last post]
mslozano
Offline
Joined: 2009-11-16

I want to write pixels on a RenderedOp image taking the color where I make click , I do this:

BufferedImage biImage = _finalImage.getAsBufferedImage();
int R = biImage.getColorModel().getRGBdefault().getRed(biImage.getRGB(x,y));
int G = biImage.getColorModel().getRGBdefault().getGreen(biImage.getRGB(x,y));
int B = biImage.getColorModel().getRGBdefault().getBlue(biImage.getRGB(x,y));
Color color = new Color(R, G, B);

for ( int i = 0; i < 3*a*l; i=i+3 ){
rgb i = color.getRed();
rgb i+1 = color.getGreen();
rgb i+2= color.getBlue();
}
WritableRaster raster = biImage.getRaster();
raster.setPixels(x1Coord, y1Coord, a, l, rgb);
biImage.setData(raster);
PlanarImage pl = PlanarImage.wrapRenderedImage(biImage);

pb = new ParameterBlock();
pb.addSource(pl);
pb.add((float)1.0f);
pb.add((float)1.0f);
image = JAI.create("scale", pb);
display.setImage(image);
this.pnlImagen.setViewportView(display);
this.pnlImagen.revalidate();
this.pnlImagen.repaint();

I have un bufferedImage and I need to set on a RenderedOp image, because I am
setting it on a PlanarImage

but I get problems because I am working with a chain of operators
for other operations as a bright or zoom for example:

_zoomPB.setParameter("xScale",(float) zoom);
_zoomPB.setParameter("yScale", (float)zoom);
_zoomImage.setParameterBlock(_zoomPB);

Then I can't synchronize these operations, each operation work on a diferent image, I try add a source of a type
RenderedOp and I get goods results, then I think that the problem is in to set the bufferedImage on the RenderedOp image
and not on a planarImage but I don't know how do this.

Message was edited by: mslozano

Message was edited by: mslozano

Message was edited by: mslozano

Message was edited by: mslozano

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Rafael Santos

mslozano,

Just some suggestions:

> I want to write pixels on a RenderedOp image taking the color where I make click , I do this:
>
> BufferedImage biImage = _finalImage.getAsBufferedImage();
> int R = biImage.getColorModel().getRGBdefault().getRed(biImage.getRGB(x,y));
> int G = biImage.getColorModel().getRGBdefault().getGreen(biImage.getRGB(x,y));
> int B = biImage.getColorModel().getRGBdefault().getBlue(biImage.getRGB(x,y));
> Color color = new Color(R, G, B);
>
Why not Color color = new Color(biImage.getRGB(x,y))?

> for ( int i = 0; i < 3*a*l; i=i+3 ){
> rgb[i] = color.getRed();
> rgb[i+1] = color.getGreen();
> rgb[i+2]= color.getBlue();
> }
> WritableRaster raster = biImage.getRaster();
> raster.setPixels(x1Coord, y1Coord, a, l, rgb);
> biImage.setData(raster);
> PlanarImage pl = PlanarImage.wrapRenderedImage(biImage);
>
This is a little bit confusing -- you start with _finalImage which I
guess is a PlanarImage and wants to get it into pl which is another
PlanarImage? The code section does not tell us whether you're copying or
composing an image.

> pb = new ParameterBlock();
> pb.addSource(pl);
> pb.add((float)1.0f);
> pb.add((float)1.0f);
> image = JAI.create("scale", pb);
> display.setImage(image);
> this.pnlImagen.setViewportView(display);
> this.pnlImagen.revalidate();
> this.pnlImagen.repaint();
>
> I have un bufferedImage and I need to set on a RenderedOp image, because I am
> setting it on a PlanarImage
>
Is "set" "represent as" or "set as a region of"?

Anyway just from the code I can see you're mixing pixel processing with
JAI operators with display -- what do you want your code to do?
>
> but I get problems because I am working with a chain of operators
> for other operations as a bright or zoom for example:
>
> _zoomPB.setParameter("xScale",(float) zoom);
> _zoomPB.setParameter("yScale", (float)zoom);
> _zoomImage.setParameterBlock(_zoomPB);
>
> Then I can't synchronize these operations, each operation work on a diferent image, I try add a source of a type
> RenderedOp and I get goods results, then I think that the problem is in to set the bufferedImage on the RenderedOp image
> and not on a planarImage but I don't know how do this.
>
Just to be sure, explain "synchronize" (it has a very specific meaning
in Java) -- which is the (full) image operation chain you want to do?

Rafael -- need coffee

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net