Skip to content

Commit

Permalink
Call RawImageData::isAllocated() where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Oct 19, 2022
1 parent 1b81eb8 commit 0471890
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librawspeed/common/RawImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void RawImageData::createData() {
ThrowRDE("Dimensions too large for allocation.");
if (dim.x <= 0 || dim.y <= 0)
ThrowRDE("Dimension of one sides is less than 1 - cannot allocate image.");
if (data)
if (isAllocated())
ThrowRDE("Duplicate data allocation in createData.");

// want each line to start at 16-byte aligned address
Expand Down Expand Up @@ -191,7 +191,7 @@ void RawImageData::destroyData() {
}

void RawImageData::setCpp(uint32_t val) {
if (data)
if (isAllocated())
ThrowRDE("Attempted to set Components per pixel after data allocation");
if (val > 4) {
ThrowRDE(
Expand All @@ -205,7 +205,7 @@ void RawImageData::setCpp(uint32_t val) {
}

uint8_t* RawImageData::getData() const {
if (!data)
if (!isAllocated())
ThrowRDE("Data not yet allocated.");
return &data[mOffset.y*pitch+mOffset.x*bpp];
}
Expand All @@ -219,7 +219,7 @@ uint8_t* RawImageData::getData(uint32_t x, uint32_t y) {
if (y >= static_cast<unsigned>(uncropped_dim.y))
ThrowRDE("Y Position outside image requested.");

if (!data)
if (!isAllocated())
ThrowRDE("Data not yet allocated.");

return &data[static_cast<size_t>(y) * pitch + x * bpp];
Expand All @@ -231,7 +231,7 @@ uint8_t* RawImageData::getDataUncropped(uint32_t x, uint32_t y) const {
if (y >= static_cast<unsigned>(uncropped_dim.y))
ThrowRDE("Y Position outside image requested.");

if (!data)
if (!isAllocated())
ThrowRDE("Data not yet allocated.");

return &data[static_cast<size_t>(y) * pitch + x * bpp];
Expand Down

0 comments on commit 0471890

Please sign in to comment.