I got this problem while adding Hue and HSL mode to colorizer.
The code simply does nothing.
From the code:
Functions I made for this code:Code:if(rdPtr->mode=1) // Hue Mode { float H,S,L; RGB2HSL(r,g,b,H,S,L); HSL2RGB(H+rdPtr->h/360.0,S,L,newr,newg,newb); } if(rdPtr->mode=2) //HSL mode { float H,S,L; RGB2HSL(r,g,b,H,S,L); HSL2RGB(H+rdPtr->h/360.0,S+rdPtr->s/240.0,+rdPtr->l/240.0,newr,newg,newb); }
Also, If I add this code for debugging, the extension crashes at runtime:Code:void RGB2HSL(byte r,byte g,byte b,float &h,float &s,float &l) { float fr,fg,fb,min,max; fr=r/255.0; fg=g/255.0; fb=b/255.0; min=max(max(fr,fg),fb); max=min(min(fr,fg),fb); l=(max+min)/2; if(min==max) { s=0; h=0; } else { if(l>0.5) s=(max-min)/(max+min); else s=(max-min)/(2.0-max-min); } if (r==max) h = (g-b)/(max-min); if (g==max) h = 2.0 + (b-r)/(max-min); if (b==max) h = 4.0 + (r-g)/(max-min); h=h/6.0; } void HSL2RGB(float h, float s, float l,int &r, int &g, int &b) { float temp1,temp2,tempr,tempg,tempb; h=((((int)(h*360))%360+360)%360)/360.0; s=min(max(0,s),1); l=min(max(0,l),1); if(s==0) { r=(byte)l*255; g=(byte)l*255; b=(byte)l*255; } else { if(l<0.5) temp2=l*(1.0+s); else temp2=l+s - l*s; temp1=2.0*l - temp2; tempr = h + 1.0 / 3.0; if(tempr > 1) tempr--; tempg = h; tempb = h - 1.0 / 3.0; if(tempb < 0) tempb++; //Red if(tempr < 1.0 / 6.0) r = (temp1 + (temp2 - temp1) * 6.0 * tempr)*255; else if(tempr < 0.5) r = (temp2)*255; else if(tempr < 2.0 / 3.0) r = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempr) * 6.0)*255; else r = (temp1)*255; //Green if(tempg < 1.0 / 6.0) g = (temp1 + (temp2 - temp1) * 6.0 * tempg)*255; else if(tempg < 0.5) g = temp2*255; else if(tempg < 2.0 / 3.0) g = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempg) * 6.0)*255; else g = (temp1*255); //Blue if(tempb < 1.0 / 6.0) b = (temp1 + (temp2 - temp1) * 6.0 * tempb)*255; else if(tempb < 0.5) b = (temp2)*255; else if(tempb < 2.0 / 3.0) b = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempb) * 6.0)*255; else b = temp1*255; } }
Can anyone please help me?Code:char debuging[150]; sprintf(debuging,"H=%d S=%d L=%d",(int)H*360,(int)S*360,(int)L*360); MessageBox(NULL,debuging, "Colorizer", MB_OK);![]()







Reply With Quote
