Leadtools.ImageProcessing Namespace : ColorResolutionCommandDataEventArgs Class |
public class ColorResolutionCommandDataEventArgs : System.EventArgs
'Declaration Public Class ColorResolutionCommandDataEventArgs Inherits System.EventArgs
'Usage Dim instance As ColorResolutionCommandDataEventArgs
public sealed class ColorResolutionCommandDataEventArgs : ~Remove~
function Leadtools.ImageProcessing.ColorResolutionCommandDataEventArgs()
public ref class ColorResolutionCommandDataEventArgs : public System.EventArgs
Public Sub ColorResolutionCommandDataEventArgsExample() Dim codecs As RasterCodecs = New RasterCodecs() Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_colorresData.bmp") ' Load the source image from disk Dim srcImage As RasterImage = codecs.Load(srcFileName) ' Create the destination image _row = 0 _destImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 1, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0) ' Color-res the image to 1 bits/pixel, we will save the data ourselves into ' the destination image Dim command As ColorResolutionCommand = New ColorResolutionCommand() command.BitsPerPixel = 1 command.DitheringMethod = RasterDitheringMethod.FloydStein AddHandler command.Data, AddressOf command_Data command.Run(srcImage) RemoveHandler command.Data, AddressOf command_Data ' Save it to disk codecs.Save(_destImage, destFileName, RasterImageFormat.Bmp, 4) _destImage.Dispose() ' Clean Up srcImage.Dispose() End Sub Private _destImage As RasterImage Private _row As Integer Private Sub command_Data(ByVal sender As Object, ByVal e As ColorResolutionCommandDataEventArgs) ' Set the data into the destination image _destImage.SetRow(_row, e.Data, _destImage.BytesPerLine * e.Lines) _row += e.Lines ' If you want the data in a managed buffer, ' you can do this ' byte[] data = new byte[_destImage.BytesPerLine * e.Lines]; ' System.Runtime.InteropServices.Marshal.Copy(e.Data, data, 0, data.Length); End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void ColorResolutionCommandDataEventArgsExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_colorresData.bmp"); // Load the source image from disk RasterImage srcImage = codecs.Load(srcFileName); // Create the destination image _row = 0; _destImage = new RasterImage( RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 1, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0); // Color-res the image to 1 bits/pixel, we will save the data ourselves into // the destination image ColorResolutionCommand command = new ColorResolutionCommand(); command.BitsPerPixel = 1; command.DitheringMethod = RasterDitheringMethod.FloydStein; command.Data += new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); command.Run(srcImage); command.Data -= new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); // Save it to disk codecs.Save(_destImage, destFileName, RasterImageFormat.Bmp, 4); _destImage.Dispose(); // Clean Up srcImage.Dispose(); } RasterImage _destImage; int _row; void command_Data(object sender, ColorResolutionCommandDataEventArgs e) { // Set the data into the destination image _destImage.SetRow(_row, e.Data, _destImage.BytesPerLine * e.Lines); _row += e.Lines; // If you want the data in a managed buffer, // you can do this // byte[] data = new byte[_destImage.BytesPerLine * e.Lines]; // System.Runtime.InteropServices.Marshal.Copy(e.Data, data, 0, data.Length); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
RasterCommandExamples.prototype.ColorResolutionCommandDataEventArgsExample = function ( ) { Tools.SetLicense ( ) ; with ( Leadtools ) { with ( Leadtools.Codecs ) {with (Leadtools.ImageProcessing ) { var codecs = new RasterCodecs(); var srcFileName = "Assets\\Image1.cmp"; var destFileName = "Image1_colorresData.bmp"; var srcImage ; // Load the source image from disk return Tools.AppInstallFolder().getFileAsync(srcFileName).then ( function ( loadFile ) { return codecs.loadAsync(LeadStreamFactory.create(loadFile))}) .then ( function ( img ) { srcImage = img ; // Create the destination image _row = 0; _destImage = new RasterImage( RasterMemoryFlags.conventional, srcImage.width, srcImage.height, 1, RasterByteOrder.rgb, RasterViewPerspective.topLeft, null); // Color-res the image to 1 bits/pixel, we will save the data ourselves into // the destination image var command = new ColorResolutionCommand(); command.bitsPerPixel = 1; command.ditheringMethod = RasterDitheringMethod.floydStein; command.addEventListener ("data", command_Data); command.run(srcImage); command.removeEventListener ("data", command_Data); // Save it to disk return Tools.AppLocalFolder().createFileAsync(destFileName)}) .then ( function ( saveFile ) { return codecs.saveAsync(_destImage, LeadStreamFactory.create(saveFile), RasterImageFormat.bmp, 4)}) .then ( function ( ) { _destImage.close(); // Clean Up srcImage.close(); codecs.close ( ) ; }); } } } } var _destImage; var _row; function command_Data(e) { // Set the data into the destination image _destImage.setRow(_row, e.dataArray, 0, _destImage.bytesPerLine * e.lines); _row += e.lines; }
[TestMethod] public async Task ColorResolutionCommandDataEventArgsExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = @"Assets\Image1.cmp"; string destFileName = @"Image1_colorresData.bmp"; // Load the source image from disk StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage srcImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); // Create the destination image _row = 0; _destImage = new RasterImage( RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 1, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null); // Color-res the image to 1 bits/pixel, we will save the data ourselves into // the destination image ColorResolutionCommand command = new ColorResolutionCommand(); command.BitsPerPixel = 1; command.DitheringMethod = RasterDitheringMethod.FloydStein; command.Data += new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); command.Run(srcImage); command.Data -= new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); // Save it to disk StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName); await codecs.SaveAsync(_destImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 4); _destImage.Dispose(); // Clean Up srcImage.Dispose(); } RasterImage _destImage; int _row; void command_Data(object sender, ColorResolutionCommandDataEventArgs e) { // Set the data into the destination image _destImage.SetRow(_row, e.DataArray, 0, _destImage.BytesPerLine * e.Lines); _row += e.Lines; }
public void ColorResolutionCommandDataEventArgsExample(RasterImage srcImage, Stream destStream) { RasterCodecs codecs = new RasterCodecs(); // Create the destination image _row = 0; _destImage = new RasterImage( RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 1, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null, null, 0); // Color-res the image to 1 bits/pixel, we will save the data ourselves into // the destination image ColorResolutionCommand command = new ColorResolutionCommand(); command.BitsPerPixel = 1; command.DitheringMethod = RasterDitheringMethod.FloydStein; command.Data += new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); command.Run(srcImage); command.Data -= new EventHandler<ColorResolutionCommandDataEventArgs>(command_Data); // Save it to disk codecs.Save(_destImage, destStream, RasterImageFormat.Bmp, 4); _destImage.Dispose(); // Clean Up srcImage.Dispose(); } RasterImage _destImage; int _row; void command_Data(object sender, ColorResolutionCommandDataEventArgs e) { // Set the data into the destination image _destImage.SetRow(_row, e.DataArray, 0, _destImage.BytesPerLine * e.Lines); _row += e.Lines; }
Public Sub ColorResolutionCommandDataEventArgsExample(ByVal srcImage As RasterImage, ByVal destStream As Stream)
Dim codecs As RasterCodecs = New RasterCodecs()
' Create the destination image
_row = 0
_destImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 1, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, Nothing, Nothing, 0)
' Color-res the image to 1 bits/pixel, we will save the data ourselves into
' the destination image
Dim command As ColorResolutionCommand = New ColorResolutionCommand()
command.BitsPerPixel = 1
command.DitheringMethod = RasterDitheringMethod.FloydStein
AddHandler command.Data, AddressOf command_Data
command.Run(srcImage)
RemoveHandler command.Data, AddressOf command_Data
' Save it to disk
codecs.Save(_destImage, destStream, RasterImageFormat.Bmp, 4)
_destImage.Dispose()
' Clean Up
srcImage.Dispose()
End Sub
Private _destImage As RasterImage
Private _row As Integer
Private Sub command_Data(ByVal sender As Object, ByVal e As ColorResolutionCommandDataEventArgs)
' Set the data into the destination image
_destImage.SetRow(_row, e.DataArray, 0, _destImage.BytesPerLine * e.Lines)
_row += e.Lines
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2