more robust char->enum
edvips has much safer char->enum conversion
This commit is contained in:
parent
c197e2f90e
commit
d1f5225e58
2
TODO
2
TODO
@ -1,5 +1,5 @@
|
||||
- viewing an image tagged as fourier in nip2 is broken, which operation is
|
||||
failing?
|
||||
failing? im_abs()?
|
||||
|
||||
- add a fft test to the suite
|
||||
|
||||
|
@ -85,6 +85,7 @@ extern "C" {
|
||||
* See also: vips_demand_hint().
|
||||
*/
|
||||
typedef enum {
|
||||
VIPS_DEMAND_STYLE_ERROR = -1,
|
||||
VIPS_DEMAND_STYLE_SMALLTILE,
|
||||
VIPS_DEMAND_STYLE_FATSTRIP,
|
||||
VIPS_DEMAND_STYLE_THINSTRIP,
|
||||
@ -95,6 +96,7 @@ typedef enum {
|
||||
* does not imply that any fields in IMAGE have valid data.
|
||||
*/
|
||||
typedef enum {
|
||||
VIPS_IMAGE_ERROR = -1,
|
||||
VIPS_IMAGE_NONE, /* no type set */
|
||||
VIPS_IMAGE_SETBUF, /* malloced memory array */
|
||||
VIPS_IMAGE_SETBUF_FOREIGN, /* memory array, don't free on close */
|
||||
@ -137,6 +139,7 @@ typedef enum {
|
||||
* new numbers from the end.
|
||||
*/
|
||||
typedef enum {
|
||||
VIPS_INTERPRETATION_ERROR = -1,
|
||||
VIPS_INTERPRETATION_MULTIBAND = 0,
|
||||
VIPS_INTERPRETATION_B_W = 1,
|
||||
VIPS_INTERPRETATION_HISTOGRAM = 10,
|
||||
@ -206,6 +209,7 @@ typedef enum {
|
||||
* new numbers from the end.
|
||||
*/
|
||||
typedef enum {
|
||||
VIPS_CODING_ERROR = -1,
|
||||
VIPS_CODING_NONE = 0,
|
||||
VIPS_CODING_LABQ = 2,
|
||||
VIPS_CODING_RAD = 6,
|
||||
|
@ -356,6 +356,7 @@ vips_demand_style_get_type( void )
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_DEMAND_STYLE_ERROR, "VIPS_DEMAND_STYLE_ERROR", "error"},
|
||||
{VIPS_DEMAND_STYLE_SMALLTILE, "VIPS_DEMAND_STYLE_SMALLTILE", "smalltile"},
|
||||
{VIPS_DEMAND_STYLE_FATSTRIP, "VIPS_DEMAND_STYLE_FATSTRIP", "fatstrip"},
|
||||
{VIPS_DEMAND_STYLE_THINSTRIP, "VIPS_DEMAND_STYLE_THINSTRIP", "thinstrip"},
|
||||
@ -375,6 +376,7 @@ vips_image_type_get_type( void )
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_IMAGE_ERROR, "VIPS_IMAGE_ERROR", "error"},
|
||||
{VIPS_IMAGE_NONE, "VIPS_IMAGE_NONE", "none"},
|
||||
{VIPS_IMAGE_SETBUF, "VIPS_IMAGE_SETBUF", "setbuf"},
|
||||
{VIPS_IMAGE_SETBUF_FOREIGN, "VIPS_IMAGE_SETBUF_FOREIGN", "setbuf-foreign"},
|
||||
@ -398,6 +400,7 @@ vips_interpretation_get_type( void )
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_INTERPRETATION_ERROR, "VIPS_INTERPRETATION_ERROR", "error"},
|
||||
{VIPS_INTERPRETATION_MULTIBAND, "VIPS_INTERPRETATION_MULTIBAND", "multiband"},
|
||||
{VIPS_INTERPRETATION_B_W, "VIPS_INTERPRETATION_B_W", "b-w"},
|
||||
{VIPS_INTERPRETATION_HISTOGRAM, "VIPS_INTERPRETATION_HISTOGRAM", "histogram"},
|
||||
@ -457,6 +460,7 @@ vips_coding_get_type( void )
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_CODING_ERROR, "VIPS_CODING_ERROR", "error"},
|
||||
{VIPS_CODING_NONE, "VIPS_CODING_NONE", "none"},
|
||||
{VIPS_CODING_LABQ, "VIPS_CODING_LABQ", "labq"},
|
||||
{VIPS_CODING_RAD, "VIPS_CODING_RAD", "rad"},
|
||||
|
@ -176,17 +176,27 @@ main( int argc, char **argv )
|
||||
if( bands )
|
||||
parse_pint( bands, &im->Bands );
|
||||
if( format ) {
|
||||
if( (im->BandFmt = im_char2BandFmt( format )) < 0 )
|
||||
VipsBandFormat f;
|
||||
|
||||
if( (f = im_char2BandFmt( format )) < 0 )
|
||||
error_exit( _( "bad format %s" ), format );
|
||||
im->Bbits = im_bits_of_fmt( im->BandFmt );
|
||||
im->BandFmt = f;
|
||||
im->Bbits = im_bits_of_fmt( f );
|
||||
}
|
||||
if( interpretation ) {
|
||||
if( (im->Type = im_char2Type( interpretation )) < 0 )
|
||||
error_exit( _( "bad interpretation %s" ), interpretation );
|
||||
VipsInterpretation i;
|
||||
|
||||
if( (i = im_char2Type( interpretation )) < 0 )
|
||||
error_exit( _( "bad interpretation %s" ),
|
||||
interpretation );
|
||||
im->Type = i;
|
||||
}
|
||||
if( coding ) {
|
||||
if( (im->Coding = im_char2Coding( coding )) < 0 )
|
||||
VipsCoding c;
|
||||
|
||||
if( (c = im_char2Coding( coding )) < 0 )
|
||||
error_exit( _( "bad coding %s" ), coding );
|
||||
im->Coding = c;
|
||||
}
|
||||
if( xres )
|
||||
im->Xres = atof( xres );
|
||||
|
Loading…
Reference in New Issue
Block a user