int w = pixels.getWidth();
int h = pixels.getHeight();
Array2<CIEXYZ> hdrTile = hdrImage.slice(x, y, w, h);
for (int ry = 0; ry < h; ry++) {
for (int rx = 0; rx < w; rx++) {
CIEXYZ xyz = pixels.getPixel(rx, ry).toXYZ();
hdrTile.set(rx, ry, xyz);
}
}
if (!prepareToneMapper(hdrTile.size())) {
BufferedImage ldrTile = ldrImage.getSubimage(x, y, w, h);
for (int ry = 0; ry < h; ry++) {
for (int rx = 0; rx < w; rx++) {
CIEXYZ xyz = hdrTile.get(rx, ry);
int rgb = toneMapper.apply(xyz).toRGB().toR8G8B8();
ldrTile.setRGB(rx, ry, rgb);
}
}
super.repaint(x, y, w, h);