byteswap popplerload
and better path absoluteization
This commit is contained in:
parent
be574be539
commit
adfd25a5ed
4
TODO
4
TODO
@ -1,5 +1,3 @@
|
||||
- popplerload generates ARGB? need to do our own byteswap
|
||||
|
||||
- add tests for popplerload, check docs, update c++
|
||||
|
||||
- add load PDF from buffer
|
||||
@ -10,8 +8,6 @@
|
||||
|
||||
- trim page edges? we often have black now
|
||||
|
||||
- does poppler support other formats? SVG / PS / EPS
|
||||
|
||||
- new vips_reduce:
|
||||
|
||||
affine
|
||||
|
@ -183,11 +183,7 @@ vips_foreign_load_poppler_header( VipsForeignLoad *load )
|
||||
|
||||
/* We need an absolute path for a URI.
|
||||
*/
|
||||
if( !(path = realpath( poppler->filename, NULL )) ) {
|
||||
vips_error_system( errno, class->nickname,
|
||||
"%s", _( "unable to form filename" ) );
|
||||
return( -1 );
|
||||
}
|
||||
path = vips_realpath( poppler->filename );
|
||||
if( !(poppler->uri = g_filename_to_uri( path, NULL, &error )) ) {
|
||||
free( path );
|
||||
vips_g_error( &error );
|
||||
@ -222,6 +218,7 @@ vips_foreign_load_poppler_generate( VipsRegion *or,
|
||||
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int x, y;
|
||||
|
||||
/* Poppler won't always paint the background.
|
||||
*/
|
||||
@ -246,6 +243,20 @@ vips_foreign_load_poppler_generate( VipsRegion *or,
|
||||
|
||||
cairo_destroy( cr );
|
||||
|
||||
/* Cairo makes BRGA, we must byteswap. We might not need to on SPARC,
|
||||
* but I have no way of testing this :(
|
||||
*/
|
||||
for( y = 0; y < r->height; y++ ) {
|
||||
VipsPel *q;
|
||||
|
||||
q = VIPS_REGION_ADDR( or, r->left, r->top + y );
|
||||
for( x = 0; x < r->width; x++ ) {
|
||||
VIPS_SWAP( VipsPel, q[0], q[2] );
|
||||
|
||||
q += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
@ -293,6 +293,8 @@ char *vips__temp_name( const char *format );
|
||||
void vips__change_suffix( const char *name, char *out, int mx,
|
||||
const char *new_suff, const char **olds, int nolds );
|
||||
|
||||
char *vips_realpath( const char *path );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
@ -1713,3 +1713,44 @@ vips__substitute( char *buf, size_t len, char *sub )
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Absoluteize a path. Free the result with g_free().
|
||||
*/
|
||||
char *
|
||||
vips_realpath( const char *path )
|
||||
{
|
||||
char *real;
|
||||
|
||||
#ifdef HAVE_REALPATH
|
||||
{
|
||||
char *real2;
|
||||
|
||||
if( !(real = realpath( path, NULL )) ) {
|
||||
vips_error_system( errno, "vips_realpath",
|
||||
"%s", _( "unable to form filename" ) );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* We must return a path that can be freed with g_free().
|
||||
*/
|
||||
real2 = g_strdup( real );
|
||||
free( real );
|
||||
real = real2;
|
||||
}
|
||||
#else /*!HAVE_REALPATH*/
|
||||
{
|
||||
char *real;
|
||||
|
||||
if( !g_path_is_absolute( path ) ) {
|
||||
char *cwd;
|
||||
|
||||
cwd = g_get_current_dir();
|
||||
real = g_build_filename( cwd, path );
|
||||
g_free( cwd );
|
||||
}
|
||||
else
|
||||
real = g_strdup( path );
|
||||
#endif
|
||||
|
||||
return( real );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user