[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: [OpenJDK 2D-Dev] Writing a CMYK file
From: roxton () gmail ! com (Adam Augusta)
Date: 2008-06-17 16:27:19
Message-ID: 65ef85890806170927u4a309503g14c44600bb46898 () mail ! gmail ! com
[Download RAW message or body]
I just wanted to share my prototyped solution to this. The answer was
staring me in the face, but it may prove useful to someone else.
final DataBufferByte buffer = new DataBufferByte(myCmykByteArray,
myCmykByteArray.length);
final WritableRaster raster = Raster.createInterleavedRaster(buffer,
imageWidth, imageHeight, imageWidth*4, 4, new int[] {0, 1, 2, 3}, new
Point(0,0));
final ICC_Profile profileCmyk;
try {
profileCmyk = ICC_Profile.getInstance("c:\\myprofile.icc");
} catch (IOException e) {
...
}
final ICC_ColorSpace colorSpaceCmyk = new ICC_ColorSpace(profileCmyk);
final ColorModel model = new ComponentColorModel(colorSpaceCmyk, new
int[] {8,8,8,8}, false, false, ColorModel.OPAQUE,
DataBuffer.TYPE_BYTE);
BufferedImage bufferedImage = new BufferedImage(model, raster, false, null);
final File output = new File("c:\\fileoutput.tif");
final FileImageOutputStream outputStream;
try {
outputStream = new FileImageOutputStream(output);
} catch (IOException e) {
...
}
final ImageWriter writer =
ImageIO.getImageWritersByMIMEType("image/tiff").next();
writer.setOutput(outputStream);
try {
writer.write(bufferedImage);
} catch (IOException e) {
throw new RuntimeException("Oh noes", e);
}
-Adam
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic