←Select platform

RasterColorSpace Class

Summary
Provides support for converting buffered image data from one color space to another.
Syntax
C#
VB
C++
public static class RasterColorSpace 
Public MustInherit NotInheritable Class RasterColorSpace  
public ref class RasterColorSpace abstract sealed  
Example

This example will load an image, resize each line, then save the resized image back to disk.

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void RasterColorSpaceExample() 
{ 
	string fileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	using (RasterCodecs codecs = new RasterCodecs()) 
	{ 
		// load an image 
		using (RasterImage image = codecs.Load(fileName)) 
		{ 
			// Allocate the input buffer for 24-bit RGB data  
			byte[] inBuffer = new byte[image.Width * 3]; 
			Assert.IsTrue(inBuffer.Length == image.BytesPerLine); 
 
			// Allocate the output buffer for 32-bit CMYK data 
			byte[] outBuffer = new byte[image.Width * 4]; 
 
			// Get one row of data from the bitmap 
			image.Access(); 
			image.GetRow(0, inBuffer, 0, image.BytesPerLine); 
			image.Release(); 
 
			// Convert the data from RGB in inBuffer to CMYK in outBuffer 
			RasterColorSpace.Convert8(inBuffer, 0, outBuffer, 0, image.Width, RasterColorSpaceFormat8.Rgb, RasterColorSpaceFormat8.Cmyk); 
		} 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
 
Public Sub RasterColorSpaceExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' load an image 
   Dim fileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") 
   Dim image As RasterImage = codecs.Load(fileName) 
 
   ' Allocate the input buffer for 24-bit RGB data  
   Dim inBuffer As Byte() = New Byte(image.Width * 3 - 1) {} 
 
   ' Allocate the output buffer for 32-bit CMYK data 
   Dim outBuffer As Byte() = New Byte(image.Width * 4 - 1) {} 
 
   ' Get one row of data from the bitmap 
   image.Access() 
   image.GetRow(0, inBuffer, 0, image.BytesPerLine) 
   image.Release() 
 
   ' Convert the data from RGB in inBuffer to CMYK in outBuffer 
   RasterColorSpace.Convert8(inBuffer, 0, outBuffer, 0, image.Width, RasterColorSpaceFormat8.Rgb, RasterColorSpaceFormat8.Cmyk) 
 
   ' Cleanup 
   image.Dispose() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.