Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtHelp / il / ildecompress.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: ildecompress.c /main/3 1995/10/23 15:46:32 rswiston $ */
24 /**---------------------------------------------------------------------
25 ***     
26 ***    (c)Copyright 1991 Hewlett-Packard Co.
27 ***    
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).
37 ***
38 ***-------------------------------------------------------------------*/
39
40 #include "ilint.h"
41 #include "ilpipelem.h"
42 #include "ildecomp.h"
43 #include "ilcodec.h"
44 #include "ilerrors.h"
45
46 /* =================================================================================    
47  
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.
51
52    ================================================================================= */
53
54 IL_PRIVATE void _ilDecompress (
55     ilPipe              pipe
56     )
57 {
58     unsigned int        state;
59     ilPipeInfo          info;                              
60     ilImageDes          imdes;
61     ilImageFormat       imformat;
62      
63
64     /* Get ptr to pipe info and check state.  We should NOT FORCE decompression */
65     state =  ilGetPipeInfo(pipe, FALSE, &info, &imdes, &imformat);                    
66
67     /* Verify status of the pipe */
68     if (state != IL_PIPE_FORMING) {
69         if (!pipe->context->error) {
70             ilDeclarePipeInvalid(pipe, IL_ERROR_PIPE_STATE);
71             return;
72         }
73     }                          
74
75     /* Call the appropriate decompression function */
76     switch (imdes.compression) {
77             /* Image is already decompressed!  Continue, this is NOT an error! */
78         case IL_UNCOMPRESSED: 
79                 break;
80
81         case IL_G3:
82                 if (!_ilDecompG3 (pipe, &info, &imdes))
83                     return;
84                 break;                       
85
86         case IL_G4:           /* Currently supported CCITT Group4 decompression format */ 
87                 if (!_ilDecompG4 (pipe, &info, &imdes))                      
88                     return;                                                               
89                 break;                                                                    
90
91         case IL_LZW:          /* Currently supported LZW format */
92                 if (!_ilDecompLZW (pipe, &info, &imdes, &imformat))
93                     return;
94                 break;                       
95
96         case IL_PACKBITS:
97                 if (!_ilDecompPackbits (pipe, &info, &imdes, &imformat))
98                     return;
99                 break;                         
100
101         case IL_JPEG:         /* Currently supported JPEG format */
102                 if (!_ilDecompJPEG (pipe, &info, &imdes))
103                     return;
104                 break;
105         default:              /* imdes.compression is not valid       */
106                 ilDeclarePipeInvalid (pipe, IL_ERROR_COMPRESSION);
107                 return;
108
109     }  /* end switch */
110
111     pipe->context->error = IL_OK;
112 }
113
114