'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved .TH mlib_ImageColorRGB2HSL 3MLIB "2 Mar 2007" "SunOS 5.11" "mediaLib Library Functions" .SH NAME mlib_ImageColorRGB2HSL \- RGB to HSL color conversion .SH SYNOPSIS .LP .nf cc [ \fIflag\fR... ] \fIfile\fR... \fB-lmlib\fR [ \fIlibrary\fR... ] #include \fBmlib_status\fR \fBmlib_ImageColorRGB2HSL\fR(\fBmlib_image *\fR\fIdst\fR, \fBconst mlib_image *\fR\fIsrc\fR); .fi .SH DESCRIPTION .sp .LP The \fBmlib_ImageColorRGB2HSL()\fR function performs a conversion from red/green/blue to hue/saturation/lightness. The source and destination images must be three-channel images. .sp .LP It uses the following equations: .sp .in +2 .nf V = max(R, G, B) Vmin = min(R, G, B) L = (V + Vmin)/2 S = (V - Vmin)/(V + Vmin) if L \(<= 1/2 S = (V - Vmin)/(2 - V - Vmin) if L > 1/2 H = (5.0 + (V - B)/(V - Vmin))/6 if R = V and G = Vmin H = (1.0 - (V - G)/(V - Vmin))/6 if R = V and B = Vmin H = (1.0 + (V - R)/(V - Vmin))/6 if G = V and B = Vmin H = (3.0 - (V - B)/(V - Vmin))/6 if G = V and R = Vmin H = (3.0 + (V - G)/(V - Vmin))/6 if B = V and R = Vmin H = (5.0 - (V - R)/(V - Vmin))/6 if B = V and G = Vmin H = 0.0 if R = G = B .fi .in -2 .sp .LP where \fB0 \(<= R, G, B, V, Vmin, L, S \(<= 1\fR and \fB0 \(<= H < 1\fR. .sp .LP Assuming a pixel in the source image is \fB(r, g, b)\fR and its corresponding pixel in the destination image is \fB(h, s, l)\fR, then for \fBMLIB_BYTE\fR images, the following applies: .sp .in +2 .nf R = r/255 G = g/255 B = b/255 h = H*256 s = S*255 l = L*255 .fi .in -2 .sp .LP for \fBMLIB_SHORT\fR images, the following applies: .sp .in +2 .nf R = (r + 32768)/65535 G = (g + 32768)/65535 B = (b + 32768)/65535 h = H*65536 - 32768 s = S*65535 - 32768 l = L*65535 - 32768 .fi .in -2 .sp .LP for \fBMLIB_USHORT\fR images, the following applies: .sp .in +2 .nf R = r/65535 G = g/65535 B = b/65535 h = H*65536 s = S*65535 l = L*65535 .fi .in -2 .sp .LP and for \fBMLIB_INT\fR images, the following applies: .sp .in +2 .nf R = (r + 2147483648)/4294967295 G = (g + 2147483648)/4294967295 B = (b + 2147483648)/4294967295 h = H*4294967296 - 2147483648 s = S*4294967295 - 2147483648 l = L*4294967295 - 2147483648 .fi .in -2 .SH PARAMETERS .sp .LP The function takes the following arguments: .sp .ne 2 .mk .na \fB\fIdst\fR\fR .ad .RS 7n .rt Pointer to destination image. .RE .sp .ne 2 .mk .na \fB\fIsrc\fR\fR .ad .RS 7n .rt Pointer to source image. .RE .SH RETURN VALUES .sp .LP The function returns \fBMLIB_SUCCESS\fR if successful. Otherwise it returns \fBMLIB_FAILURE\fR. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe .TE .SH SEE ALSO .sp .LP \fBmlib_ImageColorHSL2RGB\fR(3MLIB), \fBmlib_ImageColorHSL2RGB_Fp\fR(3MLIB), \fBmlib_ImageColorRGB2HSL_Fp\fR(3MLIB), \fBattributes\fR(5)