Skip to content

Commit

Permalink
print: make sure to use intermediate profile
Browse files Browse the repository at this point in the history
When applying the printer profile, make sure we use the intermediate
profile (from bottom of the print settings dialog) rather than the
export profile. Calling dt_colorspaces_get_output_profile() will
return the profile/intent as set in the export dialog.

This re-iterates some work done by the pixelpipe and colorout.
  • Loading branch information
Dan Torop committed Oct 27, 2017
1 parent a917e5e commit 12f1378
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
14 changes: 3 additions & 11 deletions src/common/printprof.c
Expand Up @@ -39,24 +39,16 @@ static cmsUInt32Number ComputeFormatDescriptor (int OutColorSpace, int bps)
}

int dt_apply_printer_profile(int imgid, void **in, uint32_t width, uint32_t height, int bpp,
cmsHPROFILE hOutProfile, int intent, gboolean black_point_compensation)
cmsHPROFILE hInProfile, cmsHPROFILE hOutProfile,
int intent, gboolean black_point_compensation)
{
cmsHPROFILE hInProfile;
cmsHTRANSFORM hTransform;
cmsUInt32Number wInput, wOutput;
int OutputColorSpace;

if(!hOutProfile)
if(!(hInProfile && hOutProfile))
return 1;

const dt_colorspaces_color_profile_t *in_profile = dt_colorspaces_get_output_profile(imgid);
if(!in_profile || !in_profile->profile)
{
fprintf(stderr, "error getting output profile for image %d\n", imgid);
return 1;
}
hInProfile = in_profile->profile;

wInput = ComputeFormatDescriptor (PT_RGB, (bpp==8?1:2));

OutputColorSpace = _cmsLCMScolorSpace(cmsGetColorSpace(hOutProfile));
Expand Down
3 changes: 2 additions & 1 deletion src/common/printprof.h
Expand Up @@ -24,7 +24,8 @@
#include <stddef.h>

int dt_apply_printer_profile(int imgid, void **in, uint32_t width, uint32_t height, int bpp,
cmsHPROFILE hOutProfile, int intent, gboolean black_point_compensation);
cmsHPROFILE hInProfile, cmsHPROFILE hOutProfile,
int intent, gboolean black_point_compensation);
// this routines takes as input an image of 8 or 16 bpp but always return a 8 bpp result. It is indeed better to
// apply the profile to a 16bit input but we do not need this for printing.

Expand Down
14 changes: 13 additions & 1 deletion src/libs/print_settings.c
Expand Up @@ -280,9 +280,21 @@ _print_button_clicked (GtkWidget *widget, gpointer user_data)

if (*ps->v_piccprofile)
{
const dt_colorspaces_color_profile_t *eprof = dt_colorspaces_get_profile(icc_type, icc_filename,
DT_PROFILE_DIRECTION_OUT);
const dt_colorspaces_color_profile_t *pprof = dt_colorspaces_get_profile(ps->v_picctype, ps->v_piccprofile,
DT_PROFILE_DIRECTION_OUT);

if (!eprof)
{
// this is the same behavior as colorout and the same warnings
eprof = dt_colorspaces_get_profile(DT_COLORSPACE_SRGB, "",
DT_PROFILE_DIRECTION_OUT | DT_PROFILE_DIRECTION_DISPLAY)->profile;
dt_control_log(_("missing export profile has been replaced by sRGB!"));
fprintf(stderr, "missing export profile `%s' has been replaced by sRGB!\n",
dt_colorspaces_get_name(icc_type, icc_filename));
}

if (!pprof)
{
dt_control_log(_("cannot open printer profile `%s'"), ps->v_piccprofile);
Expand All @@ -292,7 +304,7 @@ _print_button_clicked (GtkWidget *widget, gpointer user_data)
}
else
if (dt_apply_printer_profile(imgid, (void **)&(dat.ps->buf), dat.width, dat.height, dat.bpp,
pprof->profile,
eprof->profile, pprof->profile,
ps->v_pintent, ps->v_black_point_compensation))
{
free(dat.ps->buf);
Expand Down

0 comments on commit 12f1378

Please sign in to comment.