shithub: jbig2

Download patch

ref: 6c00475e659e7f29c142e879ec3dd9d4b5375ee5
parent: d85ffd487d624754ce5784fb970e939bc8b9dd5c
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Sun Jul 7 16:30:57 EDT 2002

Handle lossy and intermediate text regions as well as lossless immediate.
Store the bitmap for intermediate text regions into the segment's result field for later use by a refinement region.


git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@110 ded80894-8fb9-0310-811b-c03f3676ab4d

--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2_segment.c,v 1.11 2002/07/04 16:33:44 giles Exp $
+    $Id: jbig2_segment.c,v 1.12 2002/07/07 20:30:56 giles Exp $
 */
 
 #include <stdlib.h> /* size_t */
@@ -138,13 +138,9 @@
     {
     case 0:
       return jbig2_symbol_dictionary(ctx, segment, segment_data);
-    case 4:
-      return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
-        "unhandled segment type 'intermediate text region'");
-    case 6:
-      return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
-        "unhandled segment type 'immediate text region'");
-    case 7:
+    case 4: /* intermediate text region */
+    case 6: /* immediate text region */
+    case 7: /* immediate lossless text region */
       return jbig2_read_text_info(ctx, segment, segment_data);
     case 16:
       return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -8,7 +8,7 @@
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    $Id: jbig2_text.c,v 1.9 2002/07/04 12:08:03 giles Exp $
+    $Id: jbig2_text.c,v 1.10 2002/07/07 20:30:57 giles Exp $
 */
 
 #include <stddef.h>
@@ -407,13 +407,19 @@
 
     /* todo: check errors */
 
-    jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, 
-        "composing %dx%d decoded text region onto page at (%d, %d)",
-        region_info.width, region_info.height, region_info.x, region_info.y);
-    jbig2_image_compose(ctx, page_image, image, region_info.x, region_info.y, JBIG2_COMPOSE_OR);
-    if (image != page_image)
-        jbig2_image_free(ctx, image);
-
+    if ((segment->flags & 63) == 4) {
+        /* we have an intermediate region here. save it for later */
+        segment->result = image;
+    } else {
+        /* otherwise composite onto the page */
+        jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, 
+            "composing %dx%d decoded text region onto page at (%d, %d)",
+            region_info.width, region_info.height, region_info.x, region_info.y);
+        jbig2_image_compose(ctx, page_image, image, region_info.x, region_info.y, JBIG2_COMPOSE_OR);
+        if (image != page_image)
+            jbig2_image_free(ctx, image);
+    }
+    
     /* success */            
     return 0;