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 293 : PCIDSKInterfaces::PCIDSKInterfaces()
44 :
45 : {
46 293 : io = GetDefaultIOInterfaces();
47 293 : OpenEDB = DefaultOpenEDB;
48 293 : CreateMutex = DefaultCreateMutex;
49 :
50 : #if defined(HAVE_LIBJPEG)
51 293 : JPEGDecompressBlock = LibJPEG_DecompressBlock;
52 293 : JPEGCompressBlock = LibJPEG_CompressBlock;
53 : #else
54 : JPEGDecompressBlock = NULL;
55 : JPEGCompressBlock = NULL;
56 : #endif
57 293 : }
58 :
59 : /**
60 :
61 : \var const IOInterfaces *PCIDSKInterfaces::io;
62 :
63 : \brief Pointer to IO Interfaces.
64 :
65 : ***************************************************************************/
66 :
67 : /**
68 :
69 : \var Mutex *(*PCIDSKInterfaces::CreateMutex)(void);
70 :
71 : \brief Function to create a mutex
72 :
73 : ***************************************************************************/
74 :
75 : /**
76 :
77 : \var void (*PCIDSKInterfaces::JPEGDecompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int dst_bytes, int xsize, int ysize, eChanType pixel_type);
78 :
79 : \brief Function to decompress a jpeg block
80 :
81 : This function may be NULL if there is no jpeg interface available.
82 :
83 : The default implementation is implemented using libjpeg.
84 :
85 : The function decodes the jpeg compressed image in src_data (src_bytes long)
86 : into dst_data (dst_bytes long) as image data. The result should be exactly
87 : dst_bytes long, and will be an image of xsize x ysize of type pixel_type
88 : (currently on CHN_8U is allowed).
89 :
90 : Errors should be thrown as exceptions.
91 :
92 : ***************************************************************************/
93 :
94 : /**
95 :
96 : \var void (*PCIDSKInterfaces::JPEGCompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int &dst_bytes, int xsize, int ysize, eChanType pixel_type);
97 :
98 : \brief Function to compress a jpeg block
99 :
100 : This function may be NULL if there is no jpeg interface available.
101 :
102 : The default implementation is implemented using libjpeg.
103 :
104 : The function encodes the image in src_data (src_bytes long)
105 : into dst_data as compressed jpeg data. The passed in value of dst_bytes is the
106 : size of the passed in dst_data array (it should be large enough to hold
107 : any compressed result0 and dst_bytes will be returned with the resulting
108 : actual number of bytes used.
109 :
110 : Errors should be thrown as exceptions.
111 :
112 : ***************************************************************************/
113 :
|