在SSRS报告中显示Tiff文件
-
02-07-2019 - |
题
我要求能够将扫描的tiff图像嵌入到某些SSRS报告中。
当我在VS2005中设计报告并添加图像控件时,tiff图像会完美显示,但是当我构建它时。我收到警告:
警告2 [rsInvalidMIMEType]图像的MIMEType属性的值‘ image1’是“ image / tiff”,这不是有效的MIMEType。 c:\ SSRSStuff \ TestReport.rdl 0 0
而不是图像,我得到的是小红色。
有人克服了这个问题吗?
解决方案
假设您通过IIS提供图像文件,请使用ASP.NET页面将图像格式和mime类型更改为可以使用的内容。
Response.ContentType = "image/png";
Response.Clear();
using (Bitmap bmp = new Bitmap(tifFilepath))
bmp.Save(Response.OutputStream, ImageFormat.Png);
Response.End();
其他提示
我一直在寻找如何在SSRS报告中显示TIFF图像的解决方案,但我找不到任何因为SSRS不支持TIFF,我认为将TIFF转换为支持格式之一就可以了。它确实如此。我不知道是否有像这样的类似实现,但我只是发布,所以其他人也可以受益。 请注意,这仅适用于您在数据库中保存TIFF图像的情况。
Public Shared Function ToImage(ByVal imageBytes As Byte()) As Byte()
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(imageBytes)
Dim os As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(ms)
img.Save(os, System.Drawing.Imaging.ImageFormat.Jpeg)
Return os.ToArray()
End Function
这里’ s如何使用代码: 1.在Report Properties,Select Refereneces中,单击Add并浏览System.Drawing,Version = 2.0.0.0 2.选择代码属性,复制粘贴上面的功能 3.单击“确定” 4.从工具箱中删除图像控件 4.1。右键单击图像,然后选择“图像属性” 4.2。将图像源设置为数据库 4.3。在“使用此字段”中,单击表达式并粘贴下面的代码 = Code.ToImage(领域!FormImage.Value)点击 4.4。将适当的Mime设置为Jpeg
此致 Fulbert
感谢 Peter ,您的代码无法编译,但这个想法很合理。
这是我的尝试对我有用。
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
Response.Clear();
Bitmap bmp = new Bitmap(tifFileLocation);
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
}