GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsImageSByte.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsImageSByte.cpp - Signed Byte FITS image class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GFitsImageSByte.cpp
23 * @brief Signed Byte FITS image class implementation
24 * @author Juergen Knoedlseder
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GException.hpp"
32#include "GFitsCfitsio.hpp"
33#include "GFitsImageSByte.hpp"
34
35/* __ Method name definitions ____________________________________________ */
36
37/* __ Macros _____________________________________________________________ */
38#define G_BITPIX 10 //!< BITPIX code for TSBYTE
39
40/* __ Coding definitions _________________________________________________ */
41
42/* __ Debug definitions __________________________________________________ */
43
44
45
46/*==========================================================================
47 = =
48 = Constructors/destructors =
49 = =
50 ==========================================================================*/
51
52/***********************************************************************//**
53 * @brief Void constructor
54 ***************************************************************************/
56{
57 // Initialise class members
59
60 // Return
61 return;
62}
63
64
65/***********************************************************************//**
66 * @brief 1D image constructor
67 *
68 * @param[in] nx Number of pixels.
69 * @param[in] pixels Optional pointer to image pixel array
70 *
71 * Construct 1D instance by specifying the number of pixels in the image.
72 ***************************************************************************/
73GFitsImageSByte::GFitsImageSByte(const int& nx, const char* pixels) :
75{
76 // Initialise class members
78
79 // Construct data
81
82 // Return
83 return;
84}
85
86
87/***********************************************************************//**
88 * @brief 2D image constructor
89 *
90 * @param[in] nx Number of pixels in first dimension.
91 * @param[in] ny Number of pixels in second dimension.
92 * @param[in] pixels Optional pointer to image pixel array
93 *
94 * Construct 2D image by specifying the number of pixels in each dimension.
95 ***************************************************************************/
96GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny,
97 const char* pixels) :
98 GFitsImage(G_BITPIX, nx, ny)
99{
100 // Initialise class members
101 init_members();
102
103 // Construct data
105
106 // Return
107 return;
108}
109
110
111/***********************************************************************//**
112 * @brief 3D image constructor
113 *
114 * @param[in] nx Number of pixels in first dimension.
115 * @param[in] ny Number of pixels in second dimension.
116 * @param[in] nz Number of pixels in third dimension.
117 * @param[in] pixels Optional pointer to image pixel array
118 *
119 * Construct 3D image by specifying the number of pixels in each dimension.
120 ***************************************************************************/
121GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny, const int& nz,
122 const char* pixels) :
123 GFitsImage(G_BITPIX, nx, ny, nz)
124{
125 // Initialise class members
126 init_members();
127
128 // Construct data
130
131 // Return
132 return;
133}
134
135
136/***********************************************************************//**
137 * @brief 4D image constructor
138 *
139 * @param[in] nx Number of pixels in first dimension.
140 * @param[in] ny Number of pixels in second dimension.
141 * @param[in] nz Number of pixels in third dimension.
142 * @param[in] nt Number of pixels in forth dimension.
143 * @param[in] pixels Optional pointer to image pixel array
144 *
145 * Construct 4D image by specifying the number of pixels in each dimension.
146 ***************************************************************************/
147GFitsImageSByte::GFitsImageSByte(const int& nx, const int& ny, const int& nz,
148 const int& nt,
149 const char* pixels) :
150 GFitsImage(G_BITPIX, nx, ny, nz, nt)
151{
152 // Initialise class members
153 init_members();
154
155 // Construct data
157
158 // Return
159 return;
160}
161
162
163/***********************************************************************//**
164 * @brief Pixel array constructor
165 *
166 * @param[in] naxes Vector of number of pixels in each dimension.
167 * @param[in] pixels Optional pointer to image pixel array
168 *
169 * Construct instance of GFitsImageSByte by specifying the image dimension and
170 * the number of pixels in each dimension.
171 ***************************************************************************/
172GFitsImageSByte::GFitsImageSByte(const std::vector<int>& naxes,
173 const char* pixels) :
174 GFitsImage(G_BITPIX, naxes)
175{
176 // Initialise class members
177 init_members();
178
179 // Construct data
181
182 // Return
183 return;
184}
185
186
187/***********************************************************************//**
188 * @brief Type conversion constructor
189 *
190 * @param[in] image FITS image.
191 *
192 * This constructor performs the conversion of any image type into a signed
193 * byte image.
194 ***************************************************************************/
196 GFitsImage(image)
197{
198 // Initialise class members
199 init_members();
200
201 // Copy pixels
202 if (m_num_pixels > 0) {
203 m_pixels = new char[m_num_pixels];
204 for (int i = 0; i < m_num_pixels; ++i) {
205 m_pixels[i] = (char)image.pixel(i);
206 }
207 }
208
209 // Set number of bits per pixel
211
212 // Update header card
213 card("BITPIX").value(G_BITPIX);
214
215 // Return
216 return;
217}
218
219
220/***********************************************************************//**
221 * @brief Copy constructor
222 *
223 * @param[in] image FITS image.
224 ***************************************************************************/
226 GFitsImage(image)
227{
228 // Initialise class members
229 init_members();
230
231 // Copy members
232 copy_members(image);
233
234 // Return
235 return;
236}
237
238
239/***********************************************************************//**
240 * @brief Destructor
241 ***************************************************************************/
243{
244 // Free members
245 free_members();
246
247 // Return
248 return;
249}
250
251
252/*==========================================================================
253 = =
254 = Operators =
255 = =
256 ==========================================================================*/
257
258/***********************************************************************//**
259 * @brief Assignment operator
260 *
261 * @param[in] image FITS image.
262 ***************************************************************************/
264{
265 // Execute only if object is not identical
266 if (this != &image) {
267
268 // Copy base class members
269 this->GFitsImage::operator=(image);
270
271 // Free members
272 free_members();
273
274 // Initialise private members
275 init_members();
276
277 // Copy members
278 copy_members(image);
279
280 } // endif: object was not identical
281
282 // Return this object
283 return *this;
284}
285
286
287/***********************************************************************//**
288 * @brief Image pixel access operator
289 *
290 * @param[in] ix Pixel index (starting from 0).
291 *
292 * Provides access to an image pixel. No range checking is performed.
293 * Use the at(ix) method if range checking is required.
294 ***************************************************************************/
295char& GFitsImageSByte::operator()(const int& ix)
296{
297 // Load data
298 load_data();
299
300 // Return image pixel
301 return m_pixels[ix];
302}
303
304
305/***********************************************************************//**
306 * @brief 2D image pixel access operator
307 *
308 * @param[in] ix Pixel index in first dimension (starting from 0).
309 * @param[in] iy Pixel index in second dimension (starting from 0).
310 *
311 * Provides access to a pixel of a 2D image. No range checking or image
312 * dimension verification is performed. Use the at(ix,iy) method if range
313 * checking and image dimension verification is required.
314 ***************************************************************************/
315char& GFitsImageSByte::operator()(const int& ix, const int& iy)
316{
317 // Load data
318 load_data();
319
320 // Calculate pixel offset
321 int offset = ix + iy * m_naxes[0];
322
323 // Return image pixel
324 return m_pixels[offset];
325}
326
327
328/***********************************************************************//**
329 * @brief 3D image pixel access operator
330 *
331 * @param[in] ix Pixel index in first dimension (starting from 0).
332 * @param[in] iy Pixel index in second dimension (starting from 0).
333 * @param[in] iz Pixel index in third dimension (starting from 0).
334 *
335 * Provides access to a pixel of a 3D image. No range checking or image
336 * dimension verification is performed. Use the at(ix,iy) method if range
337 * checking and image dimension verification is required.
338 ***************************************************************************/
339char& GFitsImageSByte::operator()(const int& ix, const int& iy, const int& iz)
340{
341 // Load data
342 load_data();
343
344 // Calculate pixel offset
345 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
346
347 // Return image pixel
348 return m_pixels[offset];
349}
350
351
352/***********************************************************************//**
353 * @brief 4D image pixel access operator
354 *
355 * @param[in] ix Pixel index in first dimension (starting from 0).
356 * @param[in] iy Pixel index in second dimension (starting from 0).
357 * @param[in] iz Pixel index in third dimension (starting from 0).
358 * @param[in] it Pixel index in forth dimension (starting from 0).
359 *
360 * Provides access to a pixel of a 4D image. No range checking or image
361 * dimension verification is performed. Use the at(ix,iy) method if range
362 * checking and image dimension verification is required.
363 ***************************************************************************/
364char& GFitsImageSByte::operator()(const int& ix, const int& iy,
365 const int& iz, const int& it)
366{
367 // Load data
368 load_data();
369
370 // Calculate pixel offset
371 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
372
373 // Return image pixel
374 return m_pixels[offset];
375}
376
377
378/***********************************************************************//**
379 * @brief Image pixel access operator (const variant)
380 *
381 * @param[in] ix Pixel index (starting from 0).
382 *
383 * Provides access to an image pixel. No range checking is performed.
384 * Use the at(ix) method if range checking is required.
385 ***************************************************************************/
386const char& GFitsImageSByte::operator()(const int& ix) const
387{
388 // Load data
389 load_data();
390
391 // Return image pixel
392 return m_pixels[ix];
393}
394
395
396/***********************************************************************//**
397 * @brief 2D image pixel access operator (const variant)
398 *
399 * @param[in] ix Pixel index in first dimension (starting from 0).
400 * @param[in] iy Pixel index in second dimension (starting from 0).
401 *
402 * Provides access to a pixel of a 2D image. No range checking or image
403 * dimension verification is performed. Use the at(ix,iy) method if range
404 * checking and image dimension verification is required.
405 ***************************************************************************/
406const char& GFitsImageSByte::operator()(const int& ix, const int& iy) const
407{
408 // Load data
409 load_data();
410
411 // Calculate pixel offset
412 int offset = ix + iy * m_naxes[0];
413
414 // Return image pixel
415 return m_pixels[offset];
416}
417
418
419/***********************************************************************//**
420 * @brief 3D image pixel access operator (const variant)
421 *
422 * @param[in] ix Pixel index in first dimension (starting from 0).
423 * @param[in] iy Pixel index in second dimension (starting from 0).
424 * @param[in] iz Pixel index in third dimension (starting from 0).
425 *
426 * Provides access to a pixel of a 3D image. No range checking or image
427 * dimension verification is performed. Use the at(ix,iy) method if range
428 * checking and image dimension verification is required.
429 ***************************************************************************/
430const char& GFitsImageSByte::operator()(const int& ix, const int& iy,
431 const int& iz) const
432{
433 // Load data
434 load_data();
435
436 // Calculate pixel offset
437 int offset = ix + m_naxes[0] * (iy + iz * m_naxes[1]);
438
439 // Return image pixel
440 return m_pixels[offset];
441}
442
443
444/***********************************************************************//**
445 * @brief 4D image pixel access operator (const variant)
446 *
447 * @param[in] ix Pixel index in first dimension (starting from 0).
448 * @param[in] iy Pixel index in second dimension (starting from 0).
449 * @param[in] iz Pixel index in third dimension (starting from 0).
450 * @param[in] it Pixel index in forth dimension (starting from 0).
451 *
452 * Provides access to a pixel of a 4D image. No range checking or image
453 * dimension verification is performed. Use the at(ix,iy) method if range
454 * checking and image dimension verification is required.
455 ***************************************************************************/
456const char& GFitsImageSByte::operator()(const int& ix, const int& iy,
457 const int& iz, const int& it) const
458{
459 // Load data
460 load_data();
461
462 // Calculate pixel offset
463 int offset = ix + m_naxes[0] * (iy + m_naxes[1] * (iz + it * m_naxes[2]));
464
465 // Return image pixel
466 return m_pixels[offset];
467}
468
469
470/*==========================================================================
471 = =
472 = Public methods =
473 = =
474 ==========================================================================*/
475
476/***********************************************************************//**
477 * @brief Clear instance
478 *
479 * This method properly resets the object to an initial state.
480 ***************************************************************************/
482{
483 // Free class members (base and derived classes, derived class first)
484 free_members();
487
488 // Initialise members
491 init_members();
492
493 // Return
494 return;
495}
496
497
498/***********************************************************************//**
499 * @brief Clone FITS image
500 *
501 * Cloning provides a copy of the FITS file. Cloning is used to allocate
502 * derived classes into a base class pointer.
503 ***************************************************************************/
505{
506 // Clone this image
507 return new GFitsImageSByte(*this);
508}
509
510
511/***********************************************************************//**
512 * @brief Image pixel access operator
513 *
514 * @param[in] ix Pixel index (starting from 0).
515 *
516 * Provides access to a pixel of an image including range checking. Note that
517 * this method does not necessarily restrict do 1D images but generally
518 * applies to all image dimensions.
519 ***************************************************************************/
520char& GFitsImageSByte::at(const int& ix)
521{
522 // Load data
523 load_data();
524
525 // Return image pixel
526 return (m_pixels[offset(ix)]);
527}
528
529
530/***********************************************************************//**
531 * @brief 2D image pixel access operator
532 *
533 * @param[in] ix Pixel index in first dimension (starting from 0).
534 * @param[in] iy Pixel index in second dimension (starting from 0).
535 *
536 * Provides access to a pixel of an image including range checking.
537 ***************************************************************************/
538char& GFitsImageSByte::at(const int& ix, const int& iy)
539{
540 // Load data
541 load_data();
542
543 // Return image pixel
544 return (m_pixels[offset(ix,iy)]);
545}
546
547
548/***********************************************************************//**
549 * @brief 3D image pixel access operator
550 *
551 * @param[in] ix Pixel index in first dimension (starting from 0).
552 * @param[in] iy Pixel index in second dimension (starting from 0).
553 * @param[in] iz Pixel index in third dimension (starting from 0).
554 *
555 * Provides access to a pixel of an image including range checking.
556 ***************************************************************************/
557char& GFitsImageSByte::at(const int& ix, const int& iy, const int& iz)
558{
559 // Load data
560 load_data();
561
562 // Return image pixel
563 return (m_pixels[offset(ix,iy,iz)]);
564}
565
566
567/***********************************************************************//**
568 * @brief 4D image pixel access operator
569 *
570 * @param[in] ix Pixel index in first dimension (starting from 0).
571 * @param[in] iy Pixel index in second dimension (starting from 0).
572 * @param[in] iz Pixel index in third dimension (starting from 0).
573 * @param[in] it Pixel index in forth dimension (starting from 0).
574 *
575 * Provides access to a pixel of an image including range checking.
576 ***************************************************************************/
577char& GFitsImageSByte::at(const int& ix, const int& iy, const int& iz,
578 const int& it)
579{
580 // Load data
581 load_data();
582
583 // Return image pixel
584 return (m_pixels[offset(ix,iy,iz,it)]);
585}
586
587
588/***********************************************************************//**
589 * @brief Image pixel access operator (const variant)
590 *
591 * @param[in] ix Pixel index (starting from 0).
592 *
593 * Provides access to a pixel of an image including range checking.
594 ***************************************************************************/
595const char& GFitsImageSByte::at(const int& ix) const
596{
597 // Load data
598 load_data();
599
600 // Return image pixel
601 return (m_pixels[offset(ix)]);
602}
603
604
605/***********************************************************************//**
606 * @brief 2D image pixel access operator (const variant)
607 *
608 * @param[in] ix Pixel index in first dimension (starting from 0).
609 * @param[in] iy Pixel index in second dimension (starting from 0).
610 *
611 * Provides access to a pixel of an image including range checking.
612 ***************************************************************************/
613const char& GFitsImageSByte::at(const int& ix, const int& iy) const
614{
615 // Load data
616 load_data();
617
618 // Return image pixel
619 return (m_pixels[offset(ix,iy)]);
620}
621
622
623/***********************************************************************//**
624 * @brief 3D image pixel access operator (const variant)
625 *
626 * @param[in] ix Pixel index in first dimension (starting from 0).
627 * @param[in] iy Pixel index in second dimension (starting from 0).
628 * @param[in] iz Pixel index in third dimension (starting from 0).
629 *
630 * Provides access to a pixel of an image including range checking.
631 ***************************************************************************/
632const char& GFitsImageSByte::at(const int& ix, const int& iy,
633 const int& iz) const
634{
635 // Load data
636 load_data();
637
638 // Return image pixel
639 return (m_pixels[offset(ix,iy,iz)]);
640}
641
642
643/***********************************************************************//**
644 * @brief 4D image pixel access operator (const variant)
645 *
646 * @param[in] ix Pixel index in first dimension (starting from 0).
647 * @param[in] iy Pixel index in second dimension (starting from 0).
648 * @param[in] iz Pixel index in third dimension (starting from 0).
649 * @param[in] it Pixel index in forth dimension (starting from 0).
650 *
651 * Provides access to a pixel of an image including range checking.
652 ***************************************************************************/
653const char& GFitsImageSByte::at(const int& ix, const int& iy,
654 const int& iz, const int& it) const
655{
656 // Load data
657 load_data();
658
659 // Return image pixel
660 return (m_pixels[offset(ix,iy,iz,it)]);
661}
662
663
664/***********************************************************************//**
665 * @brief Return value of image pixel
666 *
667 * @param[in] ix Pixel index (starting from 0).
668 *
669 * Returns the value of an image pixel as double precision floating point
670 * value. This method performs range checking.
671 ***************************************************************************/
672double GFitsImageSByte::pixel(const int& ix) const
673{
674 // Return pixel value
675 return (double(this->at(ix)));
676}
677
678
679/***********************************************************************//**
680 * @brief Return value of image pixel (2D version)
681 *
682 * @param[in] ix Pixel index in first dimension (starting from 0).
683 * @param[in] iy Pixel index in second dimension (starting from 0).
684 *
685 * Returns the value of an image pixel as double precision floating point
686 * value. This method performs range checking.
687 ***************************************************************************/
688double GFitsImageSByte::pixel(const int& ix, const int& iy) const
689{
690 // Return pixel value
691 return (double(this->at(ix,iy)));
692}
693
694
695/***********************************************************************//**
696 * @brief Return value of image pixel (3D version)
697 *
698 * @param[in] ix Pixel index in first dimension (starting from 0).
699 * @param[in] iy Pixel index in second dimension (starting from 0).
700 * @param[in] iz Pixel index in third dimension (starting from 0).
701 *
702 * Returns the value of an image pixel as double precision floating point
703 * value. This method performs range checking.
704 ***************************************************************************/
705double GFitsImageSByte::pixel(const int& ix, const int& iy, const int& iz) const
706{
707 // Return pixel value
708 return (double(this->at(ix,iy,iz)));
709}
710
711
712/***********************************************************************//**
713 * @brief Return value of image pixel (4D version)
714 *
715 * @param[in] ix Pixel index in first dimension (starting from 0).
716 * @param[in] iy Pixel index in second dimension (starting from 0).
717 * @param[in] iz Pixel index in third dimension (starting from 0).
718 * @param[in] it Pixel index in forth dimension (starting from 0).
719 *
720 * Returns the value of an image pixel as double precision floating point
721 * value. This method performs range checking.
722 ***************************************************************************/
723double GFitsImageSByte::pixel(const int& ix, const int& iy, const int& iz,
724 const int& it) const
725{
726 // Return pixel value
727 return (double(this->at(ix,iy,iz,it)));
728}
729
730
731/***********************************************************************//**
732 * @brief Return pointer to image pixel
733 ***************************************************************************/
735{
736 // Load data
737 load_data();
738
739 // Return
740 return m_pixels;
741}
742
743
744/***********************************************************************//**
745 * @brief Return image type
746 ***************************************************************************/
748{
749 // Return type
750 return __TSBYTE;
751}
752
753
754/*==========================================================================
755 = =
756 = Private methods =
757 = =
758 ==========================================================================*/
759
760/***********************************************************************//**
761 * @brief Initialise class members
762 ***************************************************************************/
764{
765 // Initialise members
767 m_pixels = NULL;
768 m_nulval = NULL;
769
770 // Return
771 return;
772}
773
774
775/***********************************************************************//**
776 * @brief Copy class members
777 *
778 * @param image FITS image to copy
779 *
780 * Copy class members. If the pixel array is linked the pointer to the array
781 * is copied. Otherwise a copy of the image pixels will be created.
782 ***************************************************************************/
784{
785 // Fetch column data if not yet fetched. The casting circumvents the
786 // const correctness
787 bool not_loaded = (image.m_pixels == NULL);
788 if (not_loaded) {
789 const_cast<GFitsImageSByte*>(&image)->fetch_data();
790 }
791
792 // Copy pixels
793 if (m_num_pixels > 0 && image.m_pixels != NULL) {
794 m_pixels = new char[m_num_pixels];
795 for (int i = 0; i < m_num_pixels; ++i) {
796 m_pixels[i] = image.m_pixels[i];
797 }
798 }
799
800 // Copy NULL value
801 alloc_nulval(image.m_nulval);
802
803 // Small memory option: release column if it was fetch above
804 #if defined(G_SMALL_MEMORY)
805 if (not_loaded) {
806 const_cast<GFitsImageSByte*>(&image)->release_data();
807 }
808 #endif
809
810 // Return
811 return;
812}
813
814
815/***********************************************************************//**
816 * @brief Delete class members
817 ***************************************************************************/
819{
820 // Free memory
821 if (m_pixels != NULL) delete [] m_pixels;
822 if (m_nulval != NULL) delete m_nulval;
823
824 // Mark memory as free
825 m_pixels = NULL;
826 m_nulval = NULL;
827
828 // Return
829 return;
830}
831
832
833/***********************************************************************//**
834 * @brief Allocate data
835 ***************************************************************************/
837{
838 // Release any existing data
839 release_data();
840
841 // Allocate new data
842 if (m_num_pixels > 0) {
843 m_pixels = new char[m_num_pixels];
844 }
845
846 // Return
847 return;
848}
849
850
851/***********************************************************************//**
852 * @brief Initialise data
853 ***************************************************************************/
855{
856 // Initialise data if they exist
857 if (m_pixels != NULL) {
858 for (int i = 0; i < m_num_pixels; ++i) {
859 m_pixels[i] = 0;
860 }
861 }
862
863 // Return
864 return;
865}
866
867
868/***********************************************************************//**
869 * @brief Release data
870 ***************************************************************************/
872{
873 // Free any existing memory
874 if (m_pixels != NULL) delete [] m_pixels;
875
876 // Mark pointer as free
877 m_pixels = NULL;
878
879 // Return
880 return;
881}
882
883
884/***********************************************************************//**
885 * @brief Construct data from array
886 *
887 * @param[in] pixels Optional pointer to pixel array.
888 *
889 * Initialise pixel data from an optional pixel array. If the pointer is
890 * NULL the image is simply initialised. This method supports all
891 * constructors.
892 ***************************************************************************/
893void GFitsImageSByte::construct_data(const char* pixels)
894{
895 // If there are pixels then allocate array
896 if (m_num_pixels > 0) {
897
898 // Allocate data
899 alloc_data();
900
901 // If no pixel array has been specified then simply initialise data
902 if (pixels == NULL) {
903 init_data();
904 }
905
906 // ... otherwise copy pixels
907 else {
908 for (int i = 0; i < m_num_pixels; ++i) {
909 m_pixels[i] = pixels[i];
910 }
911 }
912
913 } // endif: there are pixels in image
914
915 // Return
916 return;
917}
918
919
920/***********************************************************************//**
921 * @brief Load data
922 *
923 * Load the image data if no pixels have been allocated.
924 ***************************************************************************/
926{
927 // If image pixels are not available then fetch them now.
928 if (m_pixels == NULL) {
929 const_cast<GFitsImageSByte*>(this)->fetch_data();
930 }
931
932 // Return
933 return;
934}
935
936
937/***********************************************************************//**
938 * @brief Allocates nul value
939 *
940 * @param[in] value Nul value.
941 ***************************************************************************/
942void GFitsImageSByte::alloc_nulval(const void* value)
943{
944 // Free any existing memory
945 if (m_nulval != NULL) delete m_nulval;
946
947 // Mark pointer as free
948 m_nulval = NULL;
949
950 // If we have valid value, allocate and set nul value
951 if (value != NULL) {
952 m_nulval = new char;
953 *m_nulval = *((char*)value);
954 }
955
956 // Return
957 return;
958}
Exception handler interface definition.
CFITSIO interface header.
#define __TSBYTE
#define G_BITPIX
Defines the number of bits per pixel.
#define G_BITPIX
BITPIX code for TSBYTE.
Signed Byte FITS image class definition.
void free_members(void)
Delete class members.
Definition GFitsHDU.cpp:505
void init_members(void)
Initialise class members.
Definition GFitsHDU.cpp:462
GFitsHeaderCard & card(const int &cardno)
Return header card.
Definition GFitsHDU.hpp:259
void value(const std::string &value)
Set string value of header card.
Signed Byte FITS image class.
void alloc_data(void)
Allocate data.
virtual ~GFitsImageSByte(void)
Destructor.
char & operator()(const int &ix)
Image pixel access operator.
double pixel(const int &ix) const
Return value of image pixel.
void release_data(void)
Release data.
void init_members(void)
Initialise class members.
GFitsImageSByte * clone(void) const
Clone FITS image.
void load_data(void) const
Load data.
void init_data(void)
Initialise data.
char * m_nulval
NULL value.
void construct_data(const char *pixels)
Construct data from array.
void free_members(void)
Delete class members.
int type(void) const
Return image type.
GFitsImageSByte & operator=(const GFitsImageSByte &image)
Assignment operator.
char & at(const int &ix)
Image pixel access operator.
void alloc_nulval(const void *value)
Allocates nul value.
void copy_members(const GFitsImageSByte &image)
Copy class members.
void clear(void)
Clear instance.
char * m_pixels
Pixels.
GFitsImageSByte(void)
Void constructor.
void * pixels(void)
Return pointer to image pixel.
Abstract FITS image base class.
virtual double pixel(const int &ix) const =0
int offset(const int &ix) const
Return pixel offset.
void free_members(void)
Delete class members.
void fetch_data(void)
Fetch image pixels.
long * m_naxes
Number of pixels in each dimension.
int m_bitpix
Number of Bits/pixel.
int m_num_pixels
Number of image pixels.
GFitsImage & operator=(const GFitsImage &image)
Assignment operator.
void init_members(void)
Initialise class members.