2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: ildecompress.c /main/3 1995/10/23 15:46:32 rswiston $ */
24 /**---------------------------------------------------------------------
26 *** (c)Copyright 1991 Hewlett-Packard Co.
28 *** RESTRICTED RIGHTS LEGEND
29 *** Use, duplication, or disclosure by the U.S. Government is subject to
30 *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
31 *** Technical Data and Computer Software clause in DFARS 252.227-7013.
32 *** Hewlett-Packard Company
33 *** 3000 Hanover Street
34 *** Palo Alto, CA 94304 U.S.A.
35 *** Rights for non-DOD U.S. Government Departments and Agencies are as set
36 *** forth in FAR 52.227-19(c)(1,2).
38 ***-------------------------------------------------------------------*/
41 #include "ilpipelem.h"
46 /* =================================================================================
48 -------------------- ilDecompress() --------------------
49 Add a filter to "pipe" (guaranteed to be a pipe in IL_PIPE_FORMING state)
50 which decompresses the compressed pipe image.
52 ================================================================================= */
54 IL_PRIVATE void _ilDecompress (
61 ilImageFormat imformat;
64 /* Get ptr to pipe info and check state. We should NOT FORCE decompression */
65 state = ilGetPipeInfo(pipe, FALSE, &info, &imdes, &imformat);
67 /* Verify status of the pipe */
68 if (state != IL_PIPE_FORMING) {
69 if (!pipe->context->error) {
70 ilDeclarePipeInvalid(pipe, IL_ERROR_PIPE_STATE);
75 /* Call the appropriate decompression function */
76 switch (imdes.compression) {
77 /* Image is already decompressed! Continue, this is NOT an error! */
82 if (!_ilDecompG3 (pipe, &info, &imdes))
86 case IL_G4: /* Currently supported CCITT Group4 decompression format */
87 if (!_ilDecompG4 (pipe, &info, &imdes))
91 case IL_LZW: /* Currently supported LZW format */
92 if (!_ilDecompLZW (pipe, &info, &imdes, &imformat))
97 if (!_ilDecompPackbits (pipe, &info, &imdes, &imformat))
101 case IL_JPEG: /* Currently supported JPEG format */
102 if (!_ilDecompJPEG (pipe, &info, &imdes))
105 default: /* imdes.compression is not valid */
106 ilDeclarePipeInvalid (pipe, IL_ERROR_COMPRESSION);
111 pipe->context->error = IL_OK;