diff --git a/Makefile b/Makefile index 0d1ad48..97f19c1 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ APP = simpleskycam OBJECTS := $(OBJECTS) gui.oo main.oo \ video.oo videoframe.oo \ videodev.oo videodev-v4l2.oo videodev-dumpfile.oo \ - convert.oo filter.oo detect.oo json.oo configuration.oo ser.oo + convert.oo filter.oo detect.oo json.oo configuration.oo ser.oo dng.oo DISTNAME=simpleskycam-$(VERSION) DEPENDFILE=.depend diff --git a/dng.cc b/dng.cc index 30c9a32..dff5385 100644 --- a/dng.cc +++ b/dng.cc @@ -26,11 +26,25 @@ DNG::~DNG() { } } +/* + Run-time detection if we are little- or big-endian. + */ +int DNG::IsBigEndian(void) { + int i = 1; + return ! *((char *)&i); +} + /* Sets the file name of the DNG file to be written. Returns -1 on failure, 0 on success. */ int DNG::setFile(char * file) { + /* + w = write + l = little endian + b = big endian + -> if neither l or b is given, data is written in native CPU format + */ if (!(tif = TIFFOpen(file, "w"))) { return -1; } @@ -139,7 +153,7 @@ int DNG::writeFile(void * data) { TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA); TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, CFARepeatPattern); // 0 = Red, 1 = Green, 2 = Blue - TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\001\000\002\001"); // GRGB + TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\001\000\002\001"); // GRBG } else if(ColorID == DNG_COLORID_RGB) { TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); diff --git a/dng.h b/dng.h index 950e0a2..8a2123a 100644 --- a/dng.h +++ b/dng.h @@ -48,6 +48,7 @@ class DNG { int BitsPerSample; int SamplesPerPixel; int ColorID; + int IsBigEndian(void); public: DNG();