diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2009-05-07 17:19:42 +0000 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2009-05-07 17:19:42 +0000 |
commit | 5fc43fb23e7680e09e40339a8f59598bdb07d789 (patch) | |
tree | 50e02aea5a9e92bec465bab1ad6773cf75fea67e /gs | |
parent | 99223a33971961d0b65fd5c1ece76d7891134536 (diff) |
Addition of code for setting device ICC profile in ICC manager.
git-svn-id: http://svn.ghostscript.com/ghostscript/branches/icc_work@9728 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs')
-rw-r--r-- | gs/base/gdevdflt.c | 1 | ||||
-rw-r--r-- | gs/base/gsicccache.c | 2 | ||||
-rw-r--r-- | gs/base/gsicccache.h | 2 | ||||
-rw-r--r-- | gs/base/gsiccmanage.c | 78 | ||||
-rw-r--r-- | gs/base/gsiccmanage.h | 5 | ||||
-rw-r--r-- | gs/base/gsistate.c | 2 | ||||
-rw-r--r-- | gs/psi/zicc.c | 12 |
7 files changed, 85 insertions, 17 deletions
diff --git a/gs/base/gdevdflt.c b/gs/base/gdevdflt.c index 38d562dcd..b9dad9283 100644 --- a/gs/base/gdevdflt.c +++ b/gs/base/gdevdflt.c @@ -639,7 +639,6 @@ gx_device_fill_in_procs(register gx_device * dev) } } - dev->color_info.icc_profile[0] = '\0'; /* Initialization for ICC profile file name */ set_dev_proc(dev, decode_color, get_decode_color(dev)); fill_dev_proc(dev, map_color_rgb, gx_default_map_color_rgb); diff --git a/gs/base/gsicccache.c b/gs/base/gsicccache.c index f944d1bfe..8552e208b 100644 --- a/gs/base/gsicccache.c +++ b/gs/base/gsicccache.c @@ -56,7 +56,7 @@ gs_private_st_ptrs1(st_icc_linkcache, gsicc_link_cache_t, "gsiccmanage_linkcache **/
gsicc_link_cache_t *
-gsicc_cache_new(int cachesize, gs_memory_t *memory)
+gsicc_cache_new(gs_memory_t *memory)
{
gsicc_link_cache_t *result;
diff --git a/gs/base/gsicccache.h b/gs/base/gsicccache.h index a6a72cd53..17e25cdf0 100644 --- a/gs/base/gsicccache.h +++ b/gs/base/gsicccache.h @@ -20,7 +20,7 @@ #include "gx.h"
-gsicc_link_cache_t* gsicc_cache_new(int cachesize, gs_memory_t *memory);
+gsicc_link_cache_t* gsicc_cache_new(gs_memory_t *memory);
static void gsicc_add_link(gsicc_link_cache_t *link_cache, void *link_handle,
void *ContextPtr, int64_t link_hashcode, gs_memory_t *memory);
diff --git a/gs/base/gsiccmanage.c b/gs/base/gsiccmanage.c index 2ddc09d4d..f3cdbef5c 100644 --- a/gs/base/gsiccmanage.c +++ b/gs/base/gsiccmanage.c @@ -20,6 +20,7 @@ #include "scommon.h"
#include "strmio.h"
#include "gx.h"
+#include "gxistate.h"
#include "gxcspace.h"
#include "gscms.h"
#include "gsiccmanage.h"
@@ -123,11 +124,51 @@ gsicc_set_cmyk_profile(cmm_profile_t cmykbuffer) device */
void
-gsicc_set_device_profile(cmm_profile_t deviceprofile)
+gsicc_set_device_profile(gs_imager_state *pis, gx_device * pdev, gs_memory_t * mem)
{
+ gsicc_manager_t *icc_manager = pis->icc_manager;
+ cmm_profile_t *icc_profile;
+ stream *str;
+ const char *profile = &(pdev->color_info.icc_profile[0]);
+ if (icc_manager->device_profile == NULL){
+ /* Device profile in icc manager has not
+ yet been set. Lets do it. */
+ /* Check if device has a profile. This
+ should always be true, since if one was
+ not set, we should have set it to the default.
+ */
+
+ if (profile != '\0'){
+
+ /* We need to do a bit of work here with
+ respect to path names. MJV ToDo. */
+
+ str = sfopen(profile, "rb", mem);
+
+ if (str != NULL){
+ icc_profile = gsicc_profile_new(str, mem);
+ sfclose(str);
+ icc_manager->device_profile = icc_profile;
+
+ /* Get the profile handle */
+
+
+ /* Set the hash code of the profile */
+
+
+
+
+ }
+
+
+ }
+
+
+ }
+
}
/* Set the named color profile in the Device manager */
@@ -208,13 +249,11 @@ gsicc_setbuffer_desc(gsicc_bufferdesc_t *buffer_desc,unsigned char num_chan, }
cmm_profile_t *
-gsicc_profile_new(gs_color_space *gs_colorspace, stream *s, gs_memory_t *memory)
+gsicc_profile_new(stream *s, gs_memory_t *memory)
{
cmm_profile_t *result;
int code;
-
- /* gs_colorspace = gs_cspace_alloc(memory,&gs_color_space_type_icc); */
result = gs_alloc_struct(memory, cmm_profile_t, &st_gsicc_profile,
"gsicc_profile_new");
@@ -300,6 +339,25 @@ gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory }
+
+gcmmhprofile_t
+gsicc_get_profile_handle_buffer(unsigned char *buffer){
+
+ gcmmhprofile_t profile_handle = NULL;
+ unsigned int profile_size;
+
+ if( buffer != NULL){
+ profile_size = gsicc_getprofilesize(buffer);
+ profile_handle = gscms_get_profile_handle_mem(buffer, profile_size);
+ return(profile_handle);
+ }
+
+ return(0);
+
+}
+
+
+
/* If we have a profile handle in the color space already, then we use that.
If we do not have one, then we check if there is data in the buffer. A
handle is created from that data and also stored in the gs color space.
@@ -321,8 +379,7 @@ gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory }
if( buffer != NULL){
- profile_size = gsicc_getprofilesize(buffer);
- return(gscms_get_profile_handle_mem(buffer, profile_size));
+ return(gsicc_get_profile_handle_buffer(buffer));
}
/* Now get a colorspace handle based upon the colorspace type */
@@ -331,19 +388,22 @@ gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory case gs_color_space_index_DeviceGray:
- return(gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_gray));
+ gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_gray);
+ return(gs_colorspace->cmm_icc_profile_data->profile_handle);
break;
case gs_color_space_index_DeviceRGB:
- return(gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_rgb));
+ gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_rgb);
+ return(gs_colorspace->cmm_icc_profile_data->profile_handle);
break;
case gs_color_space_index_DeviceCMYK:
- return(gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_cmyk));
+ gs_colorspace->cmm_icc_profile_data = &(icc_manager->default_cmyk);
+ return(gs_colorspace->cmm_icc_profile_data->profile_handle);
break;
diff --git a/gs/base/gsiccmanage.h b/gs/base/gsiccmanage.h index 1c2e8a425..e00556717 100644 --- a/gs/base/gsiccmanage.h +++ b/gs/base/gsiccmanage.h @@ -27,7 +27,7 @@ void gsicc_destroy(); void gsicc_set_gray_profile(cmm_profile_t graybuffer);
void gsicc_set_rgb_profile(cmm_profile_t rgbbuffer);
void gsicc_set_cmyk_profile(cmm_profile_t cmykbuffer);
-void gsicc_set_device_profile(cmm_profile_t deviceprofile);
+void gsicc_set_device_profile(gs_imager_state *pis, gx_device * pdev, gs_memory_t * mem);
void gsicc_set_device_named_color_profile(cmm_profile_t nameprofile);
void gsicc_set_device_linked_profile(cmm_profile_t outputlinkedprofile );
void gsicc_set_proof_profile(cmm_profile_t proofprofile );
@@ -35,7 +35,7 @@ void gsicc_load_default_device_profile(int numchannels); void gsicc_load_default_input_profile(int numchannels);
gsicc_manager_t* gsicc_manager_new(gs_memory_t *memory);
-cmm_profile_t* gsicc_profile_new(gs_color_space *gs_colorspace, stream *s, gs_memory_t *memory);
+cmm_profile_t* gsicc_profile_new(stream *s, gs_memory_t *memory);
static int gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory);
unsigned int gsicc_getprofilesize(unsigned char *buffer);
@@ -49,6 +49,7 @@ void gsicc_setbuffer_desc(gsicc_bufferdesc_t *buffer_desc,unsigned char num_chan gs_icc_colorbuffer_t buffercolor);
gcmmhprofile_t gsicc_get_profile_handle(gs_color_space *gs_colorspace, gsicc_manager_t *icc_manager);
+ gcmmhprofile_t gsicc_get_profile_handle_buffer(unsigned char *buffer);
diff --git a/gs/base/gsistate.c b/gs/base/gsistate.c index 8b37d2fd2..984544066 100644 --- a/gs/base/gsistate.c +++ b/gs/base/gsistate.c @@ -132,7 +132,7 @@ gs_imager_state_initialize(gs_imager_state * pis, gs_memory_t * mem) pis->have_pattern_streams = false; pis->devicergb_cs = gs_cspace_new_DeviceRGB(mem); pis->devicecmyk_cs = gs_cspace_new_DeviceCMYK(mem); - pis->icc_cache = 0; + pis->icc_cache = gsicc_cache_new(pis->memory); pis->icc_manager = gsicc_manager_new(pis->memory); return 0; } diff --git a/gs/psi/zicc.c b/gs/psi/zicc.c index fdb05623c..80e07fc7f 100644 --- a/gs/psi/zicc.c +++ b/gs/psi/zicc.c @@ -34,6 +34,8 @@ #include "zicc.h" #include "icc34.h" #include "gsiccmanage.h" +#include "gx.h" +#include "gxistate.h" int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) { @@ -48,6 +50,10 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) ref * pstrmval; stream * s = 0L; cmm_profile_t *icc_profile; + int zz; + gs_imager_state * pis = (gs_imager_state *)igs; + gx_device * pdev = gs_currentdevice(igs); + palt_cs = gs_currentcolorspace(igs); /* verify the DataSource entry */ @@ -71,15 +77,17 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) want to have this buffer. */ icc_profile = NULL; - icc_profile = gsicc_profile_new(pcs, s, gs_state_memory(igs)); + icc_profile = gsicc_profile_new(s, gs_state_memory(igs)); /* If we have not populated the icc_managers device profile yet, go ahead and take care of that now. We will likely want to move this out of here and into an intialization section later. Do it now though so that we can do some testing. */ + if (pis->icc_manager->device_profile == NULL){ - + gsicc_set_device_profile(pis, pdev, gs_state_memory(igs)); + } #if 0 |