Now adds a fake TIFF header to the exported EXIF data so that the used endian of the data is known.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20630 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3360,13 +3360,19 @@ DCRaw::ImageAt(uint32 index, image_data_info& info) const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DCRaw::GetEXIFTag(off_t& offset, size_t& length) const
|
DCRaw::GetEXIFTag(off_t& offset, size_t& length, bool& bigEndian) const
|
||||||
{
|
{
|
||||||
if (fEXIFOffset < 0)
|
if (fEXIFOffset < 0)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
offset = fEXIFOffset;
|
offset = fEXIFOffset;
|
||||||
length = fEXIFLength;
|
length = fEXIFLength;
|
||||||
|
|
||||||
|
#if B_HOST_IS_LENDIAN
|
||||||
|
bigEndian = fRead.IsSwapping();
|
||||||
|
#else
|
||||||
|
bigEndian = !fRead.IsSwapping();
|
||||||
|
#endif
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ class DCRaw {
|
|||||||
uint32 CountImages() const;
|
uint32 CountImages() const;
|
||||||
status_t ImageAt(uint32 index, image_data_info& info) const;
|
status_t ImageAt(uint32 index, image_data_info& info) const;
|
||||||
|
|
||||||
status_t GetEXIFTag(off_t& offset, size_t& length) const;
|
status_t GetEXIFTag(off_t& offset, size_t& length,
|
||||||
|
bool& bigEndian) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32 _AllocateImage();
|
int32 _AllocateImage();
|
||||||
|
|||||||
@@ -63,11 +63,11 @@ const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting
|
|||||||
|
|
||||||
|
|
||||||
RAWTranslator::RAWTranslator()
|
RAWTranslator::RAWTranslator()
|
||||||
: BaseTranslator("Raw Images", "Raw Image Translator",
|
: BaseTranslator("RAW Images", "RAW Image Translator",
|
||||||
RAW_TRANSLATOR_VERSION,
|
RAW_TRANSLATOR_VERSION,
|
||||||
sInputFormats, kNumInputFormats,
|
sInputFormats, kNumInputFormats,
|
||||||
sOutputFormats, kNumOutputFormats,
|
sOutputFormats, kNumOutputFormats,
|
||||||
"RawTranslator_Settings",
|
"RAWTranslator_Settings",
|
||||||
sDefaultSettings, kNumDefaultSettings,
|
sDefaultSettings, kNumDefaultSettings,
|
||||||
B_TRANSLATOR_BITMAP, RAW_IMAGE_FORMAT)
|
B_TRANSLATOR_BITMAP, RAW_IMAGE_FORMAT)
|
||||||
{
|
{
|
||||||
@@ -192,12 +192,26 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
// retrieve EXIF data
|
// retrieve EXIF data
|
||||||
off_t exifOffset;
|
off_t exifOffset;
|
||||||
size_t exifLength;
|
size_t exifLength;
|
||||||
if (settings != NULL && raw.GetEXIFTag(exifOffset, exifLength) == B_OK) {
|
bool bigEndian;
|
||||||
void* exifBuffer = malloc(exifLength);
|
if (settings != NULL && raw.GetEXIFTag(exifOffset, exifLength, bigEndian) == B_OK) {
|
||||||
|
uint8* exifBuffer = (uint8*)malloc(exifLength + 16);
|
||||||
if (exifBuffer != NULL) {
|
if (exifBuffer != NULL) {
|
||||||
if (source->ReadAt(exifOffset, exifBuffer, exifLength)
|
// add fake TIFF header to EXIF data
|
||||||
|
struct {
|
||||||
|
uint16 endian;
|
||||||
|
uint16 tiff_marker;
|
||||||
|
uint32 offset;
|
||||||
|
uint16 null;
|
||||||
|
} _PACKED header;
|
||||||
|
header.endian = bigEndian ? 'MM' : 'II';
|
||||||
|
header.tiff_marker = 42;
|
||||||
|
header.offset = 16;
|
||||||
|
header.null = 0;
|
||||||
|
memcpy(exifBuffer, &header, sizeof(header));
|
||||||
|
|
||||||
|
if (source->ReadAt(exifOffset, exifBuffer + 16, exifLength)
|
||||||
== (ssize_t)exifLength)
|
== (ssize_t)exifLength)
|
||||||
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength);
|
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength + 16);
|
||||||
|
|
||||||
free(exifBuffer);
|
free(exifBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,16 +173,16 @@ class TReadHelper {
|
|||||||
throw fError;
|
throw fError;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Status()
|
status_t Status() const
|
||||||
{ return fError >= B_OK ? B_OK : fError; };
|
{ return fError >= B_OK ? B_OK : fError; };
|
||||||
|
|
||||||
off_t Seek(off_t offset, int32 mode)
|
off_t Seek(off_t offset, int32 mode)
|
||||||
{ return fStream.Seek(offset, mode); }
|
{ return fStream.Seek(offset, mode); }
|
||||||
off_t Position()
|
off_t Position() const
|
||||||
{ return fStream.Position(); }
|
{ return fStream.Position(); }
|
||||||
|
|
||||||
void SetSwap(bool yesNo) { fSwap = yesNo; };
|
void SetSwap(bool yesNo) { fSwap = yesNo; };
|
||||||
bool IsSwapping() { return fSwap; };
|
bool IsSwapping() const { return fSwap; };
|
||||||
|
|
||||||
BPositionIO& Stream() { return fStream; }
|
BPositionIO& Stream() { return fStream; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user