LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

StartDitheringメソッド








これがディザ処理のために使うパレット。指定することができます独自のパレットまたはLEADのもののための無効な参照がパレットに用意した使用。
パレットで使われる色の数パレットがより多くの色を格納するならば、最初のカラーだけが使われます。有効な値は、2から256です。
imageのバッファーに入れられたディザ処理を初期化します。
構文
public void StartDithering( 
   RasterColor[] palette,
   int colors
)
'Declaration
 
Public Sub StartDithering( _
   ByVal palette() As RasterColor, _
   ByVal colors As Integer _
) 
'Usage
 
Dim instance As RasterImage
Dim palette() As RasterColor
Dim colors As Integer
 
instance.StartDithering(palette, colors)
public void StartDithering( 
   RasterColor[] palette,
   int colors
)
- (BOOL)startDithering:(nullable NSArray<LTRasterColor *> *)palette 
                colors:(NSUInteger)colors 
                 error:(NSError **)error
            
public void startDithering(
  RasterColor[] palette, 
  int colors
)
            
 function Leadtools.RasterImage.StartDithering( 
   palette ,
   colors 
)
public:
void StartDithering( 
   array<RasterColor>^ palette,
   int colors
) 

パラメーター

パレット
これがディザ処理のために使うパレット。指定することができます独自のパレットまたはLEADのもののための無効な参照がパレットに用意した使用。
パレットで使われる色の数パレットがより多くの色を格納するならば、最初のカラーだけが使われます。有効な値は、2から256です。
解説

以下の流れ図は、メソッドがどのように互いに関連があるかについて示します:

RasterImageからの以下のプロパティは、ディザ処理操作を制御するのに用いられます:

このメソッドは、符合付きイメージをサポートしません。

詳細については、「LEADTOOLSによる画像処理入門」を参照してください。

サンプル

このサンプルディザリングは、1でimageに各々線をひきます、そして、それをもう一つのimageへ書き込みます。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg

      
Public Sub StartDitheringExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load an image that has BottomLeft ViewPerspective
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))
   Dim Palette As RasterColor() = RasterPalette.Fixed(8)

   ' Create the new palletized image.
   Dim destinationImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, _
                                                         image.Order, image.ViewPerspective, Palette, IntPtr.Zero, 0)

   ' Set the dithering method.
   image.DitheringMethod = RasterDitheringMethod.StevensonArce

   ' Initialize the dithering process.
   image.StartDithering(Palette, 256)

   ' Allocate the output buffer for 8-bit data.
   Dim InBuffer As Byte() = New Byte(image.Width * 3 - 1) {} ' Buffer to hold the input row.
   Dim OutBuffer As Byte() = New Byte(image.Width - 1) {} ' Buffer to hold the output row.

   ' Use DitherLine method to process each row in the image.
   Dim i As Integer = 0
   Do While i < image.Height
      image.GetRow(i, InBuffer, 0, image.BytesPerLine)
      image.DitherLine(InBuffer, 0, OutBuffer, 0)
      destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine)
      i += 1
   Loop
   ' End the dithering process.
   image.StopDithering()

   codecs.Save(destinationImage, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_DitherLine.BMP"), RasterImageFormat.Bmp, 0)

   image.Dispose()
   destinationImage.Dispose()
   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;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;

      
public void StartDitheringExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // Load an image that has BottomLeft ViewPerspective
   RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP"));
   RasterColor[] Palette = RasterPalette.Fixed(256);

   // Create the new palletized image.
   RasterImage destinationImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, IntPtr.Zero, 0);

   // Set the dithering method.
   image.DitheringMethod = RasterDitheringMethod.StevensonArce;

   // Initialize the dithering process.
   image.StartDithering(Palette, 256);

   // Allocate the output buffer for 8-bit data.
   byte[] InBuffer = new byte[image.Width * 3];// Buffer to hold the input row.
   byte[] OutBuffer = new byte[image.Width];// Buffer to hold the output row.

   // Use DitherLine method to process each row in the image.
   for(int i = 0; i < image.Height; i++)
   {
      image.GetRow(i, InBuffer, 0, image.BytesPerLine);
      image.DitherLine(InBuffer, 0, OutBuffer, 0);
      destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine);
   }
   // End the dithering process.
   image.StopDithering();

   codecs.Save(destinationImage, Path.Combine(ImagesPath.Path, "IMAGE1_DitherLine.BMP"), RasterImageFormat.Bmp, 0);

   image.Dispose();
   destinationImage.Dispose();
   codecs.Dispose();
}
RasterImageExamples.prototype.StartDitheringExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();

         // Load an image that has BottomLeft ViewPerspective
         var srcFileName = "Assets\\Image1.cmp";
         var image;
         var destinationImage;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
            return codecs.loadAsync(LeadStreamFactory.create(loadFile))
         })
            .then(function (img) {
               image = img;

               var Palette = [RasterColorHelper.create(0, 0, 0),
                  RasterColorHelper.create(255, 255, 255),
                  RasterColorHelper.create(255, 0, 0),
                  RasterColorHelper.create(0, 255, 0),
                  RasterColorHelper.create(0, 0, 255),
                  RasterColorHelper.create(255, 255, 0),
                  RasterColorHelper.create(0, 255, 255),
                  RasterColorHelper.create(255, 0, 255),
                  RasterColorHelper.create(128, 128, 0),
                  RasterColorHelper.create(0, 128, 128),
                  RasterColorHelper.create(128, 128, 128),
                  RasterColorHelper.create(128, 0, 128),
                  RasterColorHelper.create(128, 255, 128),
                  RasterColorHelper.create(128, 255, 255),
                  RasterColorHelper.create(255, 128, 128),
                  RasterColorHelper.create(255, 255, 128)
               ];

               // Create the new palletized image.
               destinationImage = new RasterImage(RasterMemoryFlags.conventional, image.width, image.height, 4, image.order, image.viewPerspective, Palette);

               // Set the dithering method.
               image.ditheringMethod = RasterDitheringMethod.stevensonArce;

               // Initialize the dithering process.
               image.startDithering(Palette, Palette.length);

               // Allocate the output buffer for 8-bit data.
               var InBuffer = new Uint8Array(image.bytesPerLine);// Buffer to hold the input row.
               var OutBuffer = new Uint8Array(destinationImage.bytesPerLine);// Buffer to hold the output row.

               // Use DitherLine method to process each row in the image.
               image.accessData();
               for (var i = 0; i < image.height; i++) {
                  image.getRow(i, InBuffer, 0, image.bytesPerLine);
                  image.ditherLine(InBuffer, OutBuffer);
                  destinationImage.setRow(i, OutBuffer, 0, destinationImage.bytesPerLine);
               }
               // End the dithering process.
               image.stopDithering();
               image.releaseData();

               return Tools.AppLocalFolder().createFileAsync("IMAGE1_DitherLine.BMP")
            })
            .then(function (saveFile) {
               var saveStream = LeadStreamFactory.create(saveFile);
               return codecs.saveAsync(destinationImage, saveStream, RasterImageFormat.bmp, 0)
            })
            .then(function () {

               image.Dispose();
               destinationImage.Dispose();
               codecs.Dispose();
            });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;

      
public async Task StartDitheringExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // Load an image that has BottomLeft ViewPerspective
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
   RasterColor[] Palette = { RasterColorHelper.Create(0,0,0),
                             RasterColorHelper.Create(255,255,255),
                             RasterColorHelper.Create(255,0,0),
                             RasterColorHelper.Create(0,255,0),
                             RasterColorHelper.Create(0,0,255),
                             RasterColorHelper.Create(255,255,0),
                             RasterColorHelper.Create(0,255,255),
                             RasterColorHelper.Create(255,0,255),
                             RasterColorHelper.Create(128,128,0),
                             RasterColorHelper.Create(0,128,128),
                             RasterColorHelper.Create(128,128,128),
                             RasterColorHelper.Create(128,0,128),
                             RasterColorHelper.Create(128,255,128),
                             RasterColorHelper.Create(128,255,255),
                             RasterColorHelper.Create(255,128,128),
                             RasterColorHelper.Create(255,255,128),
                           };

   // Create the new palletized image.
   RasterImage destinationImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 4, image.Order, image.ViewPerspective, Palette);

   // Set the dithering method.
   image.DitheringMethod = RasterDitheringMethod.StevensonArce;

   // Initialize the dithering process.
   image.StartDithering(Palette, Palette.Length);

   // Allocate the output buffer for 8-bit data.
   byte[] InBuffer = new byte[image.BytesPerLine];// Buffer to hold the input row.
   byte[] OutBuffer = new byte[destinationImage.BytesPerLine];// Buffer to hold the output row.

   // Use DitherLine method to process each row in the image.
   image.AccessData();
   for (int i = 0; i < image.Height; i++)
   {
      image.GetRow(i, InBuffer, 0, image.BytesPerLine);
      image.DitherLine(InBuffer, 0, OutBuffer, 0);
      destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine);
   }
   // End the dithering process.
   image.StopDithering();
   image.ReleaseData();

   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("IMAGE1_DitherLine.BMP");
   ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
   await codecs.SaveAsync(destinationImage, saveStream, RasterImageFormat.Bmp, 0);

   image.Dispose();
   destinationImage.Dispose();
   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;

public void StartDitheringExample(RasterImage image, Stream destStream)
{
   RasterColor[] Palette = RasterPalette.Fixed(256);
   // Create the new palletized image.
   RasterImage destinationImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, null, 0);

   // Set the dithering method.
   image.DitheringMethod = RasterDitheringMethod.StevensonArce;

   // Initialize the dithering process.
   image.StartDithering(Palette, 256);

   // Allocate the output buffer for 8-bit data.
   byte[] InBuffer = new byte[image.Width * 3];// Buffer to hold the input row.
   byte[] OutBuffer = new byte[image.Width];// Buffer to hold the output row.

   // Use DitherLine method to process each row in the image.
   for (int i = 0; i < image.Height; i++)
   {
      image.GetRow(i, InBuffer, 0, image.BytesPerLine);
      image.DitherLine(InBuffer, 0, OutBuffer, 0);
      destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine);
   }
   // End the dithering process.
   image.StopDithering();

   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(destinationImage, destStream, RasterImageFormat.Bmp, 0);

   image.Dispose();
   destinationImage.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Public Sub StartDitheringExample(ByVal image As RasterImage, ByVal destStream As Stream)
   Dim Palette As RasterColor() = RasterPalette.Fixed(256)
   ' Create the new palletized image.
   Dim destinationImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, Nothing, 0)

   ' Set the dithering method.
   image.DitheringMethod = RasterDitheringMethod.StevensonArce

   ' Initialize the dithering process.
   image.StartDithering(Palette, 256)

   ' Allocate the output buffer for 8-bit data.
   Dim InBuffer As Byte() = New Byte(image.Width * 3 - 1){} ' Buffer to hold the input row.
   Dim OutBuffer As Byte() = New Byte(image.Width - 1){} ' Buffer to hold the output row.

   ' Use DitherLine method to process each row in the image.
   Dim i As Integer = 0
   Do While i < image.Height
      image.GetRow(i, InBuffer, 0, image.BytesPerLine)
      image.DitherLine(InBuffer, 0, OutBuffer, 0)
      destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine)
      i += 1
   Loop
   ' End the dithering process.
   image.StopDithering()

   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(destinationImage, destStream, RasterImageFormat.Bmp, 0)

   image.Dispose()
   destinationImage.Dispose()
End Sub
必要条件

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

参照

参照

RasterImageクラス
RasterImageメンバ
LEADTOOLSによる画像処理入門
ディザ処理メソッド
Codecs.CodecsThumbnailOptions.DitheringMethodプロパティ
ImageProcessing.ColorResolutionCommand.DitheringMethodプロパティ
RasterDitheringMethod列挙体
RasterDefaults.DitheringMethodプロパティ
RasterImage.DitheringMethodプロパティ
RasterImage.DitherLineメソッド
RasterImage.StopDitheringメソッド
RasterBufferConverter.Convert