Author: post
Date: 2011-02-09 22:23:21 +0100 (Wed, 09 Feb 2011)
New Revision: 327
Modified:
RawSpeed/RawImage.cpp
RawSpeed/RawImage.h
Log:
Store allocated image size and fix black level calculation.
Modified: RawSpeed/RawImage.cpp
===================================================================
--- RawSpeed/RawImage.cpp 2011-01-30 18:48:40 UTC (rev 326)
+++ RawSpeed/RawImage.cpp 2011-02-09 21:23:21 UTC (rev 327)
@@ -29,7 +29,7 @@
namespace RawSpeed {
RawImageData::RawImageData(void):
- dim(0, 0), bpp(0), isCFA(true),
+ dim(0, 0), uncropped_dim(0, 0),bpp(0), isCFA(true),
blackLevel(-1), whitePoint(65536),
dataRefCount(0), data(0), cpp(1) {
pthread_mutex_init(&mymutex, NULL);
@@ -66,6 +66,7 @@
data = (uchar8*)_aligned_malloc(pitch * dim.y, 16);
if (!data)
ThrowRDE("RawImageData::createData: Memory Allocation failed.");
+ uncropped_dim = dim;
}
void RawImageData::destroyData() {
@@ -107,9 +108,9 @@
}
uchar8* RawImageData::getDataUncropped(uint32 x, uint32 y) {
- if ((int)x >= dim.x+mOffset.x)
+ if ((int)x >= uncropped_dim.x)
ThrowRDE("RawImageData::getDataUncropped - X Position outside image
requested.");
- if ((int)y >= dim.y+mOffset.y) {
+ if ((int)y >= uncropped_dim.y) {
ThrowRDE("RawImageData::getDataUncropped - Y Position outside image
requested.");
}
@@ -142,10 +143,12 @@
BlackArea area = blackAreas[i];
/* Process horizontal area */
if (!area.isVertical) {
+ if ((int)area.offset+(int)area.size > uncropped_dim.y)
+ ThrowRDE("RawImageData::calculateBlackAreas: Offset + size is larger
than height of image");
for (uint32 y = area.offset; y < area.offset+area.size; y++) {
ushort16 *pixel = (ushort16*)getDataUncropped(mOffset.x, y);
int* localhist = &histogram[(y&1)*(65536*2)];
- for (int x = mOffset.x; x < dim.x; x++) {
+ for (int x = mOffset.x; x < dim.x+mOffset.x; x++) {
localhist[((x&1)<<16) + *pixel]++;
}
}
@@ -154,10 +157,12 @@
/* Process vertical area */
if (area.isVertical) {
- for (int y = mOffset.y; y < dim.y; y++) {
+ if ((int)area.offset+(int)area.size > uncropped_dim.x)
+ ThrowRDE("RawImageData::calculateBlackAreas: Offset + size is larger
than width of image");
+ for (int y = mOffset.y; y < dim.y+mOffset.y; y++) {
ushort16 *pixel = (ushort16*)getDataUncropped(area.offset, y);
int* localhist = &histogram[(y&1)*(65536*2)];
- for (uint32 x = area.offset; x < area.size; x++) {
+ for (uint32 x = area.offset; x < area.size+area.offset; x++) {
localhist[((x&1)<<16) + *pixel]++;
}
}
Modified: RawSpeed/RawImage.h
===================================================================
--- RawSpeed/RawImage.h 2011-01-30 18:48:40 UTC (rev 326)
+++ RawSpeed/RawImage.h 2011-02-09 21:23:21 UTC (rev 327)
@@ -63,6 +63,7 @@
friend class RawImage;
pthread_mutex_t mymutex;
iPoint2D mOffset;
+ iPoint2D uncropped_dim;
};
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit