~ubuntu-branches/ubuntu/karmic/ghostscript/karmic

« back to all changes in this revision

Viewing changes to base/sjpx.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-07-29 09:47:54 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20090729094754-8igon4p944x8382l
Tags: 8.70.dfsg.1~rc1-0ubuntu1
* New upstream release
   o Fixes many transparency problems: color space conversion, mask contexts,
     patterns, ...
   o Fixes in font handling, especially when generating PDF
   o Improvements in robustness, correctness, and performance
   o New generic Esc/Page drivers: "eplmono", "eplcolor"
   o New "cdnj500" driver for many HP DesignJet printers
   o License is now GPLv2 or later and not GPLv2-only any more
   o Merged all patches of the Ubuntu and Debian packages upstream
   o Fixes LP: #196009
* debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch,
  debian/patches/35_bitcmyk-blank-output.dpatch,
  debian/patches/37_fix-segfault-in-cups-raster-output-device.dpatch,
  debian/patches/38_CVE-2009-0583_0584.dpatch,
  debian/patches/40_pdfwrite-numcopies.dpatch,
  debian/patches/41_CVE-2009-0196.dpatch,
  debian/patches/42_CVE-2009-0792.dpatch,
  debian/patches/43_add-cdnj500-driver.dpatch,
  debian/patches/45_cups-device-pagesize-margins-duplex-fixes.dpatch,
  debian/patches/47_ps2write-segfault-fix.dpatch,
  debian/patches/50_ps2write-do-not-advertize-dsc-conformance.dpatch,
  debian/patches/53_fix-pstoraster-for-call-with-input-filename.dpatch:
  Removed patches backported from upstream.
* debian/copyright: License change.
* debian/ghostscript.links: s/8.64/8.70/

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: sjpx.c 9006 2008-08-20 23:22:49Z giles $ */
 
14
/* $Id: sjpx.c 9801 2009-06-18 05:16:48Z giles $ */
15
15
/* JPXDecode filter implementation -- hooks in libjasper */
16
16
 
17
17
#include "memory_.h"
18
 
#include "gserrors.h"
19
18
#include "gserror.h"
20
19
#include "gdebug.h"
21
20
#include "strimpl.h"
173
172
{
174
173
    int i, p;
175
174
    int v;
176
 
    int shift;
 
175
    int shift, bits;
177
176
 
178
177
    v = jas_image_getcmptbytype(image, JAS_IMAGE_CT_GRAY_Y);
179
178
    if (v < 0) return 0; /* no matching component */
180
 
    shift = max(jas_image_cmptprec(image, v) - 8, 0);
181
 
 
182
 
    for (i = 1; i <= bytes; i++) {
183
 
        p = jas_image_readcmptsample(image, v, x++, y);
184
 
        dest[i] = p >> shift;
 
179
 
 
180
    bits = jas_image_cmptprec(image, v);
 
181
    if (bits >= 8) {
 
182
        /* shift down to 8 bpp */
 
183
        shift = max(jas_image_cmptprec(image, v) - 8, 0);
 
184
 
 
185
        for (i = 1; i <= bytes; i++) {
 
186
            p = jas_image_readcmptsample(image, v, x++, y);
 
187
            dest[i] = p >> shift;
 
188
        }
 
189
   } else if (bits == 4) {
 
190
        /* return two packed pixels per byte */
 
191
        for (i = 1; i <= bytes; i++) {
 
192
            p = jas_image_readcmptsample(image, v, x++, y) << 4;
 
193
            p |= jas_image_readcmptsample(image, v, x++, y);
 
194
            dest[i] = p;
 
195
        }
 
196
    } else {
 
197
        /* todo: handle other bit depths */
 
198
        memset(dest + 1, 0x80, bytes);
185
199
    }
186
200
 
187
201
    return bytes;
405
419
      if (state->image != NULL) {
406
420
        jas_image_t *image = state->image;
407
421
        int numcmpts = jas_image_numcmpts(image);
 
422
        int bits = jas_image_cmptprec(image, 0);
408
423
        int stride = numcmpts*jas_image_width(image);
409
424
        long image_size = stride*jas_image_height(image);
410
425
        int clrspc = jas_image_clrspc(image);
411
426
        int x, y;
412
427
        long usable, done;
413
428
 
 
429
        if (bits == 4) stride = (stride + 1)/2;
 
430
 
414
431
        /* copy data out of the decoded image data */
415
432
        /* be lazy and only write the rest of the current row */
416
433
        y = state->offset / stride;