better gif load via magick7
This commit is contained in:
parent
6d217f6f68
commit
422b029602
15
TODO
15
TODO
@ -1,17 +1,6 @@
|
|||||||
- try:
|
- try a gif with transparency
|
||||||
|
|
||||||
vips magickload images/cramps.gif x.png
|
- try loading a PNG
|
||||||
|
|
||||||
we get a four-band png with a strange alpha ... should be 0/255, but it has
|
|
||||||
greyscale values in
|
|
||||||
|
|
||||||
try with convert, get a one-band png, no alpha at all
|
|
||||||
|
|
||||||
solution: cramps.gif is tagged as ImageType 4, palette image (not palette
|
|
||||||
alpha) ... the four channels are RGB + index, index is 0 - 15, the index
|
|
||||||
values for the gif
|
|
||||||
|
|
||||||
we'll need a separate path for each imagetype :-(
|
|
||||||
|
|
||||||
- try loading a DICOM
|
- try loading a DICOM
|
||||||
|
|
||||||
|
@ -316,8 +316,21 @@ vips_foreign_load_magick7_parse( VipsForeignLoadMagick7 *magick7,
|
|||||||
*/
|
*/
|
||||||
out->Xsize = image->columns;
|
out->Xsize = image->columns;
|
||||||
out->Ysize = image->rows;
|
out->Ysize = image->rows;
|
||||||
out->Bands = GetPixelChannels( image );
|
|
||||||
magick7->frame_height = image->rows;
|
magick7->frame_height = image->rows;
|
||||||
|
out->Bands = GetPixelChannels( image );
|
||||||
|
|
||||||
|
switch( GetImageType( image ) ) {
|
||||||
|
case PaletteType:
|
||||||
|
case PaletteAlphaType:
|
||||||
|
case PaletteBilevelAlphaType:
|
||||||
|
/* Palette images include an index channel, which we drop.
|
||||||
|
*/
|
||||||
|
out->Bands -= 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
/* Depth can be 'fractional'. You'd think we should use
|
/* Depth can be 'fractional'. You'd think we should use
|
||||||
* GetImageDepth() but that seems to compute something very complex.
|
* GetImageDepth() but that seems to compute something very complex.
|
||||||
@ -451,28 +464,27 @@ vips_foreign_load_magick7_parse( VipsForeignLoadMagick7 *magick7,
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNPACK( TYPE, Q, P ) { \
|
/* We don't bother with GetPixelReadMask((), assume it's everywhere. Don't
|
||||||
TYPE * restrict tq = (TYPE *) (Q); \
|
* bother with traits, assume taht's always update.
|
||||||
|
*
|
||||||
|
* We do skip index channels. Palette images add extra index channels
|
||||||
|
* containing the index value from the file before colourmap lookup.
|
||||||
|
*/
|
||||||
|
#define UNPACK( TYPE ) { \
|
||||||
|
TYPE * restrict tq = (TYPE *) q; \
|
||||||
int x; \
|
int x; \
|
||||||
int b; \
|
int b; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < r->width; x++ ) { \
|
for( x = 0; x < r->width; x++ ) { \
|
||||||
if( GetPixelReadMask( image, (P) ) ) { \
|
for( b = 0; b < GetPixelChannels( image ); b++ ) { \
|
||||||
for( b = 0; b < GetPixelChannels( image ); b++ ) { \
|
PixelChannel channel = \
|
||||||
PixelChannel channel = \
|
GetPixelChannelChannel( image, b ); \
|
||||||
GetPixelChannelChannel( image, b ); \
|
\
|
||||||
PixelTrait traits = \
|
if( channel != IndexPixelChannel ) \
|
||||||
GetPixelChannelTraits( image, channel );\
|
*tq++ = p[b]; \
|
||||||
\
|
|
||||||
if( (traits & UpdatePixelTrait) == 0 ) \
|
|
||||||
continue; \
|
|
||||||
\
|
|
||||||
tq[b] = (P)[b]; \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
(P) += GetPixelChannels( image ); \
|
p += GetPixelChannels( image ); \
|
||||||
tq += GetPixelChannels( image ); \
|
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,45 +521,19 @@ vips_foreign_load_magick7_fill_region( VipsRegion *or,
|
|||||||
|
|
||||||
switch( im->BandFmt ) {
|
switch( im->BandFmt ) {
|
||||||
case VIPS_FORMAT_UCHAR:
|
case VIPS_FORMAT_UCHAR:
|
||||||
|
UNPACK( unsigned char );
|
||||||
{
|
|
||||||
unsigned char * restrict tq = (unsigned char *) q;
|
|
||||||
int x;
|
|
||||||
int b;
|
|
||||||
|
|
||||||
for( x = 0; x < r->width; x++ ) {
|
|
||||||
if( GetPixelReadMask( image, p ) ) {
|
|
||||||
for( b = 0; b < GetPixelChannels( image ); b++ ) {
|
|
||||||
PixelChannel channel =
|
|
||||||
GetPixelChannelChannel( image, b );
|
|
||||||
PixelTrait traits =
|
|
||||||
GetPixelChannelTraits( image, channel );
|
|
||||||
|
|
||||||
if( (traits & UpdatePixelTrait ) == 0 )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
tq[b] = p[b];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p += GetPixelChannels( image );
|
|
||||||
tq += GetPixelChannels( image );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//UNPACK( unsigned char, q, p );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_USHORT:
|
case VIPS_FORMAT_USHORT:
|
||||||
UNPACK( unsigned short, q, p );
|
UNPACK( unsigned short );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_FLOAT:
|
case VIPS_FORMAT_FLOAT:
|
||||||
UNPACK( float, q, p );
|
UNPACK( float );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_FORMAT_DOUBLE:
|
case VIPS_FORMAT_DOUBLE:
|
||||||
UNPACK( double, q, p );
|
UNPACK( double );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user