Transparency is represented as a 32-bit packed integer value that stores
the transparency method and transparency components. Assignment of components
depends on the method. It can be an alpha-value or transparency of other object
(layer, block). The transparency object is declared by the following line:
OdCmTransparency clarity;
To get the transparency as an integer value, use the serializeOut() method that returns the
transparency
as a value of the OdUInt32 type. Use the hexadecimal format to represent the
returned value. For example:
odPrintConsoleString(L"\nEntity Color value = %x", clarity.serializeOut());
The obtained transparency value can be separated by the components using the
bit operations. For example:
OdUInt32 value = clarity.serializeOut();
if(((value >> 24) & 0x0F) == 2)
odPrintConsoleString(L"\nTransparency Method is by Alpha that = %d", (value & 0xFF));
To set the transparency using an integer value, use the serializeIn() method that requires an integer value
to set the transparency. The serializeIn() method uses 24 to
27 bits to specify the transparency
method and 0 to 7 bits to specify the alpha value. If these bits contain incorrect
values that the serializeIn() method generates the eInvalidInput exception. Use
the try-catch statement for this method. For example:
try {
clarity.serializeIn(0x02000033); // Set alpha = 51 (20%)
clarity.serializeIn(0x01000000); // Set transparency by block
}
catch(OdError e) {
odPrintConsoleString(L"\nError %d - %s", e.code(), e.description());
}
To compare transparencies, use the (==) operator that returns True
when two transparency instances are equal or False otherwise, and the (!=) operator that returns True
when two transparency instances are not equal or False otherwise. These operators take into account
the transparency method and transparency components when they compare instances, which compare the transparencies as integer numbers. For
example:
The assignment operator copies the specified transparency value from one
instance to another instance, keeping the transparency method and transparency components. For example: