net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Unable to get value for field 'Attr1_icon' of class 'java.awt.Image'
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:482)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:457)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:347)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.JRException: Unable to get value for field 'Attr1_icon' of class 'java.awt.Image'
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:319)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1356)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1257)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1233)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1577)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:73)
at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:167)
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:309)
Caused by: net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:73)
at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:167)
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:309)
public Image readImage(byte[] bytes) throws JRException {
InputStream bais = new ByteArrayInputStream(bytes);
Image image = null;
try {
image = ImageIO.read(bais);
} catch (Exception e) {
throw new JRException(e);
} finally {
try {
bais.close();
} catch (IOException e) {
}
}
if (image == null) {
throw new JRException("Image read failed."); // Line 73
}
return image;
}
Returns a BufferedImage as the result of decoding a supplied InputStream with an
ImageReader chosen automatically from among those currently registered. The InputStream
is wrapped in an ImageInputStream. If no registered ImageReader claims to be able to
read the resulting stream, null is returned.
所以我猜没有注册的ImageReader?我怎么能通过Jaspersoft Studio修复这样的东西?
编辑:我尝试使用java.io.InputStream作为这里建议的类类型,但结果是相同的错误。算是吧。一个很大的区别是,在Jaspersoft Studio中,如果出现错误,您可以将图像设置为显示为空白。如果我使用java.awt.Image,那么这个设置什么也不做。我仍然得到一个错误,报告不能建立。如果我使用java.io.InputStream,报告确实会生成,但是图像是空白的。如果打开错误报告,我会得到类似的堆栈跟踪,但并不完全相同:
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.export.draw.PrintDrawVisitor.visit(PrintDrawVisitor.java:143)
at net.sf.jasperreports.engine.export.draw.PrintDrawVisitor.visit(PrintDrawVisitor.java:1)
at net.sf.jasperreports.engine.fill.JRTemplatePrintImage.accept(JRTemplatePrintImage.java:451)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:251)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:199)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportPage(JRGraphics2DExporter.java:273)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReportToGraphics2D(JRGraphics2DExporter.java:246)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReport(JRGraphics2DExporter.java:184)
at net.sf.jasperreports.eclipse.viewer.ViewerCanvas.renderPage(ViewerCanvas.java:369)
at net.sf.jasperreports.eclipse.viewer.ViewerCanvas.refresh(ViewerCanvas.java:344)
at net.sf.jasperreports.eclipse.viewer.ViewerCanvas$2.viewerStateChanged(ViewerCanvas.java:118)
at net.sf.jasperreports.eclipse.viewer.ReportViewer.fireViewerModelChanged(ReportViewer.java:383)
at net.sf.jasperreports.eclipse.viewer.ReportViewer.setPageIndex(ReportViewer.java:297)
at com.jaspersoft.studio.editor.preview.view.report.swt.SWTViewer.setJRPRint(SWTViewer.java:125)
at com.jaspersoft.studio.editor.preview.view.report.swt.SWTViewer.setJRPRint(SWTViewer.java:112)
at com.jaspersoft.studio.editor.preview.PreviewJRPrint.switchRightView(PreviewJRPrint.java:226)
at com.jaspersoft.studio.editor.preview.PreviewContainer.switchRightView(PreviewContainer.java:247)
at com.jaspersoft.studio.editor.preview.PreviewJRPrint$3.switchView(PreviewJRPrint.java:194)
at com.jaspersoft.studio.editor.preview.PreviewJRPrint$1.run(PreviewJRPrint.java:153)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.jaspersoft.studio.rcp.intro.Application.start(Application.java:97)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:73)
at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:167)
at net.sf.jasperreports.engine.JRImageRenderer.getImage(JRImageRenderer.java:407)
at net.sf.jasperreports.engine.JRImageRenderer.getDimension(JRImageRenderer.java:482)
at net.sf.jasperreports.engine.RenderableUtil.getOnErrorRendererForDimension(RenderableUtil.java:264)
at net.sf.jasperreports.engine.export.draw.ImageDrawer.draw(ImageDrawer.java:116)
at net.sf.jasperreports.engine.export.draw.PrintDrawVisitor.visit(PrintDrawVisitor.java:134)
但是,正如您所看到的,根本原因仍然来自JRJDK14ImageReader.java第73行。
同样,对于我尝试的表达式javax.imageio.imageio.read($F{Attr1_icon}),这实际上不会产生任何错误,但图像是空白的。
尽管我在本期文章中发布了它,但我完全忽略了这样一个事实,即图像是Base64编码的,这意味着它是一个字符串。因此,Jasper不能使用该值,因此必须对其进行解码。这可以通过以下两种方法之一实现:
将表达式更改为:
new java.io.ByteArrayInputStream(javax.xml.DatatypeConverter.parseBase64Binary($F{ImageField}))
或者简单地将字符串转换为数据库中的二进制。在Sybase中,这是base64_decode函数。一旦它被转换,您只需将类型更改为java.io.InputStream,它就可以工作了。
问题内容: 我有一堆图像,格式类似于Cifar10(二进制文件,每个图像字节),一个接一个(STL-10数据集)。我打开的文件有138MB。 我试图阅读并检查包含图像的张量的内容,以确保阅读正确,但是我有两个问题- 是否加载整个文件,但是一次只提供一个输入?由于读取第一个字节应该相对较快。但是,该代码大约需要两分钟才能运行。 如何获得可显示格式的实际图像内容,或在内部显示它们以验证图像是否被正确阅
但是宽度和高度较低的图像成功地加载到图像视图中! 有人能告诉我代码有什么问题吗?我做错了什么?我只想从库中导入相机图像,并在图像视图中显示它们!
问题内容: 我想从s3获取图像并将其显示在HTML页面上。 Angular HTML文件: Angular Controller文件: 我找到了一个叫做 FileReader的 东西并尝试了这个: 但是它显示错误: Uncaught TypeError:无法在’FileReader’上执行’readAsDataURL’:参数1的类型不是’Blob’。 请使用代码帮助我在img标签中显示图像文件 我
现在,我们知道如何绘制图像和视频,让我们尝试去访问图像的数据,看看什么类型的属性我们可以操作。 图3-6 获取图像数据 警告:由于getImageData()方法的安全限制,本节的例子必须在Web服务器上运行。 准备工作 在开始处理图像数据之前,很重要是要了解一下画布的安全和RGBA颜色空间。 那么,在访问图像数据方面,为什么画布安全很重要?简言之,为了访问图像数据,需要使用画布上下文对象的get
这里我们使用工具为Python2.7,使用库numpy,opencv,从图片的导入到显示及保存,同时将图片变为灰度图 1、读入图像 cv2.imread(文件名,标记) 第一个参数图像应该在工作目录中,或者应该给出完整的图像路径。 第二个参数是一个标志,指定应读取图像的方式。 cv2.IMREAD_COLOR:加载彩色图像。任何形象的透明度将被忽略。这是默认的标志。 cv2.IMREAD_GRAY
我目前正在编写一个应用程序来读取TIFF文件,然后执行一些压缩算法。我已经成功地做到了这一点...但是现在,我想读取TIFF图像的元数据,但似乎找不到正确的方法。 我应该使用什么库和函数?