quantise: fix styling (#2807)
Also, use the correct conditional directive in spngsave.
This commit is contained in:
parent
c5ea747f71
commit
6aca41d713
@ -47,9 +47,7 @@
|
||||
|
||||
#ifdef HAVE_QUANTIZATION
|
||||
|
||||
#include "pforeign.h"
|
||||
|
||||
#if defined(HAVE_IMAGEQUANT)
|
||||
#ifdef HAVE_IMAGEQUANT
|
||||
|
||||
VipsQuantiseAttr *
|
||||
vips__quantise_attr_create()
|
||||
@ -76,19 +74,22 @@ vips__quantise_set_speed(VipsQuantiseAttr* attr, int speed)
|
||||
}
|
||||
|
||||
VipsQuantiseImage *
|
||||
vips__quantise_image_create_rgba(const VipsQuantiseAttr *attr, const void *bitmap, int width, int height, double gamma)
|
||||
vips__quantise_image_create_rgba( const VipsQuantiseAttr *attr,
|
||||
const void *bitmap, int width, int height, double gamma )
|
||||
{
|
||||
return liq_image_create_rgba( attr, bitmap, width, height, gamma );
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_image_quantize(VipsQuantiseImage *const input_image, VipsQuantiseAttr *const options, VipsQuantiseResult **result_output)
|
||||
vips__quantise_image_quantize( VipsQuantiseImage *const input_image,
|
||||
VipsQuantiseAttr *const options, VipsQuantiseResult **result_output )
|
||||
{
|
||||
return liq_image_quantize( input_image, options, result_output );
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_set_dithering_level(VipsQuantiseResult *res, float dither_level)
|
||||
vips__quantise_set_dithering_level( VipsQuantiseResult *res,
|
||||
float dither_level )
|
||||
{
|
||||
return liq_set_dithering_level( res, dither_level );
|
||||
}
|
||||
@ -100,9 +101,11 @@ vips__quantise_get_palette(VipsQuantiseResult *result)
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_write_remapped_image(VipsQuantiseResult *result, VipsQuantiseImage *input_image, void *buffer, size_t buffer_size)
|
||||
vips__quantise_write_remapped_image( VipsQuantiseResult *result,
|
||||
VipsQuantiseImage *input_image, void *buffer, size_t buffer_size )
|
||||
{
|
||||
return liq_write_remapped_image(result, input_image, buffer, buffer_size);
|
||||
return liq_write_remapped_image(
|
||||
result, input_image, buffer, buffer_size );
|
||||
}
|
||||
|
||||
void
|
||||
@ -123,7 +126,7 @@ vips__quantise_attr_destroy(VipsQuantiseAttr *attr)
|
||||
liq_attr_destroy( attr );
|
||||
}
|
||||
|
||||
#elif defined(HAVE_QUANTIZR) /*HAVE_IMAGEQUANT*/
|
||||
#elif defined(HAVE_QUANTIZR) /*!HAVE_IMAGEQUANT*/
|
||||
|
||||
VipsQuantiseAttr *
|
||||
vips__quantise_attr_create()
|
||||
@ -140,32 +143,40 @@ vips__quantise_set_max_colors(VipsQuantiseAttr* attr, int colors)
|
||||
VipsQuantiseError
|
||||
vips__quantise_set_quality( VipsQuantiseAttr *attr, int minimum, int maximum )
|
||||
{
|
||||
// Not supported by quantizr
|
||||
/* Not supported by quantizr
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_set_speed( VipsQuantiseAttr *attr, int speed )
|
||||
{
|
||||
// Not supported by quantizr
|
||||
/* Not supported by quantizr
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
VipsQuantiseImage *
|
||||
vips__quantise_image_create_rgba(const VipsQuantiseAttr *attr, const void *bitmap, int width, int height, double gamma)
|
||||
vips__quantise_image_create_rgba( const VipsQuantiseAttr *attr,
|
||||
const void *bitmap, int width, int height, double gamma )
|
||||
{
|
||||
return quantizr_create_image_rgba((unsigned char*)bitmap, width, height);
|
||||
/* attr and gamma ununused by quantizr
|
||||
*/
|
||||
return quantizr_create_image_rgba(
|
||||
(unsigned char *) bitmap, width, height );
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_image_quantize(VipsQuantiseImage *const input_image, VipsQuantiseAttr *const options, VipsQuantiseResult **result_output)
|
||||
vips__quantise_image_quantize( VipsQuantiseImage *const input_image,
|
||||
VipsQuantiseAttr *const options, VipsQuantiseResult **result_output )
|
||||
{
|
||||
*result_output = quantizr_quantize( input_image, options );
|
||||
return 0;
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_set_dithering_level(VipsQuantiseResult *res, float dither_level)
|
||||
vips__quantise_set_dithering_level( VipsQuantiseResult *res,
|
||||
float dither_level )
|
||||
{
|
||||
return quantizr_set_dithering_level( res, dither_level );
|
||||
}
|
||||
@ -177,7 +188,8 @@ vips__quantise_get_palette(VipsQuantiseResult *result)
|
||||
}
|
||||
|
||||
VipsQuantiseError
|
||||
vips__quantise_write_remapped_image(VipsQuantiseResult *result, VipsQuantiseImage *input_image, void *buffer, size_t buffer_size)
|
||||
vips__quantise_write_remapped_image( VipsQuantiseResult *result,
|
||||
VipsQuantiseImage *input_image, void *buffer, size_t buffer_size )
|
||||
{
|
||||
return quantizr_remap( result, input_image, buffer, buffer_size );
|
||||
}
|
||||
@ -200,7 +212,7 @@ vips__quantise_attr_destroy(VipsQuantiseAttr *attr)
|
||||
quantizr_free_options( attr );
|
||||
}
|
||||
|
||||
#endif /*HAVE_QUANTIZR*/
|
||||
#endif /*HAVE_IMAGEQUANT*/
|
||||
|
||||
/* Track during a quantisation.
|
||||
*/
|
||||
|
@ -60,14 +60,20 @@ extern "C" {
|
||||
|
||||
#ifdef HAVE_QUANTIZATION
|
||||
VipsQuantiseAttr *vips__quantise_attr_create();
|
||||
VipsQuantiseError vips__quantise_set_max_colors(VipsQuantiseAttr* attr, int colors);
|
||||
VipsQuantiseError vips__quantise_set_quality(VipsQuantiseAttr* attr, int minimum, int maximum);
|
||||
VipsQuantiseError vips__quantise_set_max_colors( VipsQuantiseAttr *attr,
|
||||
int colors );
|
||||
VipsQuantiseError vips__quantise_set_quality( VipsQuantiseAttr *attr,
|
||||
int minimum, int maximum );
|
||||
VipsQuantiseError vips__quantise_set_speed( VipsQuantiseAttr *attr, int speed );
|
||||
VipsQuantiseImage* vips__quantise_image_create_rgba(const VipsQuantiseAttr *attr, const void *bitmap, int width, int height, double gamma);
|
||||
VipsQuantiseError vips__quantise_image_quantize(VipsQuantiseImage *const input_image, VipsQuantiseAttr *const options, VipsQuantiseResult **result_output);
|
||||
VipsQuantiseError vips__quantise_set_dithering_level(VipsQuantiseResult *res, float dither_level);
|
||||
VipsQuantiseImage *vips__quantise_image_create_rgba( const VipsQuantiseAttr *attr,
|
||||
const void *bitmap, int width, int height, double gamma );
|
||||
VipsQuantiseError vips__quantise_image_quantize( VipsQuantiseImage *input_image,
|
||||
VipsQuantiseAttr *options, VipsQuantiseResult **result_output );
|
||||
VipsQuantiseError vips__quantise_set_dithering_level( VipsQuantiseResult *res,
|
||||
float dither_level );
|
||||
const VipsQuantisePalette *vips__quantise_get_palette( VipsQuantiseResult *result );
|
||||
VipsQuantiseError vips__quantise_write_remapped_image(VipsQuantiseResult *result, VipsQuantiseImage *input_image, void *buffer, size_t buffer_size);
|
||||
VipsQuantiseError vips__quantise_write_remapped_image( VipsQuantiseResult *result,
|
||||
VipsQuantiseImage *input_image, void *buffer, size_t buffer_size );
|
||||
void vips__quantise_result_destroy( VipsQuantiseResult *result );
|
||||
void vips__quantise_image_destroy( VipsQuantiseImage *img );
|
||||
void vips__quantise_attr_destroy( VipsQuantiseAttr *attr );
|
||||
|
@ -374,7 +374,7 @@ vips_foreign_save_spng_write( VipsForeignSaveSpng *spng, VipsImage *in )
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#ifdef HAVE_IMAGEQUANT
|
||||
#ifdef HAVE_QUANTIZATION
|
||||
if( spng->palette ) {
|
||||
VipsImage *im_index;
|
||||
VipsImage *im_palette;
|
||||
@ -424,7 +424,7 @@ vips_foreign_save_spng_write( VipsForeignSaveSpng *spng, VipsImage *in )
|
||||
|
||||
in = spng->memory = im_index;
|
||||
}
|
||||
#endif /*HAVE_IMAGEQUANT*/
|
||||
#endif /*HAVE_QUANTIZATION*/
|
||||
|
||||
ihdr.width = in->Xsize;
|
||||
ihdr.height = in->Ysize;
|
||||
@ -494,13 +494,13 @@ vips_foreign_save_spng_write( VipsForeignSaveSpng *spng, VipsImage *in )
|
||||
vips_foreign_save_spng_metadata( spng, in ) )
|
||||
return( -1 );
|
||||
|
||||
#ifdef HAVE_IMAGEQUANT
|
||||
#ifdef HAVE_QUANTIZATION
|
||||
if( spng->palette ) {
|
||||
spng_set_plte( spng->ctx, &plte );
|
||||
if( trns.n_type3_entries )
|
||||
spng_set_trns( spng->ctx, &trns );
|
||||
}
|
||||
#endif /*HAVE_IMAGEQUANT*/
|
||||
#endif /*HAVE_QUANTIZATION*/
|
||||
|
||||
/* SPNG_FMT_PNG is a special value that matches the format in ihdr
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user