2012-08-06 55 views
1

我尝试以图像格式保存本地报告。但我发现DeviceInfoColorDepth设置不起作用。DeviceInfo ColorDepth设置不起作用

string mime, encoding, fileNameExtension; 
string[] streams; 
Warning[] warnings; 
byte[] bytes = report.Render("IMAGE", @"<DeviceInfo><OutputFormat>TIFF</OutputFormat><ColorDepth>8</ColorDepth><StartPage>0</StartPage></DeviceInfo>", out mime, out encoding, out fileNameExtension, out streams, out warnings); 

FileStream fs = new FileStream("C:\\imgRep.tiff", FileMode.OpenOrCreate); 
fs.Write(bytes, 0, bytes.Length); 
fs.Close(); 

的独立ColorDepth值,结果是ColorDepth .TIFF文件= 24

有谁知道如何解决这个bug?

我转换这个字节到另一个PixelFormat

Bitmap orig = new Bitmap(new MemoryStream(bytes)); 
Bitmap clone = orig.Clone(new Rectangle(0, 0, orig.Width, orig.Height), PixelFormat.Format8bppIndexed); 
clone.Save(@"c:\imgPixelF.tiff", ImageFormat.Tiff); 

但我不知道这是一个很好的决定..

回答

2

SQL Server Books Online您从报告中呈现TIFF图像将始终保存作为当前版本的24位。

For this release of SQL Server, the value of this setting is ignored, and the TIFF image is always rendered as 24-bit.

由于的ReportViewer/LocalReport只是一个客户方使用的SQL Server Reporting Services的你会被相同的限制束缚在那里。

虽然他们认为ColorDepth仅支持TIFF图像,但在下一句中他们表示该设置在当前版本中被忽略,并且自SQL Server 2005以来一直如此。

+0

感谢您的帮助! – Chepene 2012-08-06 09:58:57