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:
Axel Dörfler 2007-04-10 00:14:32 +00:00
parent 7664bcb5c4
commit 1b52d54a31
4 changed files with 32 additions and 11 deletions

View File

@ -3360,13 +3360,19 @@ DCRaw::ImageAt(uint32 index, image_data_info& info) const
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)
return B_ENTRY_NOT_FOUND;
offset = fEXIFOffset;
length = fEXIFLength;
#if B_HOST_IS_LENDIAN
bigEndian = fRead.IsSwapping();
#else
bigEndian = !fRead.IsSwapping();
#endif
return B_OK;
}

View File

@ -63,7 +63,8 @@ class DCRaw {
uint32 CountImages() 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:
int32 _AllocateImage();

View File

@ -63,11 +63,11 @@ const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting
RAWTranslator::RAWTranslator()
: BaseTranslator("Raw Images", "Raw Image Translator",
: BaseTranslator("RAW Images", "RAW Image Translator",
RAW_TRANSLATOR_VERSION,
sInputFormats, kNumInputFormats,
sOutputFormats, kNumOutputFormats,
"RawTranslator_Settings",
"RAWTranslator_Settings",
sDefaultSettings, kNumDefaultSettings,
B_TRANSLATOR_BITMAP, RAW_IMAGE_FORMAT)
{
@ -192,12 +192,26 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
// retrieve EXIF data
off_t exifOffset;
size_t exifLength;
if (settings != NULL && raw.GetEXIFTag(exifOffset, exifLength) == B_OK) {
void* exifBuffer = malloc(exifLength);
bool bigEndian;
if (settings != NULL && raw.GetEXIFTag(exifOffset, exifLength, bigEndian) == B_OK) {
uint8* exifBuffer = (uint8*)malloc(exifLength + 16);
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)
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength);
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength + 16);
free(exifBuffer);
}

View File

@ -173,16 +173,16 @@ class TReadHelper {
throw fError;
}
status_t Status()
status_t Status() const
{ return fError >= B_OK ? B_OK : fError; };
off_t Seek(off_t offset, int32 mode)
{ return fStream.Seek(offset, mode); }
off_t Position()
off_t Position() const
{ return fStream.Position(); }
void SetSwap(bool yesNo) { fSwap = yesNo; };
bool IsSwapping() { return fSwap; };
bool IsSwapping() const { return fSwap; };
BPositionIO& Stream() { return fStream; }