Jump to content

HSL to RGB in LV


Recommended Posts

  • 4 weeks later...

QUOTE(thevoiceover @ Oct 30 2007, 03:51 PM)

Yes and I am broke.... Oh well..

Use the following code to write your own "HSL to RGB.vi" in LabVIEW. It does not take that long.

/******************************************************************************   FUNCTION: HLStoRGB   PURPOSE:	 Convert from HSL to RGB   IN:		 Hue, Saturation, Luminance from 0 to 1   RETURN:	 RGB color (0xRRGGBB)   COPYRIGHT:1995-1997 Robert Mashlan			 Modified for LabWindows/CVI, 1999 Guillaume Dargaud ******************************************************************************/ typedef unsigned char  BYTE;		// 8-bit unsigned entity  COLORREF HLStoRGB(const double H, const double L, const double S ) {	 double r,g,b;	 double m1, m2; 	 if (S==0) r=g=b=L;	 else {		 if (L <=0.5) m2 = L*(1.0+S);		 else		 m2 = L+S-L*S;		 m1 = 2.0*L-m2;		 r = HueToRGB(m1,m2,H+1.0/3.0);		 g = HueToRGB(m1,m2,H);		 b = HueToRGB(m1,m2,H-1.0/3.0);	 }   return MakeRGB((BYTE)(r*255),(BYTE)(g*255),(BYTE)(b*255)); }/******************************************************************************  FUNCTION: HueToRGB  PURPOSE: 	Convert a hue (color) to RGB  COPYRIGHT:1995-1997 Robert Mashlan			Modified for LabWindows/CVI, 1999 Guillaume Dargaud******************************************************************************/static double HueToRGB(const double m1, const double m2, double h ) {	if (h<0) h+=1.0;	if (h>1) h-=1.0;	if (6.0*h < 1  ) return (m1+(m2-m1)*h*6.0);	if (2.0*h < 1  ) return m2;	if (3.0*h < 2.0) return (m1+(m2-m1)*((2.0/3.0)-h)*6.0);	return m1;}

PJM

Link to comment
  • 2 weeks later...

This what you're looking for?

QUOTE(thevoiceover @ Oct 3 2007, 02:18 PM)

I am curious on if anyone has anything that could convert HSL to RGB for me that I could run in some LabVIEW code.. I could have sworn I had a .dll way back that did this, but I can't find it... I couldn't find anything in LV that did this either... I am running 7.1.1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.