1 : /******************************************************************************
2 : *
3 : * Purpose: Implementation of the PCIDSKInterfaces class.
4 : *
5 : ******************************************************************************
6 : * Copyright (c) 2009
7 : * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
8 : *
9 : * Permission is hereby granted, free of charge, to any person obtaining a
10 : * copy of this software and associated documentation files (the "Software"),
11 : * to deal in the Software without restriction, including without limitation
12 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 : * and/or sell copies of the Software, and to permit persons to whom the
14 : * Software is furnished to do so, subject to the following conditions:
15 : *
16 : * The above copyright notice and this permission notice shall be included
17 : * in all copies or substantial portions of the Software.
18 : *
19 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 : * DEALINGS IN THE SOFTWARE.
26 : ****************************************************************************/
27 :
28 : #include "pcidsk_config.h"
29 : #include "pcidsk_types.h"
30 : #include "pcidsk_utils.h"
31 : #include "pcidsk_interfaces.h"
32 : #include "pcidsk_mutex.h"
33 :
34 : using namespace PCIDSK;
35 :
36 : /************************************************************************/
37 : /* PCIDSKInterfaces() */
38 : /* */
39 : /* This constructor just defaults all the interfaces and */
40 : /* functions to the default implementation. */
41 : /************************************************************************/
42 :
43 191 : PCIDSKInterfaces::PCIDSKInterfaces()
44 :
45 : {
46 191 : io = GetDefaultIOInterfaces();
47 191 : CreateMutex = DefaultCreateMutex;
48 :
49 : #if defined(HAVE_LIBJPEG)
50 191 : JPEGDecompressBlock = LibJPEG_DecompressBlock;
51 191 : JPEGCompressBlock = LibJPEG_CompressBlock;
52 : #else
53 : JPEGDecompressBlock = NULL;
54 : JPEGCompressBlock = NULL;
55 : #endif
56 191 : }
57 :
58 : /**
59 :
60 : \var const IOInterfaces *PCIDSKInterfaces::io;
61 :
62 : \brief Pointer to IO Interfaces.
63 :
64 : ***************************************************************************/
65 :
66 : /**
67 :
68 : \var Mutex *(*PCIDSKInterfaces::CreateMutex)(void);
69 :
70 : \brief Function to create a mutex
71 :
72 : ***************************************************************************/
73 :
74 : /**
75 :
76 : \var void (*PCIDSKInterfaces::JPEGDecompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int dst_bytes, int xsize, int ysize, eChanType pixel_type);
77 :
78 : \brief Function to decompress a jpeg block
79 :
80 : This function may be NULL if there is no jpeg interface available.
81 :
82 : The default implementation is implemented using libjpeg.
83 :
84 : The function decodes the jpeg compressed image in src_data (src_bytes long)
85 : into dst_data (dst_bytes long) as image data. The result should be exactly
86 : dst_bytes long, and will be an image of xsize x ysize of type pixel_type
87 : (currently on CHN_8U is allowed).
88 :
89 : Errors should be thrown as exceptions.
90 :
91 : ***************************************************************************/
92 :
93 : /**
94 :
95 : \var void (*PCIDSKInterfaces::JPEGCompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int &dst_bytes, int xsize, int ysize, eChanType pixel_type);
96 :
97 : \brief Function to compress a jpeg block
98 :
99 : This function may be NULL if there is no jpeg interface available.
100 :
101 : The default implementation is implemented using libjpeg.
102 :
103 : The function encodes the image in src_data (src_bytes long)
104 : into dst_data as compressed jpeg data. The passed in value of dst_bytes is the
105 : size of the passed in dst_data array (it should be large enough to hold
106 : any compressed result0 and dst_bytes will be returned with the resulting
107 : actual number of bytes used.
108 :
109 : Errors should be thrown as exceptions.
110 :
111 : ***************************************************************************/
112 :
|