Compare commits
No commits in common. "ee202ca28b3c5f2ff1d1da5b41fea109f303da38" and "d6e79cf976befd0cc1d158c440106154554bb52b" have entirely different histories.
ee202ca28b
...
d6e79cf976
27
fiv-io.c
27
fiv-io.c
@ -1612,6 +1612,9 @@ open_libjpeg_enhanced(
|
|||||||
while (cinfo.output_scanline < cinfo.output_height)
|
while (cinfo.output_scanline < cinfo.output_height)
|
||||||
(void) jpeg_read_scanlines(&cinfo, lines + cinfo.output_scanline,
|
(void) jpeg_read_scanlines(&cinfo, lines + cinfo.output_scanline,
|
||||||
cinfo.output_height - cinfo.output_scanline);
|
cinfo.output_height - cinfo.output_scanline);
|
||||||
|
if (cinfo.out_color_space == JCS_CMYK)
|
||||||
|
trivial_cmyk_to_host_byte_order_argb(
|
||||||
|
surface_data, cinfo.output_width * cinfo.output_height);
|
||||||
(void) jpegqs_finish_decompress(&cinfo);
|
(void) jpegqs_finish_decompress(&cinfo);
|
||||||
|
|
||||||
load_jpeg_finalize(surface, use_cmyk, ctx, data, len);
|
load_jpeg_finalize(surface, use_cmyk, ctx, data, len);
|
||||||
@ -2295,8 +2298,8 @@ load_resvg_destroy(void *closure)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
load_resvg_render_internal(FivIoRenderClosureResvg *self,
|
load_resvg_render_internal(
|
||||||
double scale, FivIoProfile target, GError **error)
|
FivIoRenderClosureResvg *self, double scale, GError **error)
|
||||||
{
|
{
|
||||||
double w = ceil(self->width * scale), h = ceil(self->height * scale);
|
double w = ceil(self->width * scale), h = ceil(self->height * scale);
|
||||||
if (w > SHRT_MAX || h > SHRT_MAX) {
|
if (w > SHRT_MAX || h > SHRT_MAX) {
|
||||||
@ -2321,21 +2324,21 @@ load_resvg_render_internal(FivIoRenderClosureResvg *self,
|
|||||||
cairo_image_surface_get_width(surface),
|
cairo_image_surface_get_width(surface),
|
||||||
cairo_image_surface_get_height(surface), (char *) pixels);
|
cairo_image_surface_get_height(surface), (char *) pixels);
|
||||||
|
|
||||||
|
// TODO(p): Also apply colour management, we'll need to un-premultiply.
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
uint32_t rgba = g_ntohl(pixels[i]);
|
uint32_t rgba = g_ntohl(pixels[i]);
|
||||||
pixels[i] = rgba << 24 | rgba >> 8;
|
pixels[i] = rgba << 24 | rgba >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_mark_dirty(surface);
|
cairo_surface_mark_dirty(surface);
|
||||||
return fiv_io_profile_finalize(surface, target);
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
load_resvg_render(FivIoRenderClosure *closure, double scale)
|
load_resvg_render(FivIoRenderClosure *closure, double scale)
|
||||||
{
|
{
|
||||||
FivIoRenderClosureResvg *self = (FivIoRenderClosureResvg *) closure;
|
FivIoRenderClosureResvg *self = (FivIoRenderClosureResvg *) closure;
|
||||||
// TODO(p): Somehow get the target colour management profile.
|
return load_resvg_render_internal(self, scale, NULL);
|
||||||
return load_resvg_render_internal(self, scale, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@ -2392,8 +2395,7 @@ open_resvg(
|
|||||||
closure->width = size.width;
|
closure->width = size.width;
|
||||||
closure->height = size.height;
|
closure->height = size.height;
|
||||||
|
|
||||||
cairo_surface_t *surface =
|
cairo_surface_t *surface = load_resvg_render_internal(closure, 1., error);
|
||||||
load_resvg_render_internal(closure, 1., ctx->screen_profile, error);
|
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
load_resvg_destroy(closure);
|
load_resvg_destroy(closure);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2448,8 +2450,6 @@ load_librsvg_render(FivIoRenderClosure *closure, double scale)
|
|||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(p): Somehow get the target colour management profile.
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2515,7 +2515,7 @@ open_librsvg(
|
|||||||
closure->height = h;
|
closure->height = h;
|
||||||
cairo_surface_set_user_data(
|
cairo_surface_set_user_data(
|
||||||
surface, &fiv_io_key_render, closure, load_librsvg_destroy);
|
surface, &fiv_io_key_render, closure, load_librsvg_destroy);
|
||||||
return fiv_io_profile_finalize(surface, ctx->screen_profile);
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_LIBRSVG --------------------------------------------------------
|
#endif // HAVE_LIBRSVG --------------------------------------------------------
|
||||||
@ -2998,9 +2998,6 @@ load_libtiff_directory(TIFF *tiff, GError **error)
|
|||||||
cairo_surface_mark_dirty(surface);
|
cairo_surface_mark_dirty(surface);
|
||||||
// XXX: The whole file is essentially an Exif, any ideas?
|
// XXX: The whole file is essentially an Exif, any ideas?
|
||||||
|
|
||||||
// TODO(p): TIFF has a number of fields that an ICC profile can be
|
|
||||||
// constructed from--it's not a good idea to blindly default to sRGB
|
|
||||||
// if we don't find an ICC profile.
|
|
||||||
const uint32_t meta_len = 0;
|
const uint32_t meta_len = 0;
|
||||||
const void *meta = NULL;
|
const void *meta = NULL;
|
||||||
if (TIFFGetField(tiff, TIFFTAG_ICCPROFILE, &meta_len, &meta)) {
|
if (TIFFGetField(tiff, TIFFTAG_ICCPROFILE, &meta_len, &meta)) {
|
||||||
@ -3076,6 +3073,10 @@ fail:
|
|||||||
TIFFSetWarningHandlerExt(whe);
|
TIFFSetWarningHandlerExt(whe);
|
||||||
TIFFSetErrorHandler(eh);
|
TIFFSetErrorHandler(eh);
|
||||||
TIFFSetWarningHandler(wh);
|
TIFFSetWarningHandler(wh);
|
||||||
|
|
||||||
|
// TODO(p): Colour management even for un/associated alpha channels.
|
||||||
|
// Note that TIFF has a number of fields that an ICC profile can be
|
||||||
|
// constructed from--it's not a good idea to blindly assume sRGB.
|
||||||
return fiv_io_profile_finalize(result, ctx->screen_profile);
|
return fiv_io_profile_finalize(result, ctx->screen_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user