Some more work on HLS colors. Broken...
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@347 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
48979bf251
commit
a60b2bfd01
36
op_c.c
36
op_c.c
@ -24,6 +24,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "op_c.h"
|
#include "op_c.h"
|
||||||
#include "erreurs.h"
|
#include "erreurs.h"
|
||||||
@ -103,10 +104,43 @@ void rgb2hl(int r,int g,int b,byte * hr,byte * lr,byte* sr)
|
|||||||
*sr = (s*255.0);
|
*sr = (s*255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HLStoRGB(byte H,byte L,byte S, byte* R, byte* G, byte* B)
|
||||||
|
{
|
||||||
|
float OffsetSaturation;
|
||||||
|
float rf,gf,bf;
|
||||||
|
|
||||||
|
S = 255 - S;
|
||||||
|
|
||||||
|
if(H < 85)
|
||||||
|
rf = fminf(1, (85 - H) / 42.5);
|
||||||
|
|
||||||
|
else if(H > 170)
|
||||||
|
rf = fminf(1, (H - 170) / 42.5);
|
||||||
|
|
||||||
|
if (H < 170)
|
||||||
|
gf = fminf(1, (85 - abs(H - 85)) / 42.5);
|
||||||
|
|
||||||
|
if (H > 85)
|
||||||
|
bf = fminf(1, (85 - abs(H - 170)) / 42.5);
|
||||||
|
|
||||||
|
if (S < 255)
|
||||||
|
{
|
||||||
|
rf = rf * (S / 255.0);
|
||||||
|
gf = gf * (S / 255.0);
|
||||||
|
bf = bf * (S / 255.0);
|
||||||
|
OffsetSaturation = /*128 **/ (255 - S) / 255.0;
|
||||||
|
rf += OffsetSaturation;
|
||||||
|
gf += OffsetSaturation;
|
||||||
|
bf += OffsetSaturation;
|
||||||
|
}
|
||||||
|
|
||||||
|
*R = rf * ((255 - abs(L - 255)) / 255.0);
|
||||||
|
*G = gf * ((255 - abs(L - 255)) / 255.0);
|
||||||
|
*B = bf * ((255 - abs(L - 255)) / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////// M‚thodes de gestion des tables de conversion //
|
///////////////////////////// Méthodes de gestion des tables de conversion //
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Table_conversion * TC_New(int nbb_r,int nbb_v,int nbb_b)
|
Table_conversion * TC_New(int nbb_r,int nbb_v,int nbb_b)
|
||||||
|
|||||||
1
op_c.h
1
op_c.h
@ -148,6 +148,7 @@ byte TC_Get(Table_conversion * t,int r,int v,int b);
|
|||||||
void TC_Set(Table_conversion * t,int r,int v,int b,byte i);
|
void TC_Set(Table_conversion * t,int r,int v,int b,byte i);
|
||||||
|
|
||||||
void rgb2hl(int r, int v,int b, byte* h, byte*l, byte* s);
|
void rgb2hl(int r, int v,int b, byte* h, byte*l, byte* s);
|
||||||
|
void HLStoRGB(byte h, byte l, byte s, byte* r, byte* g, byte* b);
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
27
palette.c
27
palette.c
@ -936,9 +936,22 @@ void Bouton_Palette(void)
|
|||||||
case 2 : // Jauge rouge
|
case 2 : // Jauge rouge
|
||||||
Effacer_curseur();
|
Effacer_curseur();
|
||||||
if (Debut_block==Fin_block)
|
if (Debut_block==Fin_block)
|
||||||
|
{
|
||||||
|
if(Palette_mode_RGB)
|
||||||
{
|
{
|
||||||
Modifier_Rouge(Fore_color,63-Jauge_rouge->Position,Palette_de_travail);
|
Modifier_Rouge(Fore_color,63-Jauge_rouge->Position,Palette_de_travail);
|
||||||
Num2str(Palette_de_travail[Fore_color].R,Chaine,2);
|
Num2str(Palette_de_travail[Fore_color].R,Chaine,2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte h,l,s;
|
||||||
|
|
||||||
|
rgb2hl(Palette_de_travail[Fore_color].R,Palette_de_travail[Fore_color].V,Palette_de_travail[Fore_color].B,&h,&l,&s);
|
||||||
|
h=(63-Jauge_rouge->Position)*4; // Enlever le *4 quand le slider ira de 0 à 255 comme il faut
|
||||||
|
HLStoRGB(h,l,s,&Palette_de_travail[Fore_color].R,&Palette_de_travail[Fore_color].V,&Palette_de_travail[Fore_color].B);
|
||||||
|
|
||||||
|
Num2str((int)h>>2,Chaine,2);
|
||||||
|
}
|
||||||
Print_dans_fenetre(180,172,Chaine,CM_Noir,CM_Clair);
|
Print_dans_fenetre(180,172,Chaine,CM_Noir,CM_Clair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -975,9 +988,23 @@ void Bouton_Palette(void)
|
|||||||
case 3 : // Jauge verte
|
case 3 : // Jauge verte
|
||||||
Effacer_curseur();
|
Effacer_curseur();
|
||||||
if (Debut_block==Fin_block)
|
if (Debut_block==Fin_block)
|
||||||
|
{
|
||||||
|
if(Palette_mode_RGB)
|
||||||
{
|
{
|
||||||
Modifier_Vert (Fore_color,63-Jauge_verte->Position,Palette_de_travail);
|
Modifier_Vert (Fore_color,63-Jauge_verte->Position,Palette_de_travail);
|
||||||
Num2str(Palette_de_travail[Fore_color].V,Chaine,2);
|
Num2str(Palette_de_travail[Fore_color].V,Chaine,2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte h,l,s;
|
||||||
|
|
||||||
|
rgb2hl(Palette_de_travail[Fore_color].R,Palette_de_travail[Fore_color].V,Palette_de_travail[Fore_color].B,&h,&l,&s);
|
||||||
|
l=(63-Jauge_verte->Position)*4; // Mettre +1 quand on aura modifié la plage du slider
|
||||||
|
HLStoRGB(h,l,s,&Palette_de_travail[Fore_color].R,&Palette_de_travail[Fore_color].V,&Palette_de_travail[Fore_color].B);
|
||||||
|
|
||||||
|
Num2str((int)h>>2,Chaine,2);
|
||||||
|
}
|
||||||
|
Num2str(Palette_de_travail[Fore_color].V,Chaine,2);
|
||||||
Print_dans_fenetre(207,172,Chaine,CM_Noir,CM_Clair);
|
Print_dans_fenetre(207,172,Chaine,CM_Noir,CM_Clair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user