22#include <osl/endian.h>
26 maOrientation(
exif::TOP_LEFT),
68 sal_Int32 nStreamPosition = rStream.
Tell();
70 rStream.
Seek( nStreamPosition );
77 sal_Int32 nStreamPosition = rStream.
Tell();
79 rStream.
Seek( nStreamPosition );
87 sal_uInt32 aSize = rStream.
TellEnd();
94 if( 0xFFD8 != aMagic16 )
106 for (aCount = 0; aCount < 7; aCount++)
130 else if (aMarker == 0xD9)
136 sal_uInt32 aCurrentPosition = rStream.
SeekRel(aLength-1);
137 if (aCurrentPosition == aPreviousPosition || aCurrentPosition > aSize)
141 aPreviousPosition = aCurrentPosition;
149sal_uInt16 read16(
sal_uInt8 const (& data)[2],
bool littleEndian) {
151 return data[0] | (sal_uInt16(data[1]) << 8);
153 return data[1] | (sal_uInt16(data[0]) << 8);
157void write16(sal_uInt16 value,
sal_uInt8 (& data)[2],
bool littleEndian) {
159 data[0] =
value & 0xFF;
160 data[1] =
value >> 8;
162 data[1] =
value & 0xFF;
163 data[0] =
value >> 8;
167void write32(sal_uInt32 value,
sal_uInt8 (& data)[4],
bool littleEndian) {
169 data[0] =
value & 0xFF;
170 data[1] = (
value >> 8) & 0xFF;
171 data[2] = (
value >> 16) & 0xFF;
172 data[3] =
value >> 24;
174 data[3] =
value & 0xFF;
175 data[2] = (
value >> 8) & 0xFF;
176 data[1] = (
value >> 16) & 0xFF;
177 data[0] =
value >> 24;
183void Exif::processIFD(
sal_uInt8* pExifData, sal_uInt16 aLength, sal_uInt16 aOffset, sal_uInt16 aNumberOfTags,
bool bSetValue,
bool littleEndian)
187 while (aOffset <= aLength - 12 && aNumberOfTags > 0)
189 ifd =
reinterpret_cast<ExifIFD*
>(&pExifData[aOffset]);
190 sal_uInt16 tag = read16(ifd->
tag, littleEndian);
196 write16(3, ifd->
type, littleEndian);
197 write32(1, ifd->
count, littleEndian);
203 sal_uInt16 nIfdOffset = read16(
223 if( 0x45786966 != aMagic32 || 0x0000 != aMagic16)
228 sal_uInt16 aLength = aSectionLength - 6;
230 std::unique_ptr<sal_uInt8[]> aExifData(
new sal_uInt8[aLength]);
231 sal_uInt32 aExifDataBeginPosition = rStream.
Tell();
233 rStream.
ReadBytes(aExifData.get(), aLength);
240 bool bIntel = aTiffHeader->
byteOrder == 0x4949;
241 bool bMotorola = aTiffHeader->
byteOrder == 0x4D4D;
243 if (!bIntel && !bMotorola)
261 aTiffHeader->
offset = OSL_SWAPDWORD(aTiffHeader->
offset);
264 if (aTiffHeader->
tagAlign != 0x002A)
269 sal_uInt16 aOffset = aTiffHeader->
offset;
271 sal_uInt16 aNumberOfTags = aExifData[aOffset];
274 aNumberOfTags = ((aExifData[aOffset] << 8) | aExifData[aOffset+1]);
277 processIFD(aExifData.get(), aLength, aOffset+2, aNumberOfTags, bSetValue, bIntel);
281 rStream.
Seek(aExifDataBeginPosition);
bool read(SvStream &rStream)
bool processExif(SvStream &rStream, sal_uInt16 aLength, bool bSetValue)
void setOrientation(exif::Orientation orientation)
exif::Orientation maOrientation
void processIFD(sal_uInt8 *pExifData, sal_uInt16 aLength, sal_uInt16 aOffset, sal_uInt16 aNumberOfTags, bool bSetValue, bool bLittleEndian)
static exif::Orientation convertToOrientation(sal_Int32 value)
Degree10 getRotation() const
bool processJpeg(SvStream &rStream, bool bSetValue)
void write(SvStream &rStream)
void SetEndian(SvStreamEndian SvStreamEndian)
virtual sal_uInt64 TellEnd()
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
#define STREAM_SEEK_TO_BEGIN