mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 869723 (Part 3) - Parse EXIF orientation in nsJPEGDecoder. r=joe
This commit is contained in:
parent
3b56384f23
commit
04f76e9b9d
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include "ImageLogging.h"
|
#include "ImageLogging.h"
|
||||||
#include "nsJPEGDecoder.h"
|
#include "nsJPEGDecoder.h"
|
||||||
|
#include "Orientation.h"
|
||||||
|
#include "EXIF.h"
|
||||||
|
|
||||||
#include "nsIInputStream.h"
|
#include "nsIInputStream.h"
|
||||||
|
|
||||||
@ -235,7 +237,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Post our size to the superclass
|
// Post our size to the superclass
|
||||||
PostSize(mInfo.image_width, mInfo.image_height);
|
PostSize(mInfo.image_width, mInfo.image_height, ReadOrientationFromEXIF());
|
||||||
if (HasError()) {
|
if (HasError()) {
|
||||||
// Setting the size led to an error.
|
// Setting the size led to an error.
|
||||||
mState = JPEG_ERROR;
|
mState = JPEG_ERROR;
|
||||||
@ -533,6 +535,27 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
|||||||
return;
|
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
|
void
|
||||||
nsJPEGDecoder::NotifyDone()
|
nsJPEGDecoder::NotifyDone()
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ typedef enum {
|
|||||||
} jstate;
|
} jstate;
|
||||||
|
|
||||||
class RasterImage;
|
class RasterImage;
|
||||||
|
class Orientation;
|
||||||
|
|
||||||
class nsJPEGDecoder : public Decoder
|
class nsJPEGDecoder : public Decoder
|
||||||
{
|
{
|
||||||
@ -62,6 +63,7 @@ public:
|
|||||||
void NotifyDone();
|
void NotifyDone();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Orientation ReadOrientationFromEXIF();
|
||||||
void OutputScanlines(bool* suspend);
|
void OutputScanlines(bool* suspend);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user