Thanks Andrew,

Right, there is a missing _cmsWriteTypeBase in the line you report. You fix
is also valid. I am adding the changes to GIT sources, and will be on 2.2

Many thanks again
Best regards
Marti


Original Message:
-----------------
From: Andrew Brygin bae81...@gmail.com
Date: Fri, 3 Jun 2011 12:50:18 +0400
To: lcms-user@lists.sourceforge.net
Subject: [Lcms-user] cmsReadRawTag returns different data depending
onprofile state


The cmsReadRawTag returns different data for the same tag, depending on
whether
this tag was converted in internal representation, or not. Following
scenario makes the
problem visible:

  a) open profile:
      all tags are in raw representation at the moment.
  b) read a tag (grayTRC in this test) as raw data:
      returned data has length 14 and contain all required parts of a
tag's data:
      type signature, reserved dword, and curve data.
  c) read the tag using cmsReadTag in order to force a conversion of the tag
      into an internal representation.
  d) read raw data of the tag again:
      Note that now reported data size is 8 bytes shorter and the data does
not
      contain the type signature and the reserved dword. It happens because
      in case of 'cooked' tag, raw data is obtained as a result of
serialization of
      an internal structure, and at this codepath tag signature is missed.

Note that the step c) can be done implicitly by, for example, a
transform creation.
Attached test demonstrates the difference in the length of raw tag data.

This problem is present in latest version of sources, available via git.
A suggested fix is to explicitly add a tag signature and reserved dword
to tag raw tag data, in order to comply the ICC spec:

diff --git a/src/cmsio0.c b/src/cmsio0.c
old mode 100644
new mode 100755
index 770e986..c05e5b7
--- a/src/cmsio0.c
+++ b/src/cmsio0.c
@@ -1656,6 +1656,18 @@ cmsInt32Number CMSEXPORT
cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
     // Serialize
     TypeHandler ->ContextID  = Icc ->ContextID;
     TypeHandler ->ICCVersion = Icc ->Version;
+
+    // write type signature
+    if (!_cmsWriteUInt32Number(MemIO, TypeHandler->Signature)) {
+        cmsCloseIOhandler(MemIO);
+        return 0;
+    }
+    // write reserved field
+    if (!_cmsWriteUInt32Number(MemIO, 0)) {
+        cmsCloseIOhandler(MemIO);
+        return 0;
+    }
+
     if (!TypeHandler ->WritePtr(TypeHandler, MemIO, Object,
TagDescriptor ->ElemCount)) {
         cmsCloseIOhandler(MemIO);
         return 0;

Thanks,
Andrew


--------------------------------------------------------------------
mail2web.com – What can On Demand Business Solutions do for you?
http://link.mail2web.com/Business/SharePoint



------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to