# op_c.c File Reference

`#include <unistd.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <fcntl.h>`
`#include <sys/stat.h>`
`#include <math.h>`
`#include "op_c.h"`
`#include "erreurs.h"`

## Functions
void | RGBtoHSL (int r, int g, int b, byte *hr, byte *sr, byte *lr)
void | HSLtoRGB (byte H, byte S, byte L, byte *R, byte *G, byte *B)
Table_conversion * | TC_New (int nbb_r, int nbb_v, int nbb_b)
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 | TO_Init (Table_occurence *t)
Table_occurence * | TO_New (int nbb_r, int nbb_v, int nbb_b)
void | TO_Delete (Table_occurence *t)
int | TO_Get (Table_occurence *t, int r, int v, int b)
void | TO_Set (Table_occurence *t, int r, int v, int b, int i)
void | TO_Inc (Table_occurence *t, int r, int v, int b)
void | TO_Compter_occurences (Table_occurence *t, Bitmap24B image, int taille)
int | TO_Compter_couleurs (Table_occurence *t)
void | Cluster_Analyser (Cluster *c, Table_occurence *to)
void | Cluster_Split (Cluster *c, Cluster *c1, Cluster *c2, int teinte, Table_occurence *to)
void | Cluster_Calculer_teinte (Cluster *c, Table_occurence *to)
void | CS_Init (ClusterSet *cs, Table_occurence *to)
ClusterSet * | CS_New (int nbmax, Table_occurence *to)
void | CS_Delete (ClusterSet *cs)
void | CS_Get (ClusterSet *cs, Cluster *c)
void | CS_Set (ClusterSet *cs, Cluster *c)
void | CS_Generer (ClusterSet *cs, Table_occurence *to)
void | CS_Calculer_teintes (ClusterSet *cs, Table_occurence *to)
void | CS_Trier_par_chrominance (ClusterSet *cs)
void | CS_Trier_par_luminance (ClusterSet *cs)
void | CS_Generer_TC_et_Palette (ClusterSet *cs, Table_conversion *tc, struct Composantes *palette)
void | DS_Init (DegradeSet *ds, ClusterSet *cs)
DegradeSet * | DS_New (ClusterSet *cs)
void | DS_Delete (DegradeSet *ds)
void | DS_Generer (DegradeSet *ds, ClusterSet *cs)
Table_conversion * | Optimiser_palette (Bitmap24B image, int taille, struct Composantes *palette, int r, int v, int b)
int | Valeur_modifiee (int valeur, int modif)
void | Convert_bitmap_24B_to_256_Floyd_Steinberg (Bitmap256 Dest, Bitmap24B Source, int largeur, int hauteur, struct Composantes *palette, Table_conversion *tc)
int | Convert_bitmap_24B_to_256 (Bitmap256 Dest, Bitmap24B Source, int largeur, int hauteur, struct Composantes *palette)
## Variables
static const byte | precision_24b []

## Function Documentation

void RGBtoHSL | ( | int | r,
|  | int | g,
|  | int | b,
|  | byte * | hr,
|  | byte * | sr,
|  | byte * | lr |
| ) |  |  |

Referenced by Afficher_les_jauges(), Bouton_Palette(), Cluster_Calculer_teinte(), Modifier_HSL(), and Palette_Reafficher_jauges().

void HSLtoRGB | ( | byte | H,
|  | byte | S,
|  | byte | L,
|  | byte * | R,
|  | byte * | G,
|  | byte * | B |
| ) |  |  |

Referenced by Bouton_Palette(), and Modifier_HSL().

Table_conversion* TC_New | ( | int | nbb_r,
|  | int | nbb_v,
|  | int | nbb_b |
| ) |  |  |

References Table_conversion::dec_b, Table_conversion::dec_r, Table_conversion::dec_v, Table_conversion::nbb_b, Table_conversion::nbb_r, Table_conversion::nbb_v, Table_conversion::red_b, Table_conversion::red_r, Table_conversion::red_v, Table_conversion::rng_b, Table_conversion::rng_r, Table_conversion::rng_v, and Table_conversion::table.

Referenced by Optimiser_palette().

void TC_Delete | ( | Table_conversion * | t | ) |

References Table_conversion::table.

Referenced by Convert_bitmap_24B_to_256(), and Optimiser_palette().

byte TC_Get | ( | Table_conversion * | t,
|  | int | r,
|  | int | v,
|  | int | b |
| ) |  |  |

References Table_conversion::dec_b, Table_conversion::dec_r, Table_conversion::dec_v, Table_conversion::red_b, Table_conversion::red_r, Table_conversion::red_v, and Table_conversion::table.

Referenced by Convert_bitmap_24B_to_256_Floyd_Steinberg().

void TC_Set | ( | Table_conversion * | t,
|  | int | r,
|  | int | v,
|  | int | b,
|  | byte | i |
| ) |  |  |

References Table_conversion::dec_b, Table_conversion::dec_r, Table_conversion::dec_v, and Table_conversion::table.

Referenced by CS_Generer_TC_et_Palette().

void TO_Init | ( | Table_occurence * | t | ) |

References Table_occurence::rng_b, Table_occurence::rng_r, Table_occurence::rng_v, and Table_occurence::table.

Referenced by TO_New().

Table_occurence* TO_New | ( | int | nbb_r,
|  | int | nbb_v,
|  | int | nbb_b |
| ) |  |  |

References Table_occurence::dec_b, Table_occurence::dec_r, Table_occurence::dec_v, Table_occurence::nbb_b, Table_occurence::nbb_r, Table_occurence::nbb_v, Table_occurence::red_b, Table_occurence::red_r, Table_occurence::red_v, Table_occurence::rng_b, Table_occurence::rng_r, Table_occurence::rng_v, Table_occurence::table, and TO_Init().

Referenced by Optimiser_palette().

void TO_Delete | ( | Table_occurence * | t | ) |

References Table_occurence::table.

Referenced by Optimiser_palette().

int TO_Get | ( | Table_occurence * | t,
|  | int | r,
|  | int | v,
|  | int | b |
| ) |  |  |

References Table_occurence::dec_b, Table_occurence::dec_r, Table_occurence::dec_v, and Table_occurence::table.

Referenced by Cluster_Calculer_teinte().

void TO_Set | ( | Table_occurence * | t,
|  | int | r,
|  | int | v,
|  | int | b,
|  | int | i |
| ) |  |  |

References Table_occurence::dec_b, Table_occurence::dec_r, Table_occurence::dec_v, Table_occurence::red_b, Table_occurence::red_r, Table_occurence::red_v, and Table_occurence::table.

void TO_Inc | ( | Table_occurence * | t,
|  | int | r,
|  | int | v,
|  | int | b |
| ) |  |  |

References Table_occurence::dec_b, Table_occurence::dec_r, Table_occurence::dec_v, Table_occurence::red_b, Table_occurence::red_r, Table_occurence::red_v, and Table_occurence::table.

Referenced by TO_Compter_occurences().

void TO_Compter_occurences | ( | Table_occurence * | t,
|  | Bitmap24B | image,
|  | int | taille |
| ) |  |  |

References TO_Inc().

Referenced by Optimiser_palette().

int TO_Compter_couleurs | ( | Table_occurence * | t | ) |

References Table_occurence::rng_b, Table_occurence::rng_r, Table_occurence::rng_v, and Table_occurence::table.

Referenced by CS_New().

void Cluster_Analyser | ( | Cluster * | c,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster::bmax, Cluster::bmin, Cluster::occurences, Cluster::plus_large, Cluster::rmax, Cluster::rmin, Table_occurence::table, Cluster::vmax, and Cluster::vmin.

Referenced by CS_Generer(), and CS_Init().

void Cluster_Split | ( | Cluster * | c,
|  | Cluster * | c1,
|  | Cluster * | c2,
|  | int | teinte,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster::bmax, Cluster::Bmax, Cluster::Bmin, Cluster::bmin, Cluster::occurences, Cluster::rmax, Cluster::Rmax, Cluster::Rmin, Cluster::rmin, Table_occurence::table, Cluster::vmax, Cluster::Vmax, Cluster::Vmin, and Cluster::vmin.

Referenced by CS_Generer().

void Cluster_Calculer_teinte | ( | Cluster * | c,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster::b, Cluster::bmin, Cluster::h, Cluster::l, Cluster::occurences, Cluster::r, Table_occurence::red_b, Table_occurence::red_r, Table_occurence::red_v, RGBtoHSL(), Cluster::rmin, TO_Get(), Cluster::v, and Cluster::vmin.

Referenced by CS_Calculer_teintes().

void CS_Init | ( | ClusterSet * | cs,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster::bmax, Cluster::Bmax, Cluster::bmin, Cluster::Bmin, Cluster_Analyser(), ClusterSet::clusters, ClusterSet::nb, Cluster::rmax, Cluster::Rmax, Cluster::rmin, Cluster::Rmin, Table_occurence::rng_b, Table_occurence::rng_r, Table_occurence::rng_v, Cluster::vmax, Cluster::Vmax, Cluster::vmin, and Cluster::Vmin.

Referenced by CS_New().

ClusterSet* CS_New | ( | int | nbmax,
|  | Table_occurence * | to |
| ) |  |  |

References ClusterSet::clusters, CS_Init(), ClusterSet::nbmax, and TO_Compter_couleurs().

Referenced by Optimiser_palette().

void CS_Delete | ( | ClusterSet * | cs | ) |

References ClusterSet::clusters.

Referenced by Optimiser_palette().

void CS_Get | ( | ClusterSet * | cs,
|  | Cluster * | c |
| ) |  |  |

References Cluster::bmax, Cluster::bmin, ClusterSet::clusters, ClusterSet::nb, Cluster::rmax, Cluster::rmin, Cluster::vmax, and Cluster::vmin.

Referenced by CS_Generer().

void CS_Set | ( | ClusterSet * | cs,
|  | Cluster * | c |
| ) |  |  |

References ClusterSet::clusters, ClusterSet::nb, and Cluster::occurences.

Referenced by CS_Generer().

void CS_Generer | ( | ClusterSet * | cs,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster_Analyser(), Cluster_Split(), CS_Get(), CS_Set(), ClusterSet::nb, ClusterSet::nbmax, Cluster::occurences, and Cluster::plus_large.

Referenced by Optimiser_palette().

void CS_Calculer_teintes | ( | ClusterSet * | cs,
|  | Table_occurence * | to |
| ) |  |  |

References Cluster_Calculer_teinte(), and ClusterSet::clusters.

Referenced by Optimiser_palette().

void CS_Trier_par_chrominance | ( | ClusterSet * | cs | ) |

References ClusterSet::clusters, Cluster::h, ClusterSet::nb, and ClusterSet::nbmax.

Referenced by Optimiser_palette().

void CS_Trier_par_luminance | ( | ClusterSet * | cs | ) |

References ClusterSet::clusters, Cluster::l, ClusterSet::nb, and ClusterSet::nbmax.

Referenced by Optimiser_palette().

void CS_Generer_TC_et_Palette | ( | ClusterSet * | cs,
|  | Table_conversion * | tc,
|  | struct Composantes * | palette |
| ) |  |  |

References Cluster::b, Cluster::Bmin, ClusterSet::clusters, ClusterSet::nb, Cluster::r, Cluster::Rmin, TC_Set(), Cluster::v, and Cluster::Vmin.

Referenced by Optimiser_palette().

void DS_Init | ( | DegradeSet * | ds,
|  | ClusterSet * | cs |
| ) |  |  |

References ClusterSet::clusters, DegradeSet::degrades, Cluster::h, Degrade::hue, Degrade::max, Degrade::min, DegradeSet::nb, and Degrade::nbcouleurs.

Referenced by DS_New().

DegradeSet* DS_New | ( | ClusterSet * | cs | ) |

References DegradeSet::degrades, DS_Init(), ClusterSet::nbmax, and DegradeSet::nbmax.

Referenced by Optimiser_palette().

void DS_Delete | ( | DegradeSet * | ds | ) |

References DegradeSet::degrades.

Referenced by Optimiser_palette().

void DS_Generer | ( | DegradeSet * | ds,
|  | ClusterSet * | cs |
| ) |  |  |

References ClusterSet::clusters, DegradeSet::degrades, Cluster::h, Degrade::hue, Degrade::max, Degrade::min, DegradeSet::nb, ClusterSet::nb, and Degrade::nbcouleurs.

Referenced by Optimiser_palette().

Table_conversion* Optimiser_palette | ( | Bitmap24B | image,
|  | int | taille,
|  | struct Composantes * | palette,
|  | int | r,
|  | int | v,
|  | int | b |
| ) |  |  |

References CS_Calculer_teintes(), CS_Delete(), CS_Generer(), CS_Generer_TC_et_Palette(), CS_New(), CS_Trier_par_chrominance(), CS_Trier_par_luminance(), DS_Delete(), DS_Generer(), DS_New(), TC_Delete(), TC_New(), TO_Compter_occurences(), TO_Delete(), and TO_New().

Referenced by Convert_bitmap_24B_to_256().

int Valeur_modifiee | ( | int | valeur,
|  | int | modif |
| ) |  |  |

Referenced by Convert_bitmap_24B_to_256_Floyd_Steinberg().

void Convert_bitmap_24B_to_256_Floyd_Steinberg | ( | Bitmap256 | Dest,
|  | Bitmap24B | Source,
|  | int | largeur,
|  | int | hauteur,
|  | struct Composantes * | palette,
|  | Table_conversion * | tc |
| ) |  |  |

References TC_Get(), and Valeur_modifiee().

Referenced by Convert_bitmap_24B_to_256().

int Convert_bitmap_24B_to_256 | ( | Bitmap256 | Dest,
|  | Bitmap24B | Source,
|  | int | largeur,
|  | int | hauteur,
|  | struct Composantes * | palette |
| ) |  |  |

References Convert_bitmap_24B_to_256_Floyd_Steinberg(), Optimiser_palette(), precision_24b, and TC_Delete().

Referenced by Charger_image().

## Variable Documentation

const byte precision_24b[]`[static]`

Initial value:

    {
     8,8,8,
     6,6,6,
     6,6,5,
     5,6,5,
     5,5,5,
     5,5,4,
     4,5,4,
     4,4,4,
     4,4,3,
     3,4,3,
     3,3,3,
     3,3,2}

Referenced by Convert_bitmap_24B_to_256().