Gan_Pixel Pixel1, Pixel2; /* declare pixels 1 & 2 */
/* let's initialise pixel 1 to a grey-level unsigned character value */
Pixel1.format = GAN_GREY_LEVEL_IMAGE;
Pixel1.type = GAN_UCHAR;
Pixel1.data.gl.uc = 255;
/* now convert pixel to RGB format and floating point type */
gan_image_convert_pixel_q ( &Pixel1, GAN_RGB_COLOUR_IMAGE, GAN_FLOAT,
&Pixel2 );
/* print new pixel value, which should be R=G=B=1 */
printf ( "pixel RGB value %f %f %f\n", Pixel2.data.rgb.f.R,
Pixel2.data.rgb.f.G, Pixel2.data.rgb.f.B );
Another version of this function returns the result as a new pixel:
/* convert pixel to RGB format and floating point type */
Pixel2 = gan_image_convert_pixel_s ( &Pixel1, GAN_RGB_COLOUR_IMAGE, GAN_FLOAT );
There is also a routine that converts the format and type in-place in the
input pixel:
/* convert pixel to RGB format and floating point type in-place */
gan_image_convert_pixel_i ( &Pixel1, GAN_RGB_COLOUR_IMAGE, GAN_FLOAT );