public RasterColor GetTrueColorValue(
RasterColor color
)
- (LTRasterColor *)getTrueColorValue:(LTRasterColor *)color
public RasterColor getTrueColorValue(
RasterColor color
);
public:
RasterColor GetTrueColorValue(
RasterColor color
)
def GetTrueColorValue(self,color):
color
a RasterColor that specifies the source color
A RasterColor that is guaranteed to be a true color (has RGB value)
Use this method to translate a color that is really a palette index (the value of the RasterColor.IsPaletteIndex property is true) to a true RGB color value
The opposite of this method is TranslateColor.
This example will create transparent GIF file
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Drawing;
public void CreateTransparentGifExample()
{
// Create a 24 bpp image, we will draw on it first then convert it to 8 bpp
using (RasterImage image = new RasterImage(
RasterMemoryFlags.Conventional,
256,
256,
8,
RasterByteOrder.Bgr,
RasterViewPerspective.BottomLeft,
null,
IntPtr.Zero,
0))
{
Assert.IsNotNull(image);
// Fill the image with the transparent color.
RasterColor transparentColor = RasterColor.FromKnownColor(RasterKnownColor.Magenta);
new FillCommand(transparentColor).Run(image);
image.Transparent = true;
// Get the true color used for Magenta inside this image (a palette index)
image.TransparentColor = image.TranslateColor(image, transparentColor);
// Draw on the image, else the entire image will be transparent.
DrawEllipses(image);
// Save this image as GIF
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "TransparentEllipses.gif");
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Save(image, fileName, RasterImageFormat.Gif, 8);
}
}
}
void DrawEllipses(RasterImage image)
{
// Fill this image with magenta color and draw some random ellipses on top
const int ellipseWidth = 40;
const int ellipseHeight = 40;
IntPtr hdc = IntPtr.Zero;
try
{
hdc = RasterImagePainter.CreateLeadDC(image);
Assert.IsFalse(hdc == IntPtr.Zero);
using (Graphics g = Graphics.FromHdc(hdc))
{
Assert.IsNotNull(g);
Random r = new Random();
for (int i = 0; i < 40; i++)
{
int x = r.Next(image.Width - ellipseWidth);
int y = r.Next(image.Height - ellipseHeight);
Color clr = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256));
using (Brush brush = new SolidBrush(clr))
{
g.FillEllipse(brush, x, y, ellipseWidth, ellipseHeight);
}
}
}
}
finally
{
// Make sure to delete the handle to the DC.
if (hdc != IntPtr.Zero)
RasterImagePainter.DeleteLeadDC(hdc);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.