LEADTOOLS ナレッジベース

1ビットの白黒画像がきれいに表示されない

エディション

Proファミリー

 

コンポーネントの種類

Windows Forms/WPF

 

コントロール

ImageViewer

 

詳細

Proファミリー製品で1ビット画像を拡大・縮小表示した際に画質が低下するのは、1ビット画像のグレースケール表示機能(RasterPaintDisplayModeFlags列挙体のScaleToGray)が無効になっているためです。
RasterPaintDisplayModeFlags列挙体のScaleToGrayはDocument以上の製品でのみでサポートされている機能のため、Proファミリー製品では使用できません。

Proファミリー製品で画質の低下を抑えるには、ColorResolutionCommandクラスを使用して1ビット画像を2ビット画像に変換し、Leadtools.Drawing.RasterPaintPropertiesのPaintDisplayModeプロパティにResampleもしくはBicubicを設定する方法があります。

サンプルコード(VB.NET)

' 1ビット画像を2ビット画像に変換します。
Dim command As New Leadtools.ImageProcessing.ColorResolutionCommand()
command.BitsPerPixel = 2
command.Run(ImageViewer1.Image)

' 描画プロパティを設定します。
Dim properties As New Leadtools.Drawing.RasterPaintProperties()
properties = Leadtools.Drawing.RasterPaintProperties.Default
properties.PaintDisplayMode = Leadtools.Drawing.RasterPaintDisplayModeFlags.Bicubic
ImageViewer1.PaintProperties = properties

サンプルコード(C#)

// 1ビット画像を2ビット画像に変換します。
Leadtools.ImageProcessing.ColorResolutionCommand command = new Leadtools.ImageProcessing.ColorResolutionCommand();
command.BitsPerPixel = 2;
command.Run(imageViewer1.Image);

// 描画プロパティを設定します。
Leadtools.Drawing.RasterPaintProperties properties = new Leadtools.Drawing.RasterPaintProperties();
properties = Leadtools.Drawing.RasterPaintProperties.Default;
properties.PaintDisplayMode = Leadtools.Drawing.RasterPaintDisplayModeFlags.Bicubic;
imageViewer1.PaintProperties = properties;

1ビット画像のビット数を2ビットに増やしていることや、描画プロパティの設定でResample/Bicubicなど高品質での表示となるため、デフォルト(None)の表示の場合やScaleToGrayを使用した場合と比べてレスポンスは遅くなります。あらかじめご了承ください。

 

下記の.NETコントロール チュートリアルについてもご参照ください。

  • 画像処理 > DisplayGrayScale

 

関連情報

この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています

0 コメント

記事コメントは受け付けていません。