/******************************************************************************************************************* * * FIXME: profile conversion should be moved to EditableImageRenderer, but the problem is how to get the screen * profile. * ******************************************************************************************************************/ @Nonnull private EditableImage profileConverted (final @Nonnull EditableImage image) { // final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); // final GraphicsDevice device = environment.getScreenDevices()[0]; // final GraphicsConfiguration configuration = device.getDefaultConfiguration(); // final ICC_ColorSpace colorSpace = (ICC_ColorSpace)configuration.getColorModel().getColorSpace(); // // System.err.println("DEVICE PROFILE " + ImageUtils.getICCProfileName(colorSpace.getProfile())); return image.execute2(new ConvertColorProfileOp(deviceProfile)); //// return image.execute2(new ConvertColorProfileOp(loadProfile())).execute2(new AssignColorProfileOp(ICC_Profile.getInstance(ColorSpace.CS_sRGB))); //// return image.execute2(new ConvertColorProfileOp(loadProfile())).execute2(new AssignColorProfileOp(colorSpace.getProfile())); //// return image.execute2(new ConvertColorProfileOp(colorSpace.getProfile())); } }
@Nonnull @Override protected PlanarImage execute (final @Nonnull ConvertColorProfileOp operation, final @Nonnull EditableImage image, final @Nonnull PlanarImage planarImage) { log.info("execute({}) - {} ", operation, planarImage.getSampleModel()); if (operation.getRenderingIntent() != PERCEPTUAL) { throw new IllegalArgumentException("Can only use PERCEPTUAL intent, was " + operation.getRenderingIntent()); } final ICC_Profile iccProfile = operation.getIccProfile(); final RenderingHints hints = new RenderingHints(Collections.<RenderingHints.Key, Object>emptyMap()); hints.put(KEY_COLOR_RENDERING, VALUE_COLOR_RENDER_QUALITY); final PlanarImage result = ColorConvertDescriptor.create(planarImage, JAIUtils.getColorModel(planarImage, iccProfile), hints); JAIUtils.logImage(log, ">>>> returning", planarImage); return result; } }