"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libvips/foreign/cairo.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

cairo.c  (vips-8.10.6):cairo.c  (vips-8.11.0)
skipping to change at line 38 skipping to change at line 38
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif /*HAVE_CONFIG_H*/ #endif /*HAVE_CONFIG_H*/
#include <vips/vips.h> #include <vips/vips.h>
#include <vips/internal.h> #include <vips/internal.h>
/* Convert from ARGB to RGBA and undo premultiplication. /* Convert from Cairo-style premultiplied BGRA to RGBA.
* *
* See also openslide's argb2rgba(). * See also openslide's argb2rgba().
*/ */
void void
vips__cairo2rgba( guint32 * restrict buf, int n ) vips__premultiplied_bgra2rgba( guint32 * restrict p, int n )
{ {
int i; int x;
for( i = 0; i < n; i++ ) { for( x = 0; x < n; x++ ) {
guint32 * restrict p = buf + i; guint32 bgra = GUINT32_FROM_BE( p[x] );
guint32 x = *p; guint8 a = bgra & 0xff;
guint8 a = x >> 24;
VipsPel * restrict out = (VipsPel *) p; guint32 rgba;
if( a == 255 ) if( a == 0 ||
*p = GUINT32_TO_BE( (x << 8) | 255 ); a == 255 )
else if( a == 0 ) rgba =
*p = GUINT32_TO_BE( x << 8 ); (bgra & 0x00ff00ff) |
else { (bgra & 0x0000ff00) << 16 |
/* Undo premultiplication. (bgra & 0xff000000) >> 16;
*/ else
out[0] = 255 * ((x >> 16) & 255) / a; /* Undo premultiplication.
out[1] = 255 * ((x >> 8) & 255) / a; */
out[2] = 255 * (x & 255) / a; rgba =
out[3] = a; ((255 * ((bgra >> 8) & 0xff) / a) << 24) |
} ((255 * ((bgra >> 16) & 0xff) / a) << 16) |
((255 * ((bgra >> 24) & 0xff) / a) << 8) |
a;
p[x] = GUINT32_TO_BE( rgba );
} }
} }
/* Convert from PDFium-style BGRA to RGBA.
*/
void
vips__bgra2rgba( guint32 * restrict p, int n )
{
int x;
for( x = 0; x < n; x++ ) {
guint32 bgra = GUINT32_FROM_BE( p[x] );
guint rgba;
/* Leave G and A, swap R and B.
*/
rgba =
(bgra & 0x00ff00ff) |
(bgra & 0x0000ff00) << 16 |
(bgra & 0xff000000) >> 16;
p[x] = GUINT32_TO_BE( rgba );
}
}
 End of changes. 5 change blocks. 
21 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)