LEADTOOLS画像処理(Leadtools.ImageProcessing.Coreアセンブリ)

フレームを表示

HighQualityRotateCommandクラス








メンバ 
白黒のimageの上で高品質回転を実行します。
オブジェクトモデル
構文
'Declaration
 
Public Class HighQualityRotateCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements Leadtools.ImageProcessing.IRasterCommand 
'Usage
 
Dim instance As HighQualityRotateCommand
public sealed class HighQualityRotateCommand : Leadtools.ImageProcessing.IRasterCommand  
@interface LTHighQualityRotateCommand : LTRasterCommand
public class HighQualityRotateCommand extends RasterCommand
function Leadtools.ImageProcessing.Core.HighQualityRotateCommand()
public ref class HighQualityRotateCommand : public Leadtools.ImageProcessing.RasterCommand, Leadtools.ImageProcessing.IRasterCommand  
解説

HighQualityRotateCommandは、任意の角度で黒と白い(1ビット/ピクセル)イメージに関して高品質回転を実行するのに用いられることができます。

RotateCommandなどの通常の回転コマンドは、画像データを現状のまま回転します。この結果、画像のビット数が限定される(1ビット)ため、任意の品質より低くなります。このコマンドは、一時的に内部的に8ビット/ピクセルにimageを変換して、回転を実行して、それから、1ビット/ピクセルへimageを変換します。

このコマンドは、1ビット/ピクセルイメージ(RasterImage.BitsPerPixel同等が1へにあるRasterImage)で機能するだけです。他のどのimageの上のこのコマンドを用いても、型は例外に終わります。

このコマンドは、符合付きデータイメージをサポートしません。

詳細については、「1ビット画像のクリーンアップ」を参照してください。

LEADTOOLSのSilverlightバージョンにおいて、RasterImageオブジェクトのための画像データがSilverlight WriteableBitmapを用いて内部的に保存されるならば、この画像処理コマンドは失敗しますオブジェクト。詳細については、「Silverlightの画像処理コマンド限界」を参照してください。

サンプル

このサンプルは、1ビット/ピクセルイメージに関して実行されるとき、正転(RotateCommand)と高品質回転(HighQualityRotateCommand)の違いを示します。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing

   
Public Sub HighQualityRotateCommandExample()
   Dim codecs As New RasterCodecs()
   ' Get an image
   Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif")
   Dim normalRotateFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_NormalRotated.tif")
   Dim highQualityRotateFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_HighQualityRotated.tif")

   Dim angle As Integer = 30 * 100
   Dim fillColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.White)

   ' Load the image, rotate normally by 30 degrees and save
   Using image As RasterImage = codecs.Load(tifFileName)
      Dim cmd As New RotateCommand()
      cmd.Angle = angle
      cmd.Flags = RotateCommandFlags.Resize Or RotateCommandFlags.Bicubic
      cmd.FillColor = fillColor
      cmd.Run(image)
      codecs.Save(image, normalRotateFileName, image.OriginalFormat, image.BitsPerPixel)
   End Using

   ' Load the image, rotate with high quality by 30 degrees and save
   Using image As RasterImage = codecs.Load(tifFileName)
      Dim cmd As New HighQualityRotateCommand()
      cmd.Angle = angle
      cmd.Flags = HighQualityRotateCommandFlags.Resize Or HighQualityRotateCommandFlags.BestQuality
      cmd.FillColor = fillColor
      cmd.Run(image)
      codecs.Save(image, highQualityRotateFileName, image.OriginalFormat, image.BitsPerPixel)
   End Using

   ' Now compare the saved TIF files and notice the difference in quality between
   ' the normal rotate and high quality

   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;

      
public void HighQualityRotateCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // Get an image
   string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif");
   string normalRotateFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_NormalRotated.tif");
   string highQualityRotateFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_HighQualityRotated.tif");

   int angle = 30 * 100;
   RasterColor fillColor = RasterColor.FromKnownColor(RasterKnownColor.White);

   // Load the image, rotate normally by 30 degrees and save
   using(RasterImage image = codecs.Load(tifFileName))
   {
      RotateCommand cmd = new RotateCommand();
      cmd.Angle = angle;
      cmd.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic;
      cmd.FillColor = fillColor;
      cmd.Run(image);
      codecs.Save(image, normalRotateFileName, image.OriginalFormat, image.BitsPerPixel);
   }


   // Load the image, rotate with high quality by 30 degrees and save
   using(RasterImage image = codecs.Load(tifFileName))
   {
      HighQualityRotateCommand cmd = new HighQualityRotateCommand();
      cmd.Angle = angle;
      cmd.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality;
      cmd.FillColor = fillColor;
      cmd.Run(image);
      codecs.Save(image, highQualityRotateFileName, image.OriginalFormat, image.BitsPerPixel);
   }

   // Now compare the saved TIF files and notice the difference in quality between
   // the normal rotate and high quality

   codecs.Dispose();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
function HighQualityRotateCommandExample() {
   var codecs = new Leadtools.Codecs.RasterCodecs();
   var loadedImage;

   // Get an image
   var angle = 30 * 100;
   var fillColor = Leadtools.RasterColorHelper.fromKnownColor(Leadtools.RasterKnownColor.white);

   // Load the image, rotate normally by 30 degrees and save
   var srcFileName = "Assets\\ocr1.tif";
   return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      loadedImage = image;
      // Prepare the command
      with (Leadtools.ImageProcessing) {
         var cmd = new RotateCommand();
         cmd.angle = angle;
         cmd.flags = RotateCommandFlags.resize | RotateCommandFlags.bicubic;
         cmd.fillColor = fillColor;
         cmd.run(image);
      }

      var destFileName = "ocr1_NormalRotated.tif";
      return Tools.AppLocalFolder().createFileAsync(destFileName);
   }).then(function (saveFile) {
      return codecs.saveAsync(loadedImage, Leadtools.LeadStreamFactory.create(saveFile), loadedImage.originalFormat, loadedImage.bitsPerPixel);
   }).then(function () {

      // Load the image, rotate with high quality by 30 degrees and save
      srcFileName = "Assets\\ocr1.tif";
      return Tools.AppInstallFolder().getFileAsync(srcFileName);
   }).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      loadedImage = image;
      with (Leadtools.ImageProcessing.Core) {
         var cmd = new HighQualityRotateCommand();
         cmd.angle = angle;
         cmd.flags = HighQualityRotateCommandFlags.resize | HighQualityRotateCommandFlags.bestQuality;
         cmd.fillColor = fillColor;
         cmd.run(image);
      }

      var destFileName = "ocr1_HighQualityRotated.tif";
      return Tools.AppLocalFolder().createFileAsync(destFileName);
   }).then(function (saveFile) {
      return codecs.saveAsync(loadedImage, Leadtools.LeadStreamFactory.create(saveFile), loadedImage.originalFormat, loadedImage.bitsPerPixel);
   });

   // Now compare the saved TIF files and notice the difference in quality between
   // the normal rotate and high quality
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing;

      
public async Task HighQualityRotateCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // Get an image
   int angle = 30 * 100;
   RasterColor fillColor = RasterColorHelper.FromKnownColor(RasterKnownColor.White);

   // Load the image, rotate normally by 30 degrees and save
   string srcFileName = @"Assets\ocr1.tif";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   using (RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
   {
      RotateCommand cmd = new RotateCommand();
      cmd.Angle = angle;
      cmd.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic;
      cmd.FillColor = fillColor;
      cmd.Run(image);
      string destFileName = @"ocr1_NormalRotated.tif";
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
      await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), image.OriginalFormat, image.BitsPerPixel);
   }

   // Load the image, rotate with high quality by 30 degrees and save
   srcFileName = @"Assets\ocr1.tif";
   loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   using (RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
   {
      HighQualityRotateCommand cmd = new HighQualityRotateCommand();
      cmd.Angle = angle;
      cmd.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality;
      cmd.FillColor = fillColor;
      cmd.Run(image);
      string destFileName = @"ocr1_HighQualityRotated.tif";
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
      await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), image.OriginalFormat, image.BitsPerPixel);
   }

   // Now compare the saved TIF files and notice the difference in quality between
   // the normal rotate and high quality

   codecs.Dispose();
}
using Leadtools;
using Leadtools.ImageProcessing;
using Leadtools.Examples;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;

public void HighQualityRotateCommandExample(RasterImage image1, Stream outStream1, Stream outStream2)
{
   RasterImage image2 = image1.Clone();
   RasterCodecs codecs = new RasterCodecs();
   int angle = 30 * 100;
   RasterColor fillColor = new RasterColor(255, 255, 255);

   // rotate normally by 30 degrees and save
   RotateCommand cmd1 = new RotateCommand();
   cmd1.Angle = angle;
   cmd1.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic;
   cmd1.FillColor = fillColor;
   cmd1.Run(image1);
   // save result image to "ocr1_NormalRotated.tif"
   codecs.Save(image1, outStream1, image1.OriginalFormat, image1.BitsPerPixel);

   // rotate with high quality by 30 degrees and save
   HighQualityRotateCommand cmd2 = new HighQualityRotateCommand();
   cmd2.Angle = angle;
   cmd2.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality;
   cmd2.FillColor = fillColor;
   cmd2.Run(image2);

   // save result image to "ocr1_HighQualityRotated.tif"
   codecs.Save(image2, outStream2, image2.OriginalFormat, image2.BitsPerPixel);

   // Now compare the saved TIF files and notice the difference in quality between
   // the normal rotate and high quality
   image1.Dispose();
   image2.Dispose();
}
Imports Leadtools
Imports Leadtools.ImageProcessing
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core

Public Sub HighQualityRotateCommandExample(ByVal image1 As RasterImage, ByVal outStream1 As Stream, ByVal outStream2 As Stream)
   Dim image2 As RasterImage = image1.Clone()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim angle As Integer = 30 * 100
   Dim fillColor As RasterColor = New RasterColor(255, 255, 255)

   ' rotate normally by 30 degrees and save
   Dim cmd1 As RotateCommand = New RotateCommand()
   cmd1.Angle = angle
   cmd1.Flags = RotateCommandFlags.Resize Or RotateCommandFlags.Bicubic
   cmd1.FillColor = fillColor
   cmd1.Run(image1)
   ' save result image to "ocr1_NormalRotated.tif"
   codecs.Save(image1, outStream1, image1.OriginalFormat, image1.BitsPerPixel)

   ' rotate with high quality by 30 degrees and save
   Dim cmd2 As HighQualityRotateCommand = New HighQualityRotateCommand()
   cmd2.Angle = angle
   cmd2.Flags = HighQualityRotateCommandFlags.Resize Or HighQualityRotateCommandFlags.BestQuality
   cmd2.FillColor = fillColor
   cmd2.Run(image2)

   ' save result image to "ocr1_HighQualityRotated.tif"
   codecs.Save(image2, outStream2, image2.OriginalFormat, image2.BitsPerPixel)

   ' Now compare the saved TIF files and notice the difference in quality between
   ' the normal rotate and high quality
   image1.Dispose()
   image2.Dispose()
End Sub
必要条件

ターゲットプラットホーム

参照

参照

HighQualityRotateCommandメンバ
Leadtools.ImageProcessing.Core名前空間
1ビット画像のクリーンアップ
SmoothCommandクラス
BorderRemoveCommandクラス
LineRemoveCommandクラス
InvertedTextCommandクラス
InvertedPageCommandクラス
DotRemoveCommandクラス
HolePunchRemoveCommandクラス
HighQualityRotateCommandクラス
MinimumCommandクラス
MaximumCommandクラス
Leadtools.ImageProcessing.Effects.RegionHolesRemovalCommand