1

ローカルレポートを画像形式で保存しようとしています。しかし、DeviceInfoColorDepth設定が機能しないことがわかりました。

 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();

値に関係なく、結果は=24の.tiffColorDepthファイルになります。ColorDepth

誰かがこのバグを修正する方法を知っていますか?

このバイトを別のバイトに変換します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);

しかし、それが良い決断かどうかはわかりません。

4

1 に答える 1

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はSQLServerReporting Servicesのクライアント側での使用にすぎないため、同じ制限があります。

ColorDepthはTIFFイメージでのみサポートされていると言われているのは少し不思議ですが、次の文では、現在のバージョンでは設定が無視され、SQLServer2005以降は無視されていると述べています。

于 2012-08-06T09:49:50.907 に答える