add @format and @interpretation to rawload
This commit is contained in:
parent
f09bd91f69
commit
dd9eba9e26
@ -11,7 +11,9 @@
|
|||||||
- add vips_switch() / vips_case() ... fast many-way ifthenelse
|
- add vips_switch() / vips_case() ... fast many-way ifthenelse
|
||||||
- better const handling for arithmetic operators fixes comparisons against out
|
- better const handling for arithmetic operators fixes comparisons against out
|
||||||
of range values
|
of range values
|
||||||
|
- sharpen restores input colourspace
|
||||||
- handle alpha in heifload / heifsave [meyermarcel]
|
- handle alpha in heifload / heifsave [meyermarcel]
|
||||||
|
- add @interpretation and @format to rawload
|
||||||
|
|
||||||
31/8/19 started 8.8.3
|
31/8/19 started 8.8.3
|
||||||
- revert sharpen restoring the input colourspace
|
- revert sharpen restoring the input colourspace
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* load raw data from a file
|
/* load raw data from a file
|
||||||
*
|
*
|
||||||
* 14/12/11
|
* 14/12/11
|
||||||
|
* 5/8/19
|
||||||
|
* - add @format and @interpretation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -53,6 +55,8 @@ typedef struct _VipsForeignLoadRaw {
|
|||||||
int height;
|
int height;
|
||||||
int bands;
|
int bands;
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
|
VipsBandFormat format;
|
||||||
|
VipsInterpretation interpretation;
|
||||||
} VipsForeignLoadRaw;
|
} VipsForeignLoadRaw;
|
||||||
|
|
||||||
typedef VipsForeignLoadClass VipsForeignLoadRawClass;
|
typedef VipsForeignLoadClass VipsForeignLoadRawClass;
|
||||||
@ -76,20 +80,34 @@ static int
|
|||||||
vips_foreign_load_raw_header( VipsForeignLoad *load )
|
vips_foreign_load_raw_header( VipsForeignLoad *load )
|
||||||
{
|
{
|
||||||
VipsForeignLoadRaw *raw = (VipsForeignLoadRaw *) load;
|
VipsForeignLoadRaw *raw = (VipsForeignLoadRaw *) load;
|
||||||
VipsImage *out;
|
|
||||||
VipsImage *out2;
|
|
||||||
|
|
||||||
if( !(out2 = vips_image_new_from_file_raw( raw->filename,
|
VipsImage *out;
|
||||||
raw->width, raw->height, raw->bands, raw->offset )) )
|
VipsImage *x;
|
||||||
|
|
||||||
|
if( !(out = vips_image_new_from_file_raw( raw->filename,
|
||||||
|
raw->width, raw->height,
|
||||||
|
vips_format_sizeof_unsafe( raw->format ) * raw->bands,
|
||||||
|
raw->offset )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
if( vips_copy( out, &x,
|
||||||
|
"interpretation", raw->interpretation,
|
||||||
|
"format", raw->format,
|
||||||
|
"bands", raw->bands,
|
||||||
|
NULL ) ) {
|
||||||
|
g_object_unref( out );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
g_object_unref( out );
|
||||||
|
out = x;
|
||||||
|
|
||||||
/* Remove the @out that's there now.
|
/* Remove the @out that's there now.
|
||||||
*/
|
*/
|
||||||
g_object_get( load, "out", &out, NULL );
|
g_object_get( load, "out", &x, NULL );
|
||||||
g_object_unref( out );
|
g_object_unref( x );
|
||||||
g_object_unref( out );
|
g_object_unref( x );
|
||||||
|
|
||||||
g_object_set( load, "out", out2, NULL );
|
g_object_set( load, "out", out, NULL );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -147,11 +165,27 @@ vips_foreign_load_raw_class_init( VipsForeignLoadRawClass *class )
|
|||||||
G_STRUCT_OFFSET( VipsForeignLoadRaw, offset ),
|
G_STRUCT_OFFSET( VipsForeignLoadRaw, offset ),
|
||||||
0, 100000000000, 0 );
|
0, 100000000000, 0 );
|
||||||
|
|
||||||
|
VIPS_ARG_ENUM( class, "format", 24,
|
||||||
|
_( "Format" ),
|
||||||
|
_( "Pixel format in image" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignLoadRaw, format ),
|
||||||
|
VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR );
|
||||||
|
|
||||||
|
VIPS_ARG_ENUM( class, "interpretation", 25,
|
||||||
|
_( "Interpretation" ),
|
||||||
|
_( "Pixel interpretation" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignLoadRaw, interpretation ),
|
||||||
|
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_raw_init( VipsForeignLoadRaw *raw )
|
vips_foreign_load_raw_init( VipsForeignLoadRaw *raw )
|
||||||
{
|
{
|
||||||
|
raw->format = VIPS_FORMAT_UCHAR;
|
||||||
|
raw->interpretation = VIPS_INTERPRETATION_MULTIBAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,14 +200,18 @@ vips_foreign_load_raw_init( VipsForeignLoadRaw *raw )
|
|||||||
* Optional arguments:
|
* Optional arguments:
|
||||||
*
|
*
|
||||||
* * @offset: %guint64, offset in bytes from start of file
|
* * @offset: %guint64, offset in bytes from start of file
|
||||||
|
* * @format: #VipsBandFormat, set image format
|
||||||
|
* * @interpretation: #VipsInterpretation, set image interpretation
|
||||||
*
|
*
|
||||||
* This operation mmaps the file, setting up @out so that access to that
|
* This operation mmaps the file, setting up @out so that access to that
|
||||||
* image will read from the file.
|
* image will read from the file.
|
||||||
*
|
*
|
||||||
* @out will be a 8-bit uchar image with @bands image bands, so @bands can
|
* By default, it assumes uchar pixels. Use @format to select something else.
|
||||||
* be thought of as meaning "number of bytes per pixel". Use functions
|
*
|
||||||
* like vips_copy() to set the exact band format, number of bands,
|
* The image will be tagged as #VIPS_INTERPRETATION_MULTIBAND. Use
|
||||||
* and so on. Use vips_byteswap() to reverse the byte ordering.
|
* @interpretation to select something else.
|
||||||
|
*
|
||||||
|
* Use vips_byteswap() to reverse the byte ordering if necessary.
|
||||||
*
|
*
|
||||||
* See also: vips_image_new_from_file(), vips_copy(), vips_byteswap().
|
* See also: vips_image_new_from_file(), vips_copy(), vips_byteswap().
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user