summaryrefslogtreecommitdiffstats
path: root/tksao/frame/fitscompress.C
blob: a27d32211469cb05625000e1ced95808ba215f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#include "fitsimage.h"
#include "compress.h"
#include "rice.h"
#include "gzip.h"
#include "hcompress.h"
#include "plio.h"

void FitsImage::initCompress()
{
  int bitpix = fits_->getInteger("ZBITPIX",0);
  char* type = fits_->getString("ZCMPTYPE");
  if (!bitpix || !type)
    return ;

  if (post_)
    delete post_;
  post_ = NULL;

  if (!strncmp(type,"RICE_1",6) || !(strncmp(type,"RICE_ONE",8)))
    switch (bitpix) {
    case 8: 
      post_ = new FitsRicem<unsigned char>(fits_);
      break;
    case 16:
      post_ = new FitsRicem<short>(fits_);
      break;
    case -16:
      post_ = new FitsRicem<unsigned short>(fits_);
      break;
    case 32:
      post_ = new FitsRicem<int>(fits_);
      break;
    case 64:
      post_ = new FitsRicem<long long>(fits_);
      break;
    case -32:
      post_ = new FitsRicem<float>(fits_);
      break;
    case -64:
      post_ = new FitsRicem<double>(fits_);
      break;
    }
  else if (!strncmp(type,"GZIP_1",6) || !strncmp(type,"GZIP_2",6))
    switch (bitpix) {
    case 8: 
      post_ = new FitsGzipm<unsigned char>(fits_);
      break;
    case 16:
      post_ = new FitsGzipm<short>(fits_);
      break;
    case -16:
      post_ = new FitsGzipm<unsigned short>(fits_);
      break;
    case 32:
      post_ = new FitsGzipm<int>(fits_);
      break;
    case 64:
      post_ = new FitsGzipm<long long>(fits_);
      break;
    case -32:
      post_ = new FitsGzipm<float>(fits_);
      break;
    case -64:
      post_ = new FitsGzipm<double>(fits_);
      break;
    }
  else if (!strncmp(type,"PLIO_1",6))
    switch (bitpix) {
    case 8: 
      post_ = new FitsPliom<unsigned char>(fits_);
      break;
    case 16:
      post_ = new FitsPliom<short>(fits_);
      break;
    case -16:
      post_ = new FitsPliom<unsigned short>(fits_);
      break;
    case 32:
      post_ = new FitsPliom<int>(fits_);
      break;
    case 64:
      post_ = new FitsPliom<long long>(fits_);
      break;
    case -32:
      post_ = new FitsPliom<float>(fits_);
      break;
    case -64:
      post_ = new FitsPliom<double>(fits_);
      break;
    }
  else if (!strncmp(type,"HCOMPRESS_1",11))
    switch (bitpix) {
    case 8: 
      post_ = new FitsHcompressm<unsigned char>(fits_);
      break;
    case 16:
      post_ = new FitsHcompressm<short>(fits_);
      break;
    case -16:
      post_ = new FitsHcompressm<unsigned short>(fits_);
      break;
    case 32:
      post_ = new FitsHcompressm<int>(fits_);
      break;
    case 64:
      post_ = new FitsHcompressm<long long>(fits_);
      break;
    case -32:
      post_ = new FitsHcompressm<float>(fits_);
      break;
    case -64:
      post_ = new FitsHcompressm<double>(fits_);
      break;
    }
  else {
    ; // unknown compression type
  }

  return;
}