![]() |
![]() |
![]() |
![]() |
Color SpaceAvailability LightWave® 10.0 The color space global returns a structure that contains function pointers to the LightWave® color space conversion functions. These functions allow the user to change their color values to those selected in the color space of LightWave®. To determine the current color space settings, one needs to refresh the LWColorSpaceFuncs structure. The functions come in two types. The first type is to determine which color space is being used. The second type, after a color space has been determined, returns the functions that change RGB or A values into another color space. Global Call LWColorSpaceFuncs *colorspacefuncs; colorspacefuncs = global( LWCOLORSPACEFUNCS_GLOBAL, GFUSE_TRANSIENT ); The global function returns a pointer to an LWColorSpaceFuncs structure. The color space conversion functions use these prototypes. typedef void LWPIXELCONVERSIONRGB( struct st_lwimagelookup *, float *, float * ); typedef void LWPIXELCONVERSIONALPHA( struct st_lwimagelookup *, float *, float * ); The Local Structure The color space is a enumeration of built-in color spaces. If the color space value is greater than or equal to lwcs_sizeof, then it is a color space loaded from the disk. typedef enum en_lwcolorspace { lwcs_linear = 0, /*!< LightWave linear color space. */ lwcs_sRGB, /*!< Standard RGB color space. */ lwcs_rec709, /*!< Recommendation BT.709, HDTV. */ lwcs_cineon, /*!< Eastman Kodak Co. */ lwcs_sizeof } LWCOLORSPACE; typedef void LWPIXELCONVERSIONRGB( struct st_lwimagelookup *, float *, float * ); /*!< Conversion function prototype. */ typedef void LWPIXELCONVERSIONALPHA( struct st_lwimagelookup *, float *, float * ); /*!< Conversion function prototype. */ typedef struct st_lwcolorspacefuncs { LWCOLORSPACE (*nameToColorSpace)( char * ); LWCOLORSPACE (*getPixelConversionLookupTable)( char * ); LWPIXELCONVERSIONRGB *(*getPixelConversionNonLinearToLinearRGB)( LWCOLORSPACE, struct st_lwimagelookup ** ); LWPIXELCONVERSIONRGB *(*getPixelConversionLinearToNonLinearRGB)( LWCOLORSPACE, struct st_lwimagelookup ** ); LWPIXELCONVERSIONALPHA *(*getPixelConversionNonLinearToLinearAlpha)(LWCOLORSPACE, struct st_lwimagelookup ** ); LWPIXELCONVERSIONALPHA *(*getPixelConversionLinearToNonLinearAlpha)(LWCOLORSPACE, struct st_lwimagelookup ** ); const char * color_space_viewer_name; const char * color_space_viewer_file; const char * color_space_viewer_alpha_name; const char * color_space_viewer_alpha_file; const char * color_space_palette_files_name; const char * color_space_palette_files_file; const char * color_space_8bit_files_name; const char * color_space_8bit_files_file; const char * color_space_float_files_name; const char * color_space_float_files_file; const char * color_space_alpha_files_name; const char * color_space_alpha_files_file; const char * color_space_output_name; const char * color_space_output_file; const char * color_space_output_alpha_name; const char * color_space_output_alpha_file; } LWColorSpaceFuncs;
Example This code fragment converts a single pixel to the viewer. #include <lwrenderer.h> LWColorSpaceFuncs *colorspacefuncs; LWCOLORSPACE color_space_rgb; LWCOLORSPACE color_space_alpha; LWPIXELCONVERSIONRGB *convert_rgb; LWPIXELCONVERSIONALPHA *convert_alpha; struct st_lwimagelookup *instance_rgb; struct st_lwimagelookup *instance_alpha; float in[ 4 ], out[ 4 ]; colorspacefuncs = (LWColorSpaceFuncs *) global( LWCOLORSPACEFUNCS_GLOBAL, GFUSE_TRANSIENT ); if( colorspacefuncs != (LWColorSpaceFuncs *) NULL ) { color_space_rgb = ( ( colorspacefuncs->color_space_viewer_name != (const char *) NULL ) && ( colorspacefuncs->color_space_viewer_name[ 0 ] ) )? colorspacefuncs->nameToColorSpace( (char *) colorspacefuncs->color_space_viewer_name ): lwcs_linear; color_space_alpha = ( ( colorspacefuncs->color_space_viewer_alpha_name != (const char *) NULL ) && ( colorspacefuncs->color_space_viewer_alpha_name[ 0 ] ) )? colorspacefuncs->nameToColorSpace( (char *) colorspacefuncs->color_space_viewer_alpha_name ): lwcs_linear; convert_rgb = colorspacefuncs->getPixelConversionLinearToNonLinearRGB( color_space_rgb, &instance_rgb ); convert_alpha = colorspacefuncs->getPixelConversionLinearToNonLinearAlpha( color_space_alpha, &instance_alpha ); in[ 0 ] = 0.5f; /* Color to convert. */ in[ 1 ] = 0.5f; in[ 2 ] = 0.5f; in[ 3 ] = 1.0f; /* Alpha to convert. */ if( convert_rgb != (LWPIXELCONVERSIONRGB *) NULL ) { convert_rgb( instance_rgb, in, out ); /* Color convert pixel [0], [1], [2]. */ } if( convert_alpha != (LWPIXELCONVERSIONALPHA *) NULL ) { convert_alpha( instance_alpha, in, out ); /* Alpha convert pixel [3]. */ } /* Out[ 4 ] contains converted to viewer color space pixel. */ } |