Functions
Color Tables

Functions

int mdlColor_attachColorTable (WCharCP pCtName, byte *pCtbl)
 
Lets an application attach a new color

table to a design file. More...

 
void mdlColor_getColorTable (byte *pColorTable)
 
Obtains a copy of the color table that is

currently attached to the active design file. More...

 
StatusInt mdlColor_getColorTableByModelRef (byte *pColorTable, DgnModelRefP modelRef)
 Obtains a copy of the color table that is currently used by the specified modelRef. More...
 
int mdlColor_getName (WCharP pCtName)
 Returns the name of the active color table in use with the design file. More...
 
int mdlColor_getNameByModelRef (WCharP pCtName, DgnModelRefP modelRef)
 Returns the name of the color table from the specified model. More...
 
void mdlColor_getDefaultColorTable (byte *pColorTable)
 
Obtains a copy of the default color

table used by MicroStation when no color table is attached to the active design file. More...

 
void mdlColor_getAutocadColorTable (byte *pPalette)
 Returns a pointer to a 768 byte color table. More...
 
int mdlColor_searchRGBArray (RgbColorDef *pRgbColor, void *pRgbTable, int numColors)
 Will find the closest matching RGB to a target RGB from an array of RGB's. More...
 
StatusInt mdlColor_rgbColorFromRawColorInFile (RgbColorDefP pRGB, UInt32 rawColor, DgnFileP dgnFile)
 If the rawColor contains RGB color then that color is returned in *pColor. More...
 
StatusInt mdlColor_rgbColorFromRawColor (RgbColorDefP pRGB, UInt32 rawColor, DgnModelRefP modelRef)
 If the rawColor contains RGB color then that color is returned in *pColor. More...
 
StatusInt mdlColor_rawColorFromRGBColor (UInt32 *pRawColor, RgbColorDefCP pRGBColor, DgnModelRefP modelRef)
 Set *pRawColor to represent the RGB color value specified by *pRGBColor. More...
 
UInt32 mdlColor_v8ColorFromRawColor (UInt32 rawColor)
 The high bytes of color UInt32 are be used to optionally store a color RGB value. More...
 

Detailed Description

Function Documentation

int mdlColor_attachColorTable ( WCharCP  pCtName,
byte pCtbl 
)

Lets an application attach a new color

table to a design file.

Each color definition in ctbl is mapped to the closest matching color in the Color Manager's display colors. The color code associated with each design file element will then correspond to a color in the newly attached color table. (For a more detailed discussion of color tables and their relationships to design file elements, see the beginning of this section).

Parameters
[in]pCtNameThe color table's name as it will appear in the MicroStation Command Window after the attachment is complete. This is also the name that will appear when the CT=? command is entered to display the currently attached color table. ctName does not necessarily correspond to a file name.
[in]pCtblPoints to 256 RGB color definitions containing a total of 768 bytes. The first entry in the table defines the background color to be used in the design file. Color definitions 2 through 256 represent color indices 0 through 254 as used by design file element color codes.
Returns
SUCCESS or a non-zero value if the color table attachment fails.
See also
mdlColor_getColorTable mdlColor_getName
Remarks
Required Library: mdlbltin.lib
void mdlColor_getAutocadColorTable ( byte pPalette)

Returns a pointer to a 768 byte color table.

Parameters
[out]pPaletteA pointer to the color table
Remarks
Required Library: mdlbltin.lib
void mdlColor_getColorTable ( byte pColorTable)

Obtains a copy of the color table that is

currently attached to the active design file.

If no color table is attached to the design file, the MicroStation default color table is copied.

Parameters
[out]pColorTablePoints to a memory area that will receive a copy of the design file's currently attached color table. This memory area must be large enough to hold 256 RGB color definitions containing a total of 768 bytes.
Returns
Returns no value.
See also
mdlColor_attachColorTable mdlColor_getName mdlColor_getColorTableByModelRef
Remarks
Required Library: mdlbltin.lib
StatusInt mdlColor_getColorTableByModelRef ( byte pColorTable,
DgnModelRefP  modelRef 
)

Obtains a copy of the color table that is currently used by the specified modelRef.

Parameters
[out]pColorTablePoints to a memory area that will receive a copy of the color table used by the specified modelRef. This memory area must be large enough to hold 256 RGB color definitions containing a total of 768 bytes.
[in]modelRefModel for which the color table is needed
Returns
Returns SUCCESS or an error code if modelRef is invalid.
See also
mdlColor_attachColorTable mdlColor_getName mdlColor_getColorTable
Remarks
Required Library: mdlbltin.lib
void mdlColor_getDefaultColorTable ( byte pColorTable)

Obtains a copy of the default color

table used by MicroStation when no color table is attached to the active design file.

table. This memory area must be large enough to hold 256 RGB color definitions containing a total of 768 bytes.

Parameters
[out]pColorTableWhere to store the color table.
Returns
Returns no value.
See also
mdlColor_getColorTable
Remarks
Required Library: mdlbltin.lib
int mdlColor_getName ( WCharP  pCtName)

Returns the name of the active color table in use with the design file.

Parameters
[out]pCtNameIs the address of a 64-byte array to receive the name of the color table.
Returns
Always returns SUCCESS.
See also
mdlColor_attachColorTable mdlColor_getColorTable
Remarks
Required Library: mdlbltin.lib
int mdlColor_getNameByModelRef ( WCharP  pCtName,
DgnModelRefP  modelRef 
)

Returns the name of the color table from the specified model.

Parameters
[out]pCtNameIs the address of a 64-byte array to receive the name of the color table.
[in]modelRefThe model to get the name of color table from.
Returns
Always returns SUCCESS.
See also
mdlColor_attachColorTable mdlColor_getColorTable
Remarks
Required Library: mdlbltin.lib
StatusInt mdlColor_rawColorFromRGBColor ( UInt32 pRawColor,
RgbColorDefCP  pRGBColor,
DgnModelRefP  modelRef 
)

Set *pRawColor to represent the RGB color value specified by *pRGBColor.

Parameters
[out]pRawColorraw color
[in]pRGBColorRGB color
[in]modelRefmodelRef
Returns
SUCCESS if raw color is successfully calculated.
Remarks
Required Library: mdlbltin.lib
StatusInt mdlColor_rgbColorFromRawColor ( RgbColorDefP  pRGB,
UInt32  rawColor,
DgnModelRefP  modelRef 
)

If the rawColor contains RGB color then that color is returned in *pColor.

Parameters
[out]pRGBRGB color value (or NULL).
[in]rawColorraw color
[in]modelRefmodelRef for color table
Returns
SUCCESS if the rawColor contains RGB else ERROR.
Remarks
Required Library: mdlbltin.lib
StatusInt mdlColor_rgbColorFromRawColorInFile ( RgbColorDefP  pRGB,
UInt32  rawColor,
DgnFileP  dgnFile 
)

If the rawColor contains RGB color then that color is returned in *pColor.

Parameters
[out]pRGBRGB color value (or NULL).
[in]rawColorraw color
[in]dgnFileDGN file for color table
Returns
SUCCESS if the rawColor contains RGB else ERROR.
Remarks
Required Library: mdlbltin.lib
int mdlColor_searchRGBArray ( RgbColorDef *  pRgbColor,
void *  pRgbTable,
int  numColors 
)

Will find the closest matching RGB to a target RGB from an array of RGB's.

All RGB color comparisons are done by first converting the two RGB values into HSV (Hue, Saturation, Value) values, and comparing those converted values. The hue component of the HSV is given the highest priority. Comparing HSV values results in more desirable colors in terms of what the human eye expects to see.

Remarks
Typically, an application would use this function in conjunction with mdlColor_getColorTable to determine the best element color number to use for an arbitrary RGB value. When using mdlColor_searchRGBArray in this fashion, remember that RGB offset zero in a color table corresponds to the view background color and that RGB index one corresponds to element color number zero.
Parameters
[in]pRgbColorPoints to the target RGB to be matched against the array of RGBs.
[in]pRgbTablePoints to the RGB values that are to be searched for the closest match to the RGB value pointed to by pRgbColor.
[in]numColorsIndicates the number of RGB triads in the array rgbTableP.
Returns
The zero-based index of the RGB triad that most closely matches the target RGB value.
See also
mdlColor_getColorTable
Remarks
Required Library: mdlbltin.lib
UInt32 mdlColor_v8ColorFromRawColor ( UInt32  rawColor)

The high bytes of color UInt32 are be used to optionally store a color RGB value.

In this case, the low (least significant) byte will continue to store the index of the closest color in the color table. This function is used to provide backward compatibilty for these new color values in V8.5. It will return the color index for these combined color values just as they would appear in V8.5 (effectively ignoring the RGB data).

Parameters
[in]rawColorraw color - may contain RGB in high 3 bytes.
Returns
V8 style color - either 0-255 index, COLOR_BYLEVEL or COLOR_BYCELL.
Remarks
Required Library: mdlbltin.lib

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.