我要求能够将扫描的tiff图像嵌入到某些SSRS报告中。
当我在VS2005中设计报告并添加图像控件时,tiff图像会完美显示,但是当我构建它时。我收到警告:
Warning 2 [rsInvalidMIMEType] The value of the MIMEType property for the image ‘image1’ is “image/tiff”, which is not a valid MIMEType. c:\SSRSStuff\TestReport.rdl 0 0
而不是图像,我得到的是小红色。
有人克服了这个问题吗?
答案 0 :(得分:3)
假设您通过IIS提供图像文件,请使用ASP.NET页面将图像格式和mime类型更改为可以使用的内容。
Response.ContentType = "image/png";
Response.Clear();
using (Bitmap bmp = new Bitmap(tifFilepath))
bmp.Save(Response.OutputStream, ImageFormat.Png);
Response.End();
答案 1 :(得分:1)
我一直在寻找如何在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
以下是如何使用代码:
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
答案 2 :(得分:0)
感谢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();
}