]>
git.saurik.com Git - apple/boot.git/blob - gen/libsaio/unpackbits.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1988, 1989, 1990, 1991 Sam Leffler
26 * Copyright (c) 1991 Silicon Graphics, Inc.
28 * Permission to use, copy, modify, distribute, and sell this software and
29 * its documentation for any purpose is hereby granted without fee, provided
30 * that (i) the above copyright notices and this permission notice appear in
31 * all copies of the software and related documentation, and (ii) the names of
32 * Sam Leffler and Silicon Graphics may not be used in any advertising or
33 * publicity relating to the software without the specific, prior written
34 * permission of Sam Leffler and Silicon Graphics.
36 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
37 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
38 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
40 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
41 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
42 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
44 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
51 * PackBits Compression Algorithm Support
56 typedef unsigned int u_int
;
57 typedef unsigned char u_char
;
60 PackBitsDecode(tif
, op
, occ
, s
)
70 bp
= tif
->tif_rawcp
; cc
= tif
->tif_rawcc
;
71 while (cc
> 0 && occ
> 0) {
72 n
= (int) *bp
++; cc
--;
74 * Watch out for compilers that
75 * don't sign extend chars...
79 if (n
< 0) { /* replicate next byte -n+1 times */
81 if (n
== -128) /* nop */
85 for (b
= *bp
++; n
-- > 0;)
87 } else { /* copy next n+1 bytes literally */
96 // TIFFError(tif->tif_name,
97 // "PackBitsDecode: Not enough data for scanline %d",
99 // reallyPrint("Not enough data\n");
102 /* check for buffer overruns? */