Convert LAB to RGB Using C#
The Aspose.SVG for .NET provides a high-performance C# library for various SVG parsing tasks, including seamless work with multiple color spaces. The API’s Color class enables you to parse colors from string representations (such as RGB, HEX, HSL, HWB, CMYK, NCOL, LCH, OKLCH, LAB, OKLAB) and convert them to the desired color space.
Online Color Converter
Need to convert colors between different color models? Try our free online tool! It supports multiple color spaces, including HEX, RGB, CMYK, HSL, LAB, NCOL, XYZ, and more. Simply enter a color value to convert it. You can click inside the color area to pick a color or input a color code in the text box. The corresponding color codes will instantly appear in the Output section.
// Parse LAB color from a string var color = Color.FromLab(51.788f, 62.357f, 52.178f); // Convert LAB to RGB string rgbColor = color.ToRgbString(); // Print result to console Console.WriteLine(rgbColor); //result should be: rgb(223, 61, 37)
How to convert LAB to RGB using C#
If you want to use the conversion functions in your product or programmatically convert LAB to RGB, see the C# code example above. Color conversion can be done with a few lines of code:
- Use the
Color.FromLab(lightness, a, b)
method to parse a color from the LAB color space using the specified
L
,a
, andb
values. Thecolor
object created represents this LAB color. - The Color.ToRgbString() method converts the LAB color to the RGB color space and returns the string representation of the color in the RGB color space.
- The
Console.WriteLine(rgbColor)
method prints the RGB color string to the console. The expected output isrgb(223, 61, 37)
, which represents the RGB equivalent of the given LAB color.
For more details on using .NET API functions, visit our documentation, where you will find C# examples for common SVG processing scenarios. In the article How to Change SVG Color , you can learn how to change the color of elements and backgrounds in SVG images using the Aspose.SVG for .NET library. The SVG Color article offers an in-depth exploration of how to colorize SVG text and shapes.
Aspose.SVG offers free online Color Converters that allow you to instantly convert colors between various color codes, such as RGB, HEX, HSL, HSV, HWB, LAB, CMYK, LCH, XYZ, OKLAB, OKLCH, RGBA, HSLA, and more. These easy-to-use tools work on any browser and operating system, delivering immediate results when you enter the color code to convert.
FAQ
Aspose.SVG allows you to convert LAB to other color formats in any way – online or programmatically. For example, you can convert LAB in real-time using Online Color Converter that transforms color codes quickly and with high quality. Upload, convert and get the result at once!
You can perform conversions between color models such as RGB, HEX, HSL, HSV, HWB, LAB, CMYK, XYZ, LCH, OKLAB, etc.
A color space is a specific organization of colors that is a collection of information and data that declares how a system or device displays color to a user. The color spaces are closely linked to the methods of describing and defining these colors using their respective color codes. For different tasks, different color codes are preferred. For example, RGB colors are for the web and CMYK colors are for print.
If you check the RGB system, you will see that there are 256 different quantity options for each color – red, green, and blue. So, according to the RGB cube model, the number of colors is 256^3 = 16 777 216. If you like working with color names, there are 147 HTML color names that can be used in HTML5, including 17 standard ones. Using HTML4, you can handle 140 color names, including 16 standard colors. The secondary color in HTML5 is orange.
What is RGB Color?
Like geographic coordinates – longitude, latitude and height – the color values LAB give us a way to detect colors. LAB uses three axes: L – Lightness, a* – from Red to Green Value, and b* – from Blue to Yellow Value. The Lightness is expressed as a percentage and can exceed 100%. Values for the a and b axes can range from positive to negative. It is commonly clamped to the range of −128 to 127 for use with integer code values. The LAB color space and LAB color codes are recommended to use if you want the color on-screen to look the same as when printed on paper.
What is LAB Color?
The RGB (Red, Green, Blue) color space consists of all possible colors that can be obtained by mixing red, green, and blue. This color model is popular in photography, TV and computer graphics. RGB values are specified as an integer between 0 and 255. So, for example, rgb(255,0,0) is displayed as red. The red parameter is set to its highest value (255), and the rest are set to 0.
Aspose.SVG C# library supports RGB percentages (from 0% to 100%). For example, rgb(100%,0,0) is displayed as red.
Get Started with Aspose.SVG for .NET API
If you are interested in developing scalable vector graphics and their application, install our flexible, high-speed Aspose.SVG for .NET API with a powerful set of interfaces for C# and other .NET programming languages.Install from command line as
nuget install Aspose.SVG
or via Package Manager Console of Visual Studio with Install-Package Aspose.SVG
.
Alternatively, get the offline MSI installer or DLLs in a ZIP file from
downloads.
Aspose.SVG for .NET API is a standalone library and does not depend on any software for SVG document processing.For more details about C# library installation and system requirements, please refer to Aspose.SVG Documentation.