Previous Document Next Document

Object Model Reference : Classes : C : Color : Methods : Color.ConvertToRGB


Color.ConvertToRGB

Sub ConvertToRGB()

Description

Member of Color

The ConvertToRGB method converts the active color model to the RGB color model in CorelDRAW.

A color is an effect applied to an object that alters the object’s appearance by the way it reflects light. A color model is a system that defines the number and type of colors that make up an image and that is used to organize and define colors according to a set of basic properties that can be reproduced. Black-and-white, grayscale, RGB, CMYK, and paletted are examples of popular color modes.

RGB is a color mode that contains three components: red (R), green (G), and blue (B). The RGB color mode is based on the RGB color model. In the RGB color mode, a value between 0 and 255 is assigned to each channel of red, green, and blue. An RGB color with the component values 0:25:118, for example, contains no red, some green, and more blue, resulting in a slightly greenish blue color. Monitors, scanners, and the human eye use RGB to produce or detect color.

CorelDRAW lets you convert to the following color modes: black-and-white, grayscale, duotone, RGB, CMYK, or LAB. You can also convert to the paletted color mode.

VBA example

The following VBA example uses a separate Color object to take an object’s fill color and convert it to RGB, then checks if the color is red (that is, if its Red component value is greater than 150 and both Blue and Green values are less than 100). If this is the case, the object is filled with black. Otherwise, the object’s fill remains unchanged.

Sub Test()
 Dim c As New Color
 Dim s As Shape
 For Each s In ActiveSelection.Shapes
  If s.Fill.Type = cdrUniformFill Then
   c.CopyAssign s.Fill.UniformColor
   c.ConvertToRGB
   If c.RGBRed > 150 And c.RGBGreen < 100 And c.RGBBlue < 100 Then
    s.Fill.UniformColor.RGBAssign 0, 0, 0
   End If
  End If
 Next s
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.