diff --git a/src/op_c.c b/src/op_c.c index e9366638..022216f0 100644 --- a/src/op_c.c +++ b/src/op_c.c @@ -1238,7 +1238,7 @@ int Modified_value(int value,int modif) } -/// Convert a 24b image to 256 colors (with a given palette and conversion table) +/// Convert a 24b image to 256 colors (with a given palette and conversion table). /// This destroys the 24b picture ! /// Uses floyd steinberg dithering. void Convert_24b_bitmap_to_256_Floyd_Steinberg(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette,CT_Tree* tc) @@ -1425,7 +1425,15 @@ static const byte precision_24b[]= 3,3,2}; -// Give this one a 24b source, get back the 256c bitmap and its palette +/** + * Converts a 24 bit picture to 256 color (color reduction) + * @param[out] dest The converted 8bpp picture + * @param[in] source the 24bpp picture + * @param[in] width the width of the picture + * @param[in] height the height of the picture + * @param[out] palette the palette of the converted 8bpp picture + * @return 0 for OK, 1 for error + */ int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette) { #if !(defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)) diff --git a/src/op_c.h b/src/op_c.h index f766cc29..f81d6024 100644 --- a/src/op_c.h +++ b/src/op_c.h @@ -41,6 +41,13 @@ typedef byte * T_Bitmap256; ///////////////////////////////////////// Définition d'une table d'occurences +/** + * Occurence table. + * + * This table is used to count the occurrence of an (RGB) pixel value in the + * source 24bit image. These count are then used by the median cut algorithm to + * decide which cluster to split. + */ typedef struct { int nbb_r; // Nb de bits de précision sur les rouges @@ -66,23 +73,26 @@ typedef struct ///////////////////////////////////////// Définition d'un ensemble de couleur +/** + * informations used while median-cutting. + */ struct S_Cluster_CutData { - // informations used while median-cutting - int volume; // volume of narrow covering (without margins where there are no pixels) - int sqdiag; // square of diagonal length (without margins) + int volume; ///< volume of narrow covering (without margins where there are no pixels) + int sqdiag; ///< square of diagonal length (without margins) - // Widest component : 0 red, 1 green, 2 blue + /// Widest component : 0 red, 1 green, 2 blue byte plus_large; - }; +/** + * information used while color reducing + */ struct S_Cluster_PalData { - // information used while color reducing - byte r,g,b; // color synthétisant l'ensemble - byte h; // Chrominance - byte l; // Luminosité + byte r,g,b; ///< color synthétisant l'ensemble + byte h; ///< Hue / Chrominance + byte l; ///< Luminosity / Luminosité }; union U_Cluster_Data @@ -91,6 +101,9 @@ union U_Cluster_Data struct S_Cluster_PalData pal; }; +/** + * Color cluster + */ typedef struct S_Cluster { struct S_Cluster* next; @@ -113,6 +126,9 @@ typedef struct S_Cluster //////////////////////////////////////// Définition d'un ensemble de clusters +/** + * Cluster set + */ typedef struct { int nb; @@ -124,6 +140,9 @@ typedef struct ///////////////////////////////////////////////////// Définition d'un dégradé +/** + * Gradient + */ typedef struct { int nb_colors; // Nombre de couleurs dans le dégradé @@ -193,12 +212,5 @@ T_Gradient_set * GS_New(T_Cluster_set * cs); void GS_Delete(T_Gradient_set * ds); void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs); - - -// Convertie avec le plus de précision possible une image 24b en 256c -// Renvoie s'il y a eu une erreur ou pas.. int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette); - - - #endif