Skip to main content

BufferedImage or PlanarImage data type format

3 replies [Last post]
sportinguista
Offline
Joined: 2010-05-30

Hi,

I need to change my PlanarImage data type to "double". I have tryed with JAI.create "format" operator, but it returns a new PlanarImage without SampleModel and ColorModel. So when I make getAsBufferedImage() gives me error.

If I call

myBufferedImage = myPlanarImage.getAsBufferedImage()

and then

myBufferedImage.getRaster().setPixel( w, h, doubleArrayValues)

it rounds my new double values to int.

How can I make this transformation?

Thank you very much, I´m getting desperate :(

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
qedisk
Offline
Joined: 2011-07-07

> Thank you very much, I´m getting desperate :(

It is no wonder that you are going desperate with JAI. JAI is programmed by scientific idiots to make life of people harder. JAI should have had a title "for spending excruciating amount of time on figuring out how this bullshit works". Or another: "Too much work with too little results." As scientific bullshit usually is, unless it is communicated by some very smart person who actually can explain it's functionality. A thing widely unseed. Vary JAI.

imagero
Offline
Joined: 2003-11-18

charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Mailer: Microsoft Office Outlook 12.0
thread-index: AcxBOFskG1IAHhIAQa60ua9FMYNLiQAjUSjQ
Content-Language: de

You don't need JAI for that:

ColorSpace cs =3D ColorSpace.getInstance(ColorSpace.CS_sRGB);
ComponentColorModel cm =3D new ComponentColorModel(cs, false, false, =
Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
WritableRaster raster =3D cm.createCompatibleWritableRaster(200, 200);
BufferedImage bi =3D new BufferedImage(cm, raster, false, null);

Andrey

sportinguista
Offline
Joined: 2010-05-30

How about?

ParameterBlock pbConvert = new ParameterBlock();
pbConvert.addSource(myPlanarImage);
pbConvert.add(DataBuffer.TYPE_FLOAT);
newPlanarImage = JAI.create("format", pbConvert, null);

WritableRaster raster = newPlanarImage.getData();

I can fill this raster with float values, but when I want to wrap it into a bufferedImage, always gives me error with the colormodel.

Any hints? Thank you!