mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 869723 (Part 3) - Parse EXIF orientation in nsJPEGDecoder. r=joe
This commit is contained in:
parent
fc9c9c54a7
commit
337d1b4d5f
@ -6,6 +6,8 @@
|
||||
|
||||
#include "ImageLogging.h"
|
||||
#include "nsJPEGDecoder.h"
|
||||
#include "Orientation.h"
|
||||
#include "EXIF.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
@ -235,7 +237,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
}
|
||||
|
||||
// Post our size to the superclass
|
||||
PostSize(mInfo.image_width, mInfo.image_height);
|
||||
PostSize(mInfo.image_width, mInfo.image_height, ReadOrientationFromEXIF());
|
||||
if (HasError()) {
|
||||
// Setting the size led to an error.
|
||||
mState = JPEG_ERROR;
|
||||
@ -533,6 +535,27 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
Orientation
|
||||
nsJPEGDecoder::ReadOrientationFromEXIF()
|
||||
{
|
||||
jpeg_saved_marker_ptr marker;
|
||||
|
||||
// Locate the APP1 marker, where EXIF data is stored, in the marker list.
|
||||
for (marker = mInfo.marker_list ; marker != nullptr ; marker = marker->next) {
|
||||
if (marker->marker == JPEG_APP0 + 1)
|
||||
break;
|
||||
}
|
||||
|
||||
// If we're at the end of the list, there's no EXIF data.
|
||||
if (!marker)
|
||||
return Orientation();
|
||||
|
||||
// Extract the orientation information.
|
||||
EXIFData exif = EXIFParser::Parse(marker->data,
|
||||
static_cast<uint32_t>(marker->data_length));
|
||||
return exif.orientation;
|
||||
}
|
||||
|
||||
void
|
||||
nsJPEGDecoder::NotifyDone()
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ typedef enum {
|
||||
} jstate;
|
||||
|
||||
class RasterImage;
|
||||
class Orientation;
|
||||
|
||||
class nsJPEGDecoder : public Decoder
|
||||
{
|
||||
@ -62,6 +63,7 @@ public:
|
||||
void NotifyDone();
|
||||
|
||||
protected:
|
||||
Orientation ReadOrientationFromEXIF();
|
||||
void OutputScanlines(bool* suspend);
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user