←Select platform

RasterHsvColor Structure

Summary
Describes a color consisting of relative intensities of hue, saturation, value.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public struct RasterHsvColor 
@interface LTRasterHsvColor : NSObject<NSCopying> 
public final class RasterHsvColor 
[SerializableAttribute()] 
public value class RasterHsvColor : public System.ValueType  
class RasterHsvColor: 
Remarks

For more information on how to use this structure, refer to the AddColorHsvRangeToRegion method.

This structure does not support signed images.

Example

This example converts between HSV and RGB colors and back.

C#
Java
using Leadtools; 
 
 
public void RasterHsvColorExample() 
{ 
   const int R = 50; 
   const int G = 100; 
   const int B = 200; 
   // Expected HSV values based on RGB(50,100,200) 
   const int H = 149; 
   const int S = 191; 
   const int V = 200; 
 
   RasterColor rgb1 = new RasterColor(R, G, B); 
   Assert.IsTrue(rgb1.R == R && rgb1.G == G && rgb1.B == B); 
   Console.WriteLine("rgb1 = {0}, {1}, {2}", rgb1.R, rgb1.G, rgb1.B); 
 
   RasterHsvColor hsv1 = RasterHsvColor.FromRasterColor(rgb1); 
   Assert.IsTrue(hsv1.H == H && hsv1.S == S && hsv1.V == V); 
   Console.WriteLine("hsv1 = {0}, {1}, {2}", hsv1.H, hsv1.S, hsv1.V); 
 
   RasterHsvColor hsv2 = new RasterHsvColor(hsv1.H, hsv1.S, hsv1.V); 
   Assert.IsTrue(hsv2.H == H && hsv2.S == S && hsv2.V == V); 
   Console.WriteLine("hsv2 = {0}, {1}, {2}", hsv2.H, hsv2.S, hsv2.V); 
 
   RasterColor rgb2 = hsv2.ToRasterColor(); 
   Assert.IsTrue(rgb2.R == R && rgb2.G == G && rgb2.B == B); //rgb2.G = 102 ?? 
   Console.WriteLine("rgb2 = {0}, {1}, {2}", rgb2.R, rgb2.G, rgb2.B); 
} 
 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
 
 
public void rasterHsvColorExample() { 
   final int R = 50; 
   final int G = 100; 
   final int B = 200; 
   final int H = 149; 
   final int S = 191; 
   final int V = 200; 
 
   RasterColor rgb1 = new RasterColor(R, G, B); 
   assertTrue(rgb1.r() == R && rgb1.g() == G && rgb1.b() == B); 
   System.out.printf("rgb1 = " + rgb1.r() + ", " + rgb1.g() + ", " + rgb1.b()); 
 
   RasterHsvColor hsv1 = RasterHsvColor.fromRasterColor(rgb1); 
   assertTrue(hsv1.getH() == H && hsv1.getS() == S && hsv1.getV() == V); 
   System.out.printf("hsv1 = " + hsv1.getH() + "," + hsv1.getS() + "," + hsv1.getV()); 
 
   RasterHsvColor hsv2 = new RasterHsvColor(hsv1.getH(), hsv1.getS(), hsv1.getV(), V); 
   assertTrue(hsv2.getH() == H && hsv2.getS() == S && hsv2.getV() == V); 
   System.out.printf("hsv2 = " + hsv2.getH() + "," + hsv2.getS() + "," + hsv2.getV()); 
 
   RasterColor rgb2 = hsv2.toRasterColor(); 
   assertTrue(rgb2.r() == R && rgb2.g() == G && rgb2.b() == B); // rgb2.G = 102 ?? 
   System.out.printf("rgb2 = " + rgb2.r() + ", " + rgb2.g() + ", " + rgb2.b()); 
       
   assertTrue("no exceptions thrown", true); 
} 
Requirements

Target Platforms

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

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