Palette now uses RGB components in the full 0-255 range instead of 0-63.

All palette functions can be used in HSL color space too (multi-select, etc).
Fixed some more missing refreshes in Palette screen.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@368 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2008-12-03 01:03:32 +00:00
parent bee5956c41
commit 14accb544b
15 changed files with 671 additions and 386 deletions

View File

@ -30,7 +30,7 @@
# Windows specific
ifdef COMSPEC
DELCOMMAND = rm -f
MKDIR = mkdir
MKDIR = mkdir -p
RMDIR = rmdir
CP = cp
BIN = grafx2.exe

View File

@ -35,8 +35,8 @@ $(OBJDIR)/palette.o: palette.c const.h struct.h global.h loadsave.h divers.h \
$(OBJDIR)/readini.o: readini.c const.h global.h struct.h loadsave.h graph.h
$(OBJDIR)/readline.o: readline.c const.h struct.h global.h loadsave.h graph.h \
divers.h erreurs.h sdlscreen.h readline.h
$(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h loadsave.h readini.h \
files.h erreurs.h graph.h
$(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h loadsave.h readini.h io.h \
erreurs.h graph.h
$(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h loadsave.h sdlscreen.h \
divers.h erreurs.h graph.h
$(OBJDIR)/setup.o: setup.c struct.h const.h io.h files.h

View File

@ -4362,7 +4362,7 @@ void Calculer_les_tables_de_Colorize(void)
Facteur_A=256*(100-Colorize_Opacite)/100;
Facteur_B=256*( Colorize_Opacite)/100;
for (Indice=0;Indice<64;Indice++)
for (Indice=0;Indice<256;Indice++)
{
Table_de_multiplication_par_Facteur_A[Indice]=Indice*Facteur_A;
Table_de_multiplication_par_Facteur_B[Indice]=Indice*Facteur_B;

View File

@ -81,9 +81,9 @@ void Set_palette(T_Palette Palette)
SDL_Color PaletteSDL[256];
for(i=0;i<256;i++)
{
PaletteSDL[i].r=(Palette[i].R<<2) + (Palette[i].R>>4); //Les couleurs VGA ne vont que de 0 à 63
PaletteSDL[i].g=(Palette[i].V<<2) + (Palette[i].V>>4);
PaletteSDL[i].b=(Palette[i].B<<2) + (Palette[i].B>>4);
PaletteSDL[i].r=Palette[i].R;
PaletteSDL[i].g=Palette[i].V;
PaletteSDL[i].b=Palette[i].B;
}
//SDL_PHYSPAL|
SDL_SetPalette(Ecran_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
@ -92,9 +92,9 @@ void Set_palette(T_Palette Palette)
void Set_color(byte Couleur, byte Rouge, byte Vert, byte Bleu)
{
SDL_Color comp;
comp.r=Rouge << 2;
comp.g=Vert << 2;
comp.b=Bleu << 2;
comp.r=Rouge;
comp.g=Vert;
comp.b=Bleu;
SDL_SetPalette(Ecran_SDL, SDL_LOGPAL, &comp, Couleur, 1);
}
@ -638,9 +638,9 @@ void Palette_64_to_256(T_Palette Palette)
int i;
for(i=0;i<256;i++)
{
Palette[i].R = Palette[i].R << 2;
Palette[i].V = Palette[i].V << 2;
Palette[i].B = Palette[i].B << 2;
Palette[i].R = (Palette[i].R << 2)|(Palette[i].R >> 4);
Palette[i].V = (Palette[i].V << 2)|(Palette[i].V >> 4);
Palette[i].B = (Palette[i].B << 2)|(Palette[i].B >> 4);
}
}

View File

@ -445,8 +445,8 @@ GLOBAL short Trame_Hauteur; // Hauteur de la trame
GLOBAL byte Colorize_Mode; // Le mode Colorize est enclenché
GLOBAL byte Colorize_Opacite; // Intensité du Colorize
GLOBAL byte Colorize_Mode_en_cours; // Le type de Colorize en cours (0-2)
GLOBAL word Table_de_multiplication_par_Facteur_A[64];
GLOBAL word Table_de_multiplication_par_Facteur_B[64];
GLOBAL word Table_de_multiplication_par_Facteur_A[256];
GLOBAL word Table_de_multiplication_par_Facteur_B[256];
// Mode smooth:

197
graph.c
View File

@ -1668,6 +1668,203 @@ void Print_nom_fichier(void)
}
}
// Fonction d'affichage d'une chaine numérique avec une fonte très fine
// Spécialisée pour les compteurs RGB
void Print_compteur(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond)
{
// Macros pour écrire des litteraux binaires.
// Ex: Ob(11110000) == 0xF0
#define Ob(x) ((unsigned)Ob_(0 ## x ## uL))
#define Ob_(x) ((x & 1) | (x >> 2 & 2) | (x >> 4 & 4) | (x >> 6 & 8) | \
(x >> 8 & 16) | (x >> 10 & 32) | (x >> 12 & 64) | (x >> 14 & 128))
byte Caractere[14][8] = {
{ // 0
Ob(00011100),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00011100)
},
{ // 1
Ob(00001100),
Ob(00011100),
Ob(00111100),
Ob(00001100),
Ob(00001100),
Ob(00001100),
Ob(00001100),
Ob(00001100)
},
{ // 2
Ob(00011100),
Ob(00110110),
Ob(00000110),
Ob(00000110),
Ob(00000110),
Ob(00001100),
Ob(00011000),
Ob(00111110)
},
{ // 3
Ob(00011100),
Ob(00110110),
Ob(00000110),
Ob(00001100),
Ob(00000110),
Ob(00000110),
Ob(00110110),
Ob(00011100)
},
{ // 4
Ob(00001100),
Ob(00001100),
Ob(00011000),
Ob(00011000),
Ob(00110000),
Ob(00110100),
Ob(00111110),
Ob(00000100)
},
{ // 5
Ob(00111110),
Ob(00110000),
Ob(00110000),
Ob(00111100),
Ob(00000110),
Ob(00000110),
Ob(00110110),
Ob(00011100)
},
{ // 6
Ob(00011100),
Ob(00110110),
Ob(00110000),
Ob(00111100),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00011100)
},
{ // 7
Ob(00111110),
Ob(00000110),
Ob(00000110),
Ob(00001100),
Ob(00011000),
Ob(00011000),
Ob(00011000),
Ob(00011000)
},
{ // 8
Ob(00011100),
Ob(00110110),
Ob(00110110),
Ob(00011100),
Ob(00110110),
Ob(00110110),
Ob(00110110),
Ob(00011100)
},
{ // 9
Ob(00011100),
Ob(00110110),
Ob(00110110),
Ob(00011110),
Ob(00000110),
Ob(00000110),
Ob(00110110),
Ob(00011100)
},
{ // (espace)
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000)
},
{ // +
Ob(00000000),
Ob(00001000),
Ob(00001000),
Ob(00111110),
Ob(00001000),
Ob(00001000),
Ob(00000000),
Ob(00000000)
},
{ // -
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00111110),
Ob(00000000),
Ob(00000000),
Ob(00000000),
Ob(00000000)
},
{ // +-
Ob(00001000),
Ob(00001000),
Ob(00111110),
Ob(00001000),
Ob(00001000),
Ob(00000000),
Ob(00111110),
Ob(00000000)
} };
word Indice;
short Pos_X;
short Pos_Y;
for (Indice=0;Chaine[Indice]!='\0';Indice++)
{
int Numero_car;
switch(Chaine[Indice])
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
Numero_car=Chaine[Indice]-'0';
break;
case ' ':
default:
Numero_car=10;
break;
case '+':
Numero_car=11;
break;
case '-':
Numero_car=12;
break;
case '±':
Numero_car=13;
break;
}
for (Pos_Y=0;Pos_Y<8;Pos_Y++)
{
for (Pos_X=0;Pos_X<6;Pos_X++)
{
byte Couleur = (Caractere[Numero_car][Pos_Y] & (1 << (6-Pos_X))) ? Couleur_texte:Couleur_fond;
Pixel_dans_fenetre(X+(Indice*6+Pos_X),Y+Pos_Y,Couleur);
}
}
}
UpdateRect(Fenetre_Pos_X+X*Menu_Facteur_X,Fenetre_Pos_Y+Y*Menu_Facteur_Y,strlen(Chaine)*Menu_Facteur_X*6,8*Menu_Facteur_Y);
}
// -- Calcul des différents effets -------------------------------------------

View File

@ -65,6 +65,7 @@ void Print_char_transparent_dans_fenetre(short Pos_X,short Pos_Y,unsigned char C
void Print_dans_menu(char * Chaine, short Position);
void Print_coordonnees(void);
void Print_nom_fichier(void);
void Print_compteur(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond);
byte Aucun_effet(word X,word Y,byte Couleur);
byte Effet_Shade(word X,word Y,byte Couleur);

1
init.c
View File

@ -185,6 +185,7 @@ void Charger_DAT(void)
if (!read_bytes(Handle, Palette_defaut,sizeof(T_Palette)))
Erreur(ERREUR_DAT_CORROMPU);
Palette_64_to_256(Palette_defaut);
if (!read_bytes(Handle, BLOCK_MENU,LARGEUR_MENU*HAUTEUR_MENU))
Erreur(ERREUR_DAT_CORROMPU);

View File

@ -148,9 +148,9 @@ void Palette_fake_24b(T_Palette Palette)
// Génération de la palette
for (Couleur=0;Couleur<256;Couleur++)
{
Palette[Couleur].R=((Couleur & 0xE0)>>5)<<3;
Palette[Couleur].V=((Couleur & 0x1C)>>2)<<3;
Palette[Couleur].B=((Couleur & 0x03)>>0)<<4;
Palette[Couleur].R=((Couleur & 0xE0)>>5)<<5;
Palette[Couleur].V=((Couleur & 0x1C)>>2)<<5;
Palette[Couleur].B=((Couleur & 0x03)>>0)<<6;
}
}
@ -512,8 +512,10 @@ void Charger_image(byte Image)
if (Convert_bitmap_24B_to_256(Brosse,Buffer_image_24b,Brosse_Largeur,Brosse_Hauteur,Principal_Palette))
Erreur_fichier=2;
}
if (!Erreur_fichier)
Palette_256_to_64(Principal_Palette);
//if (!Erreur_fichier)
// Palette_256_to_64(Principal_Palette);
// Normalement plus besoin car 256 color natif, et c'etait probablement
// un bug - yr
}
free(Buffer_image_24b);
@ -625,11 +627,14 @@ void Load_PAL(void)
// Ouverture du fichier
if ((Fichier=fopen(Nom_du_fichier, "rb")))
{
T_Palette Palette_64;
// Initialiser_preview(???); // Pas possible... pas d'image...
// Lecture du fichier dans Principal_Palette
if (read_bytes(Fichier,Principal_Palette,sizeof(T_Palette)))
if (read_bytes(Fichier,Palette_64,sizeof(T_Palette)))
{
Palette_64_to_256(Palette_64);
memcpy(Principal_Palette,Palette_64,sizeof(T_Palette));
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -662,8 +667,11 @@ void Save_PAL(void)
// Ouverture du fichier
if ((Fichier=fopen(Nom_du_fichier,"wb")))
{
T_Palette Palette_64;
memcpy(Palette_64,Principal_Palette,sizeof(T_Palette));
Palette_256_to_64(Palette_64);
// Enregistrement de Principal_Palette dans le fichier
if (! write_bytes(Fichier,Principal_Palette,sizeof(T_Palette)))
if (! write_bytes(Fichier,Palette_64,sizeof(T_Palette)))
{
Erreur_fichier=1;
fclose(Fichier);
@ -763,13 +771,7 @@ void Load_IMG(void)
Initialiser_preview(IMG_Header.Largeur,IMG_Header.Hauteur,Taille_du_fichier,FORMAT_IMG);
if (Erreur_fichier==0)
{
// On commence par passer la palette en 256 comme ça, si la nouvelle
// palette a moins de 256 coul, la précédente ne souffrira pas d'un
// assombrissement préjudiciable.
Palette_64_to_256(Principal_Palette);
// On peut maintenant transférer la nouvelle palette
memcpy(Principal_Palette,IMG_Header.Palette,sizeof(T_Palette));
Palette_256_to_64(Principal_Palette);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -827,9 +829,7 @@ void Save_IMG(void)
IMG_Header.Filler2[23]=0; // Hi(Longueur de la signature)
memcpy(IMG_Header.Filler2+23,"GRAFX2 by SunsetDesign (IMG format taken from PV (c)W.Wiedmann)",64);
Palette_64_to_256(Principal_Palette);
memcpy(IMG_Header.Palette,Principal_Palette,sizeof(T_Palette));
Palette_256_to_64(Principal_Palette);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
IMG_Header.Largeur = SDL_Swap16(IMG_Header.Largeur);
@ -1047,11 +1047,13 @@ void Load_PKM(void)
Initialiser_preview(Head.Largeur,Head.Hauteur,Taille_du_fichier,FORMAT_PKM);
if (Erreur_fichier==0)
{
Principal_Largeur_image=Head.Largeur;
Principal_Hauteur_image=Head.Hauteur;
Taille_image=(dword)(Principal_Largeur_image*Principal_Hauteur_image);
// Palette lue en 64
memcpy(Principal_Palette,Head.Palette,sizeof(T_Palette));
Palette_64_to_256(Principal_Palette);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -1174,6 +1176,7 @@ void Save_PKM(void)
Head.Largeur=Principal_Largeur_image;
Head.Hauteur=Principal_Hauteur_image;
memcpy(Head.Palette,Principal_Palette,sizeof(T_Palette));
Palette_256_to_64(Head.Palette);
// Calcul de la taille du Post-Header
Head.Jump=9; // 6 pour les dimensions de l'ecran + 3 pour la back-color
@ -1679,6 +1682,7 @@ void Load_LBM(void)
Palette_256_to_64(Principal_Palette);
if (Image_HAM)
Adapter_Palette_HAM();
Palette_64_to_256(Principal_Palette);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -1818,9 +1822,6 @@ void Load_LBM(void)
}
else
{
// On restore l'ancienne palette en cas d'erreur...
Palette_256_to_64(Principal_Palette);
// ... ce qui permet de ne renvoyer qu'une erreur 1 (pas de modif)
Erreur_fichier=1;
}
}
@ -1988,9 +1989,7 @@ void Save_LBM(void)
write_bytes(LBM_Fichier,"CMAP",4);
write_dword_be(LBM_Fichier,sizeof(T_Palette));
Palette_64_to_256(Principal_Palette);
write_bytes(LBM_Fichier,Principal_Palette,sizeof(T_Palette));
Palette_256_to_64(Principal_Palette);
write_bytes(LBM_Fichier,"BODY",4);
write_dword_be(LBM_Fichier,0); // On mettra la taille à jour à la fin
@ -2199,8 +2198,6 @@ void Load_BMP(void)
// assombrissement préjudiciable.
if (Config.Clear_palette)
memset(Principal_Palette,0,sizeof(T_Palette));
else
Palette_64_to_256(Principal_Palette);
// On peut maintenant transférer la nouvelle palette
for (Indice=0; Indice<Nb_Couleurs; Indice++)
{
@ -2208,7 +2205,6 @@ void Load_BMP(void)
Principal_Palette[Indice].V=Palette_locale[Indice][1];
Principal_Palette[Indice].B=Palette_locale[Indice][0];
}
Palette_256_to_64(Principal_Palette);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -2459,7 +2455,6 @@ void Save_BMP(void)
// toujours à 0 pour forcer les gens à s'acheter des gros disques
// durs... Comme ça, ça fera passer la pillule lorsqu'on sortira
// Windows 95." ...
Palette_64_to_256(Principal_Palette);
for (Indice=0; Indice<256; Indice++)
{
Palette_locale[Indice][0]=Principal_Palette[Indice].B;
@ -2467,7 +2462,6 @@ void Save_BMP(void)
Palette_locale[Indice][2]=Principal_Palette[Indice].R;
Palette_locale[Indice][3]=0;
}
Palette_256_to_64(Principal_Palette);
if (write_bytes(Fichier,Palette_locale,1024))
{
@ -2740,13 +2734,8 @@ void Load_GIF(void)
{
// Palette globale dispo:
// On commence par passer la palette en 256 comme ça, si la
// nouvelle palette a moins de 256 coul, la précédente ne souffrira
// pas d'un assombrissement préjudiciable.
if (Config.Clear_palette)
memset(Principal_Palette,0,sizeof(T_Palette));
else
Palette_64_to_256(Principal_Palette);
// On peut maintenant charger la nouvelle palette:
if (!(LSDB.Aspect & 0x80))
@ -2767,8 +2756,6 @@ void Load_GIF(void)
for (Indice_de_couleur=0;Indice_de_couleur<Nb_couleurs;Indice_de_couleur++)
read_byte(GIF_Fichier,&Principal_Palette[Indice_de_couleur].B);
}
Palette_256_to_64(Principal_Palette);
Set_palette(Principal_Palette);
}
@ -2830,11 +2817,6 @@ void Load_GIF(void)
Nb_couleurs=(1 << ((IDB.Indicateur & 0x07)+1));
Nb_bits_initial=(IDB.Indicateur & 0x07)+2;
// On commence par passer la palette en 256 comme ça, si la
// nouvelle palette a moins de 256 coul, la précédente ne
// souffrira pas d'un assombrissement préjudiciable.
Palette_64_to_256(Principal_Palette);
if (!(IDB.Indicateur & 0x40))
// Palette dans l'ordre:
for(Indice_de_couleur=0;Indice_de_couleur<Nb_couleurs;Indice_de_couleur++)
@ -2853,8 +2835,6 @@ void Load_GIF(void)
for (Indice_de_couleur=0;Indice_de_couleur<Nb_couleurs;Indice_de_couleur++)
read_byte(GIF_Fichier,&Principal_Palette[Indice_de_couleur].B);
}
Palette_256_to_64(Principal_Palette);
Set_palette(Principal_Palette);
}
@ -3110,8 +3090,6 @@ void Save_GIF(void)
// Le LSDB a été correctement écrit.
// On sauve la palette
Palette_64_to_256(Principal_Palette);
if (write_bytes(GIF_Fichier,Principal_Palette,768))
{
// La palette a été correctement écrite.
@ -3290,7 +3268,6 @@ void Save_GIF(void)
else
Erreur_fichier=1;
Palette_256_to_64(Principal_Palette);
} // On a pu écrire le LSDB
else
Erreur_fichier=1;
@ -3486,8 +3463,6 @@ void Load_PCX(void)
// On prépare la palette à accueillir les valeurs du fichier PCX
if (Config.Clear_palette)
memset(Principal_Palette,0,sizeof(T_Palette));
else
Palette_64_to_256(Principal_Palette);
Nb_couleurs=(dword)(1<<PCX_Header.Plane)<<(PCX_Header.Depth-1);
if (Nb_couleurs>4)
@ -3538,7 +3513,6 @@ void Load_PCX(void)
}
}
}
Palette_256_to_64(Principal_Palette);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -3768,8 +3742,6 @@ void Save_PCX(void)
if ((Fichier=fopen(Nom_du_fichier,"wb")))
{
// On prépare la palette pour écrire les 16 premieres valeurs
Palette_64_to_256(Principal_Palette);
PCX_Header.Manufacturer=10;
PCX_Header.Version=5;
@ -3859,8 +3831,6 @@ void Save_PCX(void)
if (Erreur_fichier)
remove(Nom_du_fichier);
// On remet la palette à son état normal
Palette_256_to_64(Principal_Palette);
}
else
Erreur_fichier=1;
@ -4284,9 +4254,9 @@ void Load_KCF(void)
for (Indice_couleur=0;Indice_couleur<16;Indice_couleur++)
{
Indice=16+(Indice_palette*16)+Indice_couleur;
Principal_Palette[Indice].R=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1 >> 4) << 2);
Principal_Palette[Indice].B=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1 & 15) << 2);
Principal_Palette[Indice].V=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet2 & 15) << 2);
Principal_Palette[Indice].R=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1 >> 4) << 4);
Principal_Palette[Indice].B=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1 & 15) << 4);
Principal_Palette[Indice].V=((Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet2 & 15) << 4);
}
for (Indice=0;Indice<16;Indice++)
@ -4323,16 +4293,16 @@ void Load_KCF(void)
{
case 12: // RRRR BBBB | 0000 VVVV
read_bytes(Fichier,Octet,2);
Principal_Palette[Indice].R=(Octet[0] >> 4) << 2;
Principal_Palette[Indice].B=(Octet[0] & 15) << 2;
Principal_Palette[Indice].V=(Octet[1] & 15) << 2;
Principal_Palette[Indice].R=(Octet[0] >> 4) << 4;
Principal_Palette[Indice].B=(Octet[0] & 15) << 4;
Principal_Palette[Indice].V=(Octet[1] & 15) << 4;
break;
case 24: // RRRR RRRR | VVVV VVVV | BBBB BBBB
read_bytes(Fichier,Octet,3);
Principal_Palette[Indice].R=Octet[0]>>2;
Principal_Palette[Indice].V=Octet[1]>>2;
Principal_Palette[Indice].B=Octet[2]>>2;
Principal_Palette[Indice].R=Octet[0];
Principal_Palette[Indice].V=Octet[1];
Principal_Palette[Indice].B=Octet[2];
}
Indice++;
@ -4396,8 +4366,8 @@ void Save_KCF(void)
for (Indice_couleur=0;Indice_couleur<16;Indice_couleur++)
{
Indice=16+(Indice_palette*16)+Indice_couleur;
Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1=((Principal_Palette[Indice].R>>2)<<4) | (Principal_Palette[Indice].B>>2);
Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet2=Principal_Palette[Indice].V>>2;
Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet1=((Principal_Palette[Indice].R>>4)<<4) | (Principal_Palette[Indice].B>>4);
Buffer.Palette[Indice_palette].Couleur[Indice_couleur].Octet2=Principal_Palette[Indice].V>>4;
}
if (! write_bytes(Fichier,&Buffer,sizeof(T_KCF_Header)))
@ -4423,9 +4393,9 @@ void Save_KCF(void)
for (Indice=0;(Indice<256) && (!Erreur_fichier);Indice++)
{
Octet[0]=Principal_Palette[Indice].R<<2;
Octet[1]=Principal_Palette[Indice].V<<2;
Octet[2]=Principal_Palette[Indice].B<<2;
Octet[0]=Principal_Palette[Indice].R;
Octet[1]=Principal_Palette[Indice].V;
Octet[2]=Principal_Palette[Indice].B;
if (! write_bytes(Fichier,Octet,3))
Erreur_fichier=1;
}
@ -4521,6 +4491,7 @@ void Load_SCx(void)
if (Config.Clear_palette)
memset(Principal_Palette,0,sizeof(T_Palette));
Palette_64_to_256(SCx_Palette);
memcpy(Principal_Palette,SCx_Palette,Taille);
Set_palette(Principal_Palette);
Remapper_fileselect();
@ -4587,6 +4558,10 @@ void Save_SCx(void)
// Ouverture du fichier
if ((Fichier=fopen(Nom_du_fichier,"wb")))
{
T_Palette Palette_64;
memcpy(Palette_64,Principal_Palette,sizeof(T_Palette));
Palette_256_to_64(Palette_64);
memcpy(SCx_Header.Filler1,"RIX3",4);
SCx_Header.Largeur=Principal_Largeur_image;
SCx_Header.Hauteur=Principal_Hauteur_image;
@ -4594,7 +4569,7 @@ void Save_SCx(void)
SCx_Header.Plans=0x00;
if (write_bytes(Fichier,&SCx_Header,sizeof(T_SCx_Header)) &&
write_bytes(Fichier,&Principal_Palette,sizeof(T_Palette)))
write_bytes(Fichier,&Palette_64,sizeof(T_Palette)))
{
Init_ecriture();
@ -4711,9 +4686,9 @@ void PI1_Decoder_palette(byte * Src,byte * Pal)
w=((word)Src[(i*2)+1]<<8) | Src[(i*2)+0];
// Traitement des couleurs rouge, verte et bleue:
Pal[ip++]=(((w & 0x0007) << 1) | ((w & 0x0008) >> 3)) << 2;
Pal[ip++]=(((w & 0x7000) >> 11) | ((w & 0x8000) >> 15)) << 2;
Pal[ip++]=(((w & 0x0700) >> 7) | ((w & 0x0800) >> 11)) << 2;
Pal[ip++]=(((w & 0x0007) << 1) | ((w & 0x0008) >> 3)) << 4;
Pal[ip++]=(((w & 0x7000) >> 11) | ((w & 0x8000) >> 15)) << 4;
Pal[ip++]=(((w & 0x0700) >> 7) | ((w & 0x0800) >> 11)) << 4;
}
}
@ -4735,9 +4710,9 @@ void PI1_Coder_palette(byte * Pal,byte * Dst)
for (i=0;i<16;i++)
{
// Traitement des couleurs rouge, verte et bleue:
w =(((word)Pal[ip] & 0x38) >> 3) | (((word)Pal[ip] & 0x04) << 1); ip++;
w|=(((word)Pal[ip] & 0x38) << 9) | (((word)Pal[ip] & 0x04) << 13); ip++;
w|=(((word)Pal[ip] & 0x38) << 5) | (((word)Pal[ip] & 0x04) << 9); ip++;
w =(((word)(Pal[ip]>>2) & 0x38) >> 3) | (((word)(Pal[ip]>>2) & 0x04) << 1); ip++;
w|=(((word)(Pal[ip]>>2) & 0x38) << 9) | (((word)(Pal[ip]>>2) & 0x04) << 13); ip++;
w|=(((word)(Pal[ip]>>2) & 0x38) << 5) | (((word)(Pal[ip]>>2) & 0x04) << 9); ip++;
Dst[(i*2)+0]=w & 0x00FF;
Dst[(i*2)+1]=(w>>8);

8
op_c.c
View File

@ -34,7 +34,7 @@
void rgb2hl(int r,int g,int b,byte * hr,byte * lr,byte* sr)
void RGBtoHSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
{
double rd,gd,bd,h,s,l,max,min;
@ -103,7 +103,7 @@ void rgb2hl(int r,int g,int b,byte * hr,byte * lr,byte* sr)
*sr = (s*255.0);
}
void HLStoRGB(byte H,byte L,byte S, byte* R, byte* G, byte* B)
void HSLtoRGB(byte H,byte S,byte L, byte* R, byte* G, byte* B)
{
float rf =0 ,gf = 0,bf = 0;
float hf,lf,sf;
@ -156,7 +156,7 @@ void HLStoRGB(byte H,byte L,byte S, byte* R, byte* G, byte* B)
if (bf < 1/6.0)
bf = p + ((q-p)*6*bf);
else if(rf < 0.5)
else if(bf < 0.5)
bf = q;
else if(bf < 2/3.0)
bf = p + ((q-p)*6*(2/3.0-bf));
@ -632,7 +632,7 @@ void Cluster_Calculer_teinte(Cluster * c,Table_occurence * to)
c->r=(cumulR<<to->red_r)/c->occurences;
c->v=(cumulV<<to->red_v)/c->occurences;
c->b=(cumulB<<to->red_b)/c->occurences;
rgb2hl(c->r,c->v,c->b,&c->h,&c->l,&s);
RGBtoHSL(c->r,c->v,c->b,&c->h,&s,&c->l);
}

4
op_c.h
View File

@ -147,8 +147,8 @@ void TC_Delete(Table_conversion * t);
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 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);
void RGBtoHSL(int r, int v,int b, byte* h, byte*s, byte* l);
void HSLtoRGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
/////////////////////////////////////////////////////////////////////////////

663
palette.c

File diff suppressed because it is too large Load Diff

View File

@ -468,9 +468,9 @@ int Charger_INI(struct S_Config * Conf)
Conf->Coul_menu_pref[0].R=0;
Conf->Coul_menu_pref[0].V=0;
Conf->Coul_menu_pref[0].B=0;
Conf->Coul_menu_pref[3].R=63;
Conf->Coul_menu_pref[3].V=63;
Conf->Coul_menu_pref[3].B=63;
Conf->Coul_menu_pref[3].R=255;
Conf->Coul_menu_pref[3].V=255;
Conf->Coul_menu_pref[3].B=255;
if ((Retour=Charger_INI_Get_values (Fichier,Buffer,"Light_color",3,Valeurs)))
goto Erreur_Retour;
@ -480,9 +480,9 @@ int Charger_INI(struct S_Config * Conf)
goto Erreur_ERREUR_INI_CORROMPU;
if ((Valeurs[2]<0) || (Valeurs[2]>63))
goto Erreur_ERREUR_INI_CORROMPU;
Conf->Coul_menu_pref[2].R=Valeurs[0];
Conf->Coul_menu_pref[2].V=Valeurs[1];
Conf->Coul_menu_pref[2].B=Valeurs[2];
Conf->Coul_menu_pref[2].R=(Valeurs[0]<<2)|(Valeurs[0]>>4);
Conf->Coul_menu_pref[2].V=(Valeurs[1]<<2)|(Valeurs[1]>>4);
Conf->Coul_menu_pref[2].B=(Valeurs[2]<<2)|(Valeurs[2]>>4);
if ((Retour=Charger_INI_Get_values (Fichier,Buffer,"Dark_color",3,Valeurs)))
goto Erreur_Retour;
@ -492,9 +492,9 @@ int Charger_INI(struct S_Config * Conf)
goto Erreur_ERREUR_INI_CORROMPU;
if ((Valeurs[2]<0) || (Valeurs[2]>63))
goto Erreur_ERREUR_INI_CORROMPU;
Conf->Coul_menu_pref[1].R=Valeurs[0];
Conf->Coul_menu_pref[1].V=Valeurs[1];
Conf->Coul_menu_pref[1].B=Valeurs[2];
Conf->Coul_menu_pref[1].R=(Valeurs[0]<<2)|(Valeurs[0]>>4);
Conf->Coul_menu_pref[1].V=(Valeurs[1]<<2)|(Valeurs[1]>>4);
Conf->Coul_menu_pref[1].B=(Valeurs[2]<<2)|(Valeurs[2]>>4);
if ((Retour=Charger_INI_Get_values (Fichier,Buffer,"Menu_ratio",1,Valeurs)))
goto Erreur_Retour;

View File

@ -461,15 +461,15 @@ int Sauver_INI(struct S_Config * Conf)
if ((Retour=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[MENU]")))
goto Erreur_Retour;
Valeurs[0]=Conf->Coul_menu_pref[2].R;
Valeurs[1]=Conf->Coul_menu_pref[2].V;
Valeurs[2]=Conf->Coul_menu_pref[2].B;
Valeurs[0]=Conf->Coul_menu_pref[2].R>>2;
Valeurs[1]=Conf->Coul_menu_pref[2].V>>2;
Valeurs[2]=Conf->Coul_menu_pref[2].B>>2;
if ((Retour=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Light_color",3,Valeurs,0)))
goto Erreur_Retour;
Valeurs[0]=Conf->Coul_menu_pref[1].R;
Valeurs[1]=Conf->Coul_menu_pref[1].V;
Valeurs[2]=Conf->Coul_menu_pref[1].B;
Valeurs[0]=Conf->Coul_menu_pref[1].R>>2;
Valeurs[1]=Conf->Coul_menu_pref[1].V>>2;
Valeurs[2]=Conf->Coul_menu_pref[1].B>>2;
if ((Retour=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Dark_color",3,Valeurs,0)))
goto Erreur_Retour;

View File

@ -633,9 +633,9 @@ byte * Surface_en_bytefield(SDL_Surface *Source, byte * Destination)
SDL_Color Conversion_couleur_SDL(byte Index)
{
SDL_Color Couleur;
Couleur.r = (Principal_Palette[Index].R<<2) + (Principal_Palette[Index].R>>4);
Couleur.g = (Principal_Palette[Index].V<<2) + (Principal_Palette[Index].V>>4);
Couleur.b = (Principal_Palette[Index].B<<2) + (Principal_Palette[Index].B>>4);
Couleur.r = Principal_Palette[Index].R;
Couleur.g = Principal_Palette[Index].V;
Couleur.b = Principal_Palette[Index].B;
Couleur.unused = 255;
return Couleur;
}