在JasperReports中的Blob图像中旋转90º [英] Rotating 90º In a Blob Image in JasperReports

查看:178
本文介绍了在JasperReports中的Blob图像中旋转90º的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个小的jrxml:

So I have a small jrxml with this:

两个图像属于firebird数据库中的字段类型BLOB并正确显示我正在使用新的ByteArrayInputStream((byte [])$ F { FOFU})关于图像表达式。

The two images are of the field type BLOB in a firebird database and to show it correctly I'm using new ByteArrayInputStream((byte[])$F{FOFU}) on the image expression.

读了一下之后,我认为旋转这个图像的唯一方法是在java上以编程方式进行,我不知道如何即使在这里和其他地方阅读了一些帖子之后也做到了。任何人都可以帮我吗?

After reading a bit I figured the only way to rotate this image is to do it programmatically on java and I have no idea how to do, even after reading some posts here and other places. Can anyone help me with this ?

推荐答案

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

and on the Jasper I'm doing

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

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

as the image expression. Its working.

这篇关于在JasperReports中的Blob图像中旋转90º的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆