use vips__bgra2rgba() in pdfiumload
slightly quicker, works with any byte order
This commit is contained in:
parent
83bf777325
commit
bf614530cd
@ -14,6 +14,8 @@
|
|||||||
* - add _source input
|
* - add _source input
|
||||||
* 28/1/22
|
* 28/1/22
|
||||||
* - add password
|
* - add password
|
||||||
|
* 21/5/22
|
||||||
|
* - improve transparency handling [DarthSim]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -152,9 +154,9 @@ typedef struct _VipsForeignLoadPdf {
|
|||||||
VipsRect image;
|
VipsRect image;
|
||||||
VipsRect *pages;
|
VipsRect *pages;
|
||||||
|
|
||||||
/* The [double] background converted to the PDFium format.
|
/* The [double] background converted to image format.
|
||||||
*/
|
*/
|
||||||
FPDF_DWORD ink;
|
VipsPel *ink;
|
||||||
|
|
||||||
} VipsForeignLoadPdf;
|
} VipsForeignLoadPdf;
|
||||||
|
|
||||||
@ -438,7 +440,6 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
int top;
|
int top;
|
||||||
int i;
|
int i;
|
||||||
VipsPel *ink;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf( "vips_foreign_load_pdf_header: %p\n", pdf );
|
printf( "vips_foreign_load_pdf_header: %p\n", pdf );
|
||||||
@ -520,13 +521,12 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
/* Convert the background to the image format.
|
/* Convert the background to the image format.
|
||||||
*/
|
*/
|
||||||
if( !(ink = vips__vector_to_ink( class->nickname,
|
if( !(pdf->ink = vips__vector_to_ink( class->nickname,
|
||||||
load->out,
|
load->out,
|
||||||
VIPS_AREA( pdf->background )->data, NULL,
|
VIPS_AREA( pdf->background )->data, NULL,
|
||||||
VIPS_AREA( pdf->background )->n )) )
|
VIPS_AREA( pdf->background )->n )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
vips__bgra2rgba( (guint32 *) pdf->ink, 1 );
|
||||||
pdf->ink = (ink[3] << 24) + (ink[0] << 16) + (ink[1] << 8) + ink[2];
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -580,10 +580,14 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
|||||||
VIPS_REGION_ADDR( or, rect.left, rect.top ),
|
VIPS_REGION_ADDR( or, rect.left, rect.top ),
|
||||||
VIPS_REGION_LSKIP( or ) );
|
VIPS_REGION_LSKIP( or ) );
|
||||||
|
|
||||||
/* PDFium won't always paint the background.
|
/* Only paint the background if there's no transparency.
|
||||||
*/
|
*/
|
||||||
if ( !FPDFPage_HasTransparency(pdf->page) )
|
if ( !FPDFPage_HasTransparency( pdf->page ) ) {
|
||||||
FPDFBitmap_FillRect(bitmap, 0, 0, rect.width, rect.height, pdf->ink);
|
FPDF_DWORD ink = *((guint32 *) pdf->ink);
|
||||||
|
|
||||||
|
FPDFBitmap_FillRect( bitmap,
|
||||||
|
0, 0, rect.width, rect.height, ink );
|
||||||
|
}
|
||||||
|
|
||||||
FPDF_RenderPageBitmap( bitmap, pdf->page,
|
FPDF_RenderPageBitmap( bitmap, pdf->page,
|
||||||
0, 0, rect.width, rect.height,
|
0, 0, rect.width, rect.height,
|
||||||
|
Loading…
Reference in New Issue
Block a user