Visual Basic (Declaration) | |
---|---|
Public Class GrayScaleToMultitoneCommand Inherits Leadtools.ImageProcessing.RasterCommand Implements IRasterCommand |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As GrayScaleToMultitoneCommand |
C# | |
---|---|
public class GrayScaleToMultitoneCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
C++/CLI | |
---|---|
public ref class GrayScaleToMultitoneCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
Run the Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand on an image.
Visual Basic | Copy Code |
---|---|
Public Sub GrayScaleToMultitoneCommandExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command Dim Colors() As RasterColor ReDim Colors(1) Dim command As GrayScaleToMultitoneCommand = New GrayScaleToMultitoneCommand command.Colors = Colors command.Colors(0).R = 255 command.Colors(0).G = 255 command.Colors(0).B = 0 command.Colors(1).R = 255 command.Colors(1).G = 0 command.Colors(1).B = 0 command.Gradient = Nothing command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear command.Tone = GrayScaleToMultitoneCommandToneType.Duotone command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew command.Run(leadImage) codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void GrayScaleToMultitoneCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command GrayScaleToMultitoneCommand command = new GrayScaleToMultitoneCommand(); command.Colors = new RasterColor[2]; command.Colors[0].R = 255; command.Colors[0].G = 255; command.Colors[0].B = 0; command.Colors[1].R = 255; command.Colors[1].G = 0; command.Colors[1].B = 0; command.Gradient = null; command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear; command.Tone = GrayScaleToMultitoneCommandToneType.Duotone; command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew; command.Run(image); codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
SilverlightCSharp | Copy Code |
---|---|
public void GrayScaleToMultitoneCommandExample(RasterImage image, Stream outStream) { // Prepare the command GrayScaleToMultitoneCommand command = new GrayScaleToMultitoneCommand(); command.Colors = new RasterColor[2]; command.Colors[0].R = 255; command.Colors[0].G = 255; command.Colors[0].B = 0; command.Colors[1].R = 255; command.Colors[1].G = 0; command.Colors[1].B = 0; command.Gradient = null; command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear; command.Tone = GrayScaleToMultitoneCommandToneType.Duotone; command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew; command.Run(image); // Save result image RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); image.Dispose(); } |
SilverlightVB | Copy Code |
---|---|
Public Sub GrayScaleToMultitoneCommandExample(ByVal image As RasterImage, ByVal outStream As Stream) ' Prepare the command Dim command As GrayScaleToMultitoneCommand = New GrayScaleToMultitoneCommand() command.Colors = New RasterColor(1){} command.Colors(0).R = 255 command.Colors(0).G = 255 command.Colors(0).B = 0 command.Colors(1).R = 255 command.Colors(1).G = 0 command.Colors(1).B = 0 command.Gradient = Nothing command.Distribution = GrayScaleToMultitoneCommandDistributionType.Linear command.Tone = GrayScaleToMultitoneCommandToneType.Duotone command.Type = GrayScaleToDuotoneCommandMixingType.ReplaceOldWithNew command.Run(image) ' Save result image Dim codecs As RasterCodecs = New RasterCodecs() codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24) image.Dispose() End Sub |
- This class was designed for use with grayscale images. If the image being used is not grayscale, this class only affects those pixels or areas of the image where Red = Green = Blue.
- Monotone conversion is possible by setting Type to Replace, which clears the palette.
- This class gives you the option of having the toolkit generate the array of colors to use or creating the array of colors to use yourself.
- To have the toolkit generate the array of colors:
- If the image is binary, call Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand with Tone set to GrayScaleToMultitoneCommandToneType.MonoTone, Distribution set to GrayScaleToMultitoneCommandDistributionType.Linear and the color you wish to use set in Color. The Leadtools.RasterImage.GrayscaleMode property will be set by Leadtools.ImageProcessing.Color.GrayScaleToDuotoneCommand class object to determine the kind of grayscale palette being used. If the Leadtools.RasterImage.GrayscaleMode property is Leadtools.RasterImage.GrayscaleMode.OrderedInverse or Leadtools.RasterImage.GrayscaleMode.NotOrdered, then the color set in the Color property for the Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand class object will become the first color in the array generated by the toolkit, and the toolkit will create the second color in the array. The Color array will be updated with these two colors. If the Leadtools.RasterImage.GrayscaleMode property is a value other than Leadtools.RasterImage.GrayscaleMode.OrderedInverse or Leadtools.RasterImage.GrayscaleMode.NotOrdered, then the color set in the Color property for the Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand class object will become the second color in the array generated by the toolkit, and the toolkit will create the first color in the array. The Color property will be updated with these two colors.
- If the image is grayscale (not binary) call the Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.Linear. The GrayScaleToMultitoneCommand will take the color(s) set in the Color property and generate a 256 color gradient for each color.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Duotone, set two colors in the Color property. The toolkit will create a 256 color array for each color.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Tritone, set three colors in the Color property. The toolkit will create a 256 color array for each color.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Quadtone, set four colors in the Color property. The toolkit will create a 256 color array for each color.
- If the image is not grayscale (it is color) call the GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.Linear. The GrayScaleToMultitoneCommand will take the color(s) set in the Color property and generate a 256 color gradient for each color. These colors will be used to change only those pixels in the color image for which Red = Green = Blue.
- To use a user-defined array of colors:
- If the image is binary, call GrayScaleToMultitoneCommand with Tone set to GrayScaleToMultitoneCommandToneType.Monotone, Distribution set to GrayScaleToMultitoneCommandDistributionType.UserDefined and the two colors you wish to use in the Gradient property.
- If the image is grayscale (not binary) call GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.UserDefined.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Duotone, set 512 colors (256 for each basic color) in the Gradient property.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Tritone, set 768 colors (256 for each basic color) in the Gradient property.
- If the Tone is set to GrayScaleToMultitoneCommandToneType.Quadtone, set 1024 colors (256 for each basic color) in the Gradient property.
- If the image is not grayscale (it is color) call GrayScaleToMultitoneCommand with Distribution set to GrayScaleToMultitoneCommandDistributionType.UserDefined. (See the expanded explanation in i, ii and iii of (b) above.) These colors will be used to change only those pixels in the color image for which Red = Green = Blue.
- This class supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
- This class does not support signed data images.
- This command does not support 32-bit grayscale images.
For more information, refer to Grayscale Images.
System.Object
Leadtools.ImageProcessing.RasterCommand
Leadtools.ImageProcessing.Color.GrayScaleToMultitoneCommand
Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)