if (null == images || images.isEmpty()) {
return null;
}
try {
final Image firstImage = images.get(0);
BufferedImage tmp = ImageIO.read(new ByteArrayInputStream(firstImage.getData()));
for (int i = 1; i < images.size(); i++) {
final Image image = images.get(i);
final byte[] data = image.getData();
final BufferedImage awtImage = ImageIO.read(new ByteArrayInputStream(data));
tmp = splice(tmp, awtImage);
}
final Image ret = new Image();
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageIO.write(tmp, "PNG", byteArrayOutputStream);
final byte[] data = byteArrayOutputStream.toByteArray();
ret.setData(data);
return ret;
} catch (final IOException e) {
throw new RuntimeException(e);
}