static void makemap_addi(i_quantize *, i_img **imgs, int count);
static void makemap_mediancut(i_quantize *, i_img **imgs, int count);
+static void makemap_mono(i_quantize *);
static
void
*/
/*
-=item i_quant_makemap(quant, imgs, count)
+=item i_quant_makemap(C<quant>, C<imgs>, C<count>)
=category Image quantization
-Analyzes the I<count> images in I<imgs> according to the rules in
-I<quant> to build a color map (optimal or not depending on
-quant->make_colors).
+Analyzes the C<count> images in C<imgs> according to the rules in
+C<quant> to build a color map (optimal or not depending on
+C<< quant->make_colors >>).
=cut
*/
makemap_mediancut(quant, imgs, count);
break;
+ case mc_mono:
+ makemap_mono(quant);
+ break;
+
case mc_addi:
default:
makemap_addi(quant, imgs, count);
static void translate_addi(i_quantize *, i_img *, i_palidx *);
/*
-=item i_quant_translate(quant, img)
+=item i_quant_translate(C<quant>, C<img>)
=category Image quantization
-Quantize the image given the palette in quant.
+Quantize the image given the palette in C<quant>.
-On success returns a pointer to a memory block of img->xsize *
-img->ysize i_palidx entries.
+On success returns a pointer to a memory block of C<< img->xsize *
+img->ysize >> C<i_palidx> entries.
On failure returns NULL.
color_count = 1;
while (color_count < quant->mc_size) {
- int max_index, max_ch; /* index/channel with biggest spread */
+ /* initialized to avoid compiler warnings */
+ int max_index = 0, max_ch = 0; /* index/channel with biggest spread */
int max_size;
medcut_partition *workpart;
int cum_total;
i_mempool_destroy(&mp);
}
+static void
+makemap_mono(i_quantize *quant) {
+ quant->mc_colors[0].rgba.r = 0;
+ quant->mc_colors[0].rgba.g = 0;
+ quant->mc_colors[0].rgba.b = 0;
+ quant->mc_colors[0].rgba.a = 255;
+ quant->mc_colors[1].rgba.r = 255;
+ quant->mc_colors[1].rgba.g = 255;
+ quant->mc_colors[1].rgba.b = 255;
+ quant->mc_colors[1].rgba.a = 255;
+ quant->mc_count = 2;
+}
+
#define pboxjump 32
/* Define one of the following 4 symbols to choose a colour search method
#endif
static void translate_addi(i_quantize *quant, i_img *img, i_palidx *out) {
- int x, y, i, k, bst_idx;
+ int x, y, i, k, bst_idx = 0;
i_color val;
int pixdev = quant->perturb;
CF_VARS;
int errw;
int difftotal;
int x, y, dx, dy;
- int bst_idx;
+ int bst_idx = 0;
CF_VARS;
if ((quant->errdiff & ed_mask) == ed_custom) {
static void transparent_ordered(i_quantize *, i_palidx *, i_img *, i_palidx);
/*
-=item i_quant_transparent(quant, data, img, trans_index)
+=item i_quant_transparent(C<quant>, C<data>, C<img>, C<trans_index>)
=category Image quantization
-Dither the alpha channel on I<img> into the palette indexes in
-I<data>. Pixels to be transparent are replaced with I<trans_pixel>.
+Dither the alpha channel on C<img> into the palette indexes in
+C<data>. Pixels to be transparent are replaced with C<trans_pixel>.
-The method used depends on the tr_* members of quant.
+The method used depends on the tr_* members of C<quant>.
=cut
*/