Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Purpose: Implementation of the PCIDSKInterfaces class. 4 : * 5 : ****************************************************************************** 6 : * Copyright (c) 2009 7 : * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, 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 : #include "core/pcidsk_utils.h" 34 : 35 : using namespace PCIDSK; 36 : 37 : /************************************************************************/ 38 : /* PCIDSKInterfaces() */ 39 : /* */ 40 : /* This constructor just defaults all the interfaces and */ 41 : /* functions to the default implementation. */ 42 : /************************************************************************/ 43 : 44 641 : PCIDSKInterfaces::PCIDSKInterfaces() 45 : 46 : { 47 641 : io = GetDefaultIOInterfaces(); 48 641 : OpenEDB = DefaultOpenEDB; 49 641 : MergeRelativePath = DefaultMergeRelativePath; 50 641 : CreateMutex = DefaultCreateMutex; 51 641 : Debug = DefaultDebug; 52 : 53 : #if defined(HAVE_LIBJPEG) 54 641 : JPEGDecompressBlock = LibJPEG_DecompressBlock; 55 641 : JPEGCompressBlock = LibJPEG_CompressBlock; 56 : #else 57 : JPEGDecompressBlock = NULL; 58 : JPEGCompressBlock = NULL; 59 : #endif 60 641 : } 61 : 62 : /** 63 : 64 : \var const IOInterfaces *PCIDSKInterfaces::io; 65 : 66 : \brief Pointer to IO Interfaces. 67 : 68 : ***************************************************************************/ 69 : 70 : /** 71 : 72 : \var Mutex *(*PCIDSKInterfaces::CreateMutex)(void); 73 : 74 : \brief Function to create a mutex 75 : 76 : ***************************************************************************/ 77 : 78 : /** 79 : 80 : \var void (*PCIDSKInterfaces::JPEGDecompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int dst_bytes, int xsize, int ysize, eChanType pixel_type); 81 : 82 : \brief Function to decompress a jpeg block 83 : 84 : This function may be NULL if there is no jpeg interface available. 85 : 86 : The default implementation is implemented using libjpeg. 87 : 88 : The function decodes the jpeg compressed image in src_data (src_bytes long) 89 : into dst_data (dst_bytes long) as image data. The result should be exactly 90 : dst_bytes long, and will be an image of xsize x ysize of type pixel_type 91 : (currently on CHN_8U is allowed). 92 : 93 : Errors should be thrown as exceptions. 94 : 95 : ***************************************************************************/ 96 : 97 : /** 98 : 99 : \var void (*PCIDSKInterfaces::JPEGCompressBlock)(uint8 *src_data, int src_bytes, uint8 *dst_data, int &dst_bytes, int xsize, int ysize, eChanType pixel_type); 100 : 101 : \brief Function to compress a jpeg block 102 : 103 : This function may be NULL if there is no jpeg interface available. 104 : 105 : The default implementation is implemented using libjpeg. 106 : 107 : The function encodes the image in src_data (src_bytes long) 108 : into dst_data as compressed jpeg data. The passed in value of dst_bytes is the 109 : size of the passed in dst_data array (it should be large enough to hold 110 : any compressed result0 and dst_bytes will be returned with the resulting 111 : actual number of bytes used. 112 : 113 : Errors should be thrown as exceptions. 114 : 115 : ***************************************************************************/ 116 :