| 209 | } |
| 210 | |
| 211 | char* VSIImage::decodeTile(int no, int row, int col) const { |
| 212 | int size = _tileSizeX*_tileSizeY*3; |
| 213 | char* buf = new char[size]; |
| 214 | std::fill(buf, buf + size, 255); |
| 215 | if (no!=_tileCoords.size()) { |
| 216 | ifstream ets; |
| 217 | ets.open(_etsFile.c_str(), ios::in | ios::binary); |
| 218 | ets.seekg(_tileOffsets[no]); |
| 219 | ets.read(buf, size); |
| 220 | if (_compressionType == 0) { |
| 221 | return buf; |
| 222 | } |
| 223 | else if (_compressionType == 3) { |
| 224 | JPEG2000Codec cod; |
| 225 | cod.decode((unsigned char*)buf, size, size); |
| 226 | } |
| 227 | else if (_compressionType == 2 || _compressionType == 5) { |
| 228 | jpeg_decompress_struct cinfo; |
| 229 | jpeg_error_mgr jerr; //error handling |
| 230 | jpeg_create_decompress(&cinfo); |
| 231 | cinfo.err = jpeg_std_error(&jerr); |
| 232 | jpeg_mem_src(&cinfo, (unsigned char*)buf, size); |
| 233 | jpeg_read_header(&cinfo, true); |
| 234 | if (_compressionType == 2) { |
| 235 | cinfo.jpeg_color_space = JCS_YCbCr; |
| 236 | } else { |
| 237 | cinfo.jpeg_color_space = JCS_RGB; |
| 238 | } |
| 239 | jpeg_start_decompress(&cinfo); |
| 240 | unsigned char* outBuf = new unsigned char[size]; |
| 241 | unsigned char* line = outBuf; |
| 242 | while (cinfo.output_scanline < cinfo.output_height) { |
| 243 | jpeg_read_scanlines (&cinfo, &line, 1); |
| 244 | line += 3*cinfo.output_width; |
| 245 | } |
| 246 | jpeg_finish_decompress(&cinfo); |
| 247 | jpeg_destroy_decompress(&cinfo); |
| 248 | delete[] buf; |
| 249 | buf = (char*)outBuf; |
| 250 | } |
| 251 | } |
| 252 | return buf; |
| 253 | } |
| 254 | |
| 255 | void* VSIImage::readDataFromImage(const long long& startX, const long long& startY, const unsigned long long& width, |
| 256 | const unsigned long long& height, const unsigned int& level) { |
nothing calls this directly
no test coverage detected