在JasperReports中的Blob图像中旋转90º

雨果

所以我有一个小的jrxml:

图片

这两个图像在firebird数据库中的字段类型为BLOB,为了正确显示它,我在图像表达式上使用了新的ByteArrayInputStream((byte [])$ F {FOFU})。

看了一点之后,我发现旋转此图像的唯一方法是在Java上以编程方式进行操作,即使在这里和其他地方阅读了一些帖子之后,我也不知道该怎么做。谁能帮我这个 ?

雨果
private byte[] rotateImage(byte[] originalImageAsBytes , double radians) throws InternalException {
ByteArrayOutputStream rotatedImageStream = null;

try {
  BufferedImage originalImage = ImageIO.read(new ByteArrayInputStream(originalImageAsBytes)); // read the original image
  AffineTransform rotationTransform = new AffineTransform();
  rotationTransform.rotate(radians, originalImage.getWidth() / 2.0 , originalImage.getHeight() / 2.0);
  AffineTransformOp rotationTransformOp = 
    new AffineTransformOp(rotationTransform , AffineTransformOp.TYPE_NEAREST_NEIGHBOR); 
  BufferedImage rotatedImage = rotationTransformOp.filter(originalImage,null); 

  rotatedImageStream = new ByteArrayOutputStream();
  ImageIO.write(rotatedImage, "jpg" , rotatedImageStream); 
} catch (IOException e) {
  throw new InternalException(e);
}
return rotatedImageStream.toByteArray();
}

在贾斯珀(Jasper)上,我在做

new ByteArrayInputStream(path.to.rotateImage((byte[])$F{IMAGE}, 100.00))

作为图像表达。它的工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章