diff --git a/RawSpeed/RafDecoder.cpp b/RawSpeed/RafDecoder.cpp
index 5fa917f..6d42a3b 100644
--- a/RawSpeed/RafDecoder.cpp
+++ b/RawSpeed/RafDecoder.cpp
@@ -161,14 +161,21 @@ void RafDecoder::decodeMetaDataInternal(CameraMetaData *meta) {
if (rotate && !this->uncorrectedRawValues) {
// Calculate the 45 degree rotated size;
uint32 rotatedsize;
- if (alt_layout)
+ uint32 rotationPos;
+ if (alt_layout) {
rotatedsize = new_size.y+new_size.x/2;
- else
+ rotationPos = new_size.x/2 - 1;
+ }
+ else {
rotatedsize = new_size.x+new_size.y/2;
+ rotationPos = new_size.x - 1;
+ }
- iPoint2D final_size(rotatedsize, rotatedsize);
+ iPoint2D final_size(rotatedsize, rotatedsize-1);
RawImage rotated = RawImage::create(final_size, TYPE_USHORT16, 1);
rotated->clearArea(iRectangle2D(iPoint2D(0,0), rotated->dim));
+ rotated->fujiRotationPos = rotationPos;
+
int dest_pitch = (int)rotated->pitch / 2;
ushort16 *dst = (ushort16*)rotated->getData(0,0);
diff --git a/RawSpeed/RawDecoder.cpp b/RawSpeed/RawDecoder.cpp
index 32d3ebd..0d9d0e0 100644
--- a/RawSpeed/RawDecoder.cpp
+++ b/RawSpeed/RawDecoder.cpp
@@ -569,6 +569,10 @@ RawSpeed::RawImage RawDecoder::decodeRaw()
{
try {
RawImage raw = decodeRawInternal();
+ if(hints.find("pixel_aspect_ratio") != hints.end()) {
+ stringstream convert(hints.find("pixel_aspect_ratio")->second);
+ convert >> raw->pixelAspectRatio;
+ }
if (interpolateBadPixels)
raw->fixBadPixels();
return raw;
diff --git a/RawSpeed/RawImage.cpp b/RawSpeed/RawImage.cpp
index 3528217..b6f1119 100644
--- a/RawSpeed/RawImage.cpp
+++ b/RawSpeed/RawImage.cpp
@@ -41,7 +41,8 @@ RawImageData::RawImageData(void):
pthread_mutex_init(&errMutex, NULL);
pthread_mutex_init(&mBadPixelMutex, NULL);
mDitherScale = TRUE;
- fujiWidth = 0;
+ fujiRotationPos = 0;
+ pixelAspectRatio = 1;
}
RawImageData::RawImageData(iPoint2D _dim, uint32 _bpc, uint32 _cpp) :
@@ -54,7 +55,8 @@ RawImageData::RawImageData(iPoint2D _dim, uint32 _bpc, uint32 _cpp) :
isoSpeed = 0;
mBadPixelMap = NULL;
mDitherScale = TRUE;
- fujiWidth = 0;
+ fujiRotationPos = 0;
+ pixelAspectRatio = 1;
createData();
pthread_mutex_init(&mymutex, NULL);
pthread_mutex_init(&errMutex, NULL);
diff --git a/RawSpeed/RawImage.h b/RawSpeed/RawImage.h
index b34e413..6756dff 100644
--- a/RawSpeed/RawImage.h
+++ b/RawSpeed/RawImage.h
@@ -97,7 +97,15 @@ class RawImageData
uchar8 *mBadPixelMap;
uint32 mBadPixelMapPitch;
bool mDitherScale; // Should upscaling be done with dither to minimize banding?
- uint32 fujiWidth; // Similar to dcraw.
+
+ // How many pixels far down the left edge and far up the right edge the image
+ // corners are when the image is rotated 45 degrees in Fuji rotated sensors.
+ uint32 fujiRotationPos;
+
+ // Aspect ratio of the pixels, usually 1 but some cameras need scaling
+ // <1 means the image needs to be stretched vertically, (0.5 means 2x)
+ // >1 means the image needs to be stretched horizontally (2 mean 2x)
+ double pixelAspectRatio;
protected:
RawImageType dataType;
diff --git a/data/cameras.xml b/data/cameras.xml
index df4b90e..ac65e71 100644
--- a/data/cameras.xml
+++ b/data/cameras.xml
@@ -950,7 +950,7 @@
-
+
BLUE
GREEN
@@ -959,6 +959,9 @@
+
+
+