tiny code format changes
This commit is contained in:
parent
e16cb5bfe5
commit
f2dd4471eb
@ -113,8 +113,9 @@ vips__quantise_image( VipsImage *in,
|
|||||||
VipsImage *index;
|
VipsImage *index;
|
||||||
VipsImage *palette;
|
VipsImage *palette;
|
||||||
const liq_palette *lp;
|
const liq_palette *lp;
|
||||||
int i;
|
gint64 i;
|
||||||
gboolean added_alpha = FALSE;
|
VipsPel * restrict p;
|
||||||
|
gboolean added_alpha;
|
||||||
|
|
||||||
quantise = vips__quantise_new( in, index_out, palette_out,
|
quantise = vips__quantise_new( in, index_out, palette_out,
|
||||||
colours, Q, dither, effort );
|
colours, Q, dither, effort );
|
||||||
@ -132,6 +133,7 @@ vips__quantise_image( VipsImage *in,
|
|||||||
|
|
||||||
/* Add alpha channel if missing.
|
/* Add alpha channel if missing.
|
||||||
*/
|
*/
|
||||||
|
added_alpha = FALSE;
|
||||||
if( !vips_image_hasalpha( in ) ) {
|
if( !vips_image_hasalpha( in ) ) {
|
||||||
if( vips_bandjoin_const1( in, &quantise->t[1], 255, NULL ) ) {
|
if( vips_bandjoin_const1( in, &quantise->t[1], 255, NULL ) ) {
|
||||||
vips__quantise_free( quantise );
|
vips__quantise_free( quantise );
|
||||||
@ -149,11 +151,11 @@ vips__quantise_image( VipsImage *in,
|
|||||||
|
|
||||||
/* Threshold alpha channel.
|
/* Threshold alpha channel.
|
||||||
*/
|
*/
|
||||||
if( threshold_alpha && !added_alpha ) {
|
if( threshold_alpha &&
|
||||||
VipsPel * restrict p = VIPS_IMAGE_ADDR( in, 0, 0 );
|
!added_alpha ) {
|
||||||
const guint64 n_pels = VIPS_IMAGE_N_PELS( in );
|
const guint64 n_pels = VIPS_IMAGE_N_PELS( in );
|
||||||
guint64 i;
|
|
||||||
|
|
||||||
|
p = VIPS_IMAGE_ADDR( in, 0, 0 );
|
||||||
for( i = 0; i < n_pels; i++ ) {
|
for( i = 0; i < n_pels; i++ ) {
|
||||||
p[3] = p[3] > 128 ? 255 : 0;
|
p[3] = p[3] > 128 ? 255 : 0;
|
||||||
p += 4;
|
p += 4;
|
||||||
@ -207,13 +209,14 @@ vips__quantise_image( VipsImage *in,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = VIPS_IMAGE_ADDR( palette, 0, 0 );
|
||||||
for( i = 0; i < lp->count; i++ ) {
|
for( i = 0; i < lp->count; i++ ) {
|
||||||
unsigned char *p = VIPS_IMAGE_ADDR( palette, i, 0 );
|
|
||||||
|
|
||||||
p[0] = lp->entries[i].r;
|
p[0] = lp->entries[i].r;
|
||||||
p[1] = lp->entries[i].g;
|
p[1] = lp->entries[i].g;
|
||||||
p[2] = lp->entries[i].b;
|
p[2] = lp->entries[i].b;
|
||||||
p[3] = lp->entries[i].a;
|
p[3] = lp->entries[i].a;
|
||||||
|
|
||||||
|
p += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
*index_out = index;
|
*index_out = index;
|
||||||
@ -234,10 +237,10 @@ vips__quantise_image( VipsImage *in,
|
|||||||
int colours, int Q, double dither, int effort,
|
int colours, int Q, double dither, int effort,
|
||||||
gboolean threshold_alpha )
|
gboolean threshold_alpha )
|
||||||
{
|
{
|
||||||
vips_error( "vips__quantise_image",
|
vips_error( "vips__quantise_image",
|
||||||
"%s", _( "libvips not built with quantisation support" ) );
|
"%s", _( "libvips not built with quantisation support" ) );
|
||||||
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*HAVE_IMAGEQUANT*/
|
#endif /*HAVE_IMAGEQUANT*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user