Modified GetSubImagePixelValues API to be exclusive with bottom right coordinate, and documented as such
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
@@ -91,12 +91,15 @@ namespace AZ
|
||||
T GetSubImagePixelValue(uint32_t x, uint32_t y, uint32_t componentIndex = 0, uint32_t mip = 0, uint32_t slice = 0);
|
||||
|
||||
//! Retrieve a region of image pixel values (float) for specified mip and slice
|
||||
//! NOTE: The topLeft coordinate is inclusive, whereas the bottomRight is exclusive
|
||||
void GetSubImagePixelValues(AZStd::pair<uint32_t, uint32_t> topLeft, AZStd::pair<uint32_t, uint32_t> bottomRight, AZStd::span<float> outValues, uint32_t componentIndex = 0, uint32_t mip = 0, uint32_t slice = 0);
|
||||
|
||||
//! Retrieve a region of image pixel values (uint) for specified mip and slice
|
||||
//! NOTE: The topLeft coordinate is inclusive, whereas the bottomRight is exclusive
|
||||
void GetSubImagePixelValues(AZStd::pair<uint32_t, uint32_t> topLeft, AZStd::pair<uint32_t, uint32_t> bottomRight, AZStd::span<AZ::u32> outValues, uint32_t componentIndex = 0, uint32_t mip = 0, uint32_t slice = 0);
|
||||
|
||||
//! Retrieve a region of image pixel values (int) for specified mip and slice
|
||||
//! NOTE: The topLeft coordinate is inclusive, whereas the bottomRight is exclusive
|
||||
void GetSubImagePixelValues(AZStd::pair<uint32_t, uint32_t> topLeft, AZStd::pair<uint32_t, uint32_t> bottomRight, AZStd::span<AZ::s32> outValues, uint32_t componentIndex = 0, uint32_t mip = 0, uint32_t slice = 0);
|
||||
|
||||
//! Returns streaming image pool asset id of the pool that will be used to create the streaming image.
|
||||
|
||||
@@ -315,9 +315,10 @@ namespace AZ
|
||||
{
|
||||
AZStd::array<T, 1> values = { aznumeric_cast<T>(0) };
|
||||
|
||||
auto position = AZStd::make_pair(x, y);
|
||||
auto topLeft = AZStd::make_pair(x, y);
|
||||
auto bottomRight = AZStd::make_pair(x + 1, y + 1);
|
||||
AZStd::span<T> valueSpan(values.begin(), values.size());
|
||||
GetSubImagePixelValues(position, position, valueSpan, componentIndex, mip, slice);
|
||||
GetSubImagePixelValues(topLeft, bottomRight, valueSpan, componentIndex, mip, slice);
|
||||
|
||||
return values[0];
|
||||
}
|
||||
@@ -354,9 +355,9 @@ namespace AZ
|
||||
const uint32_t pixelSize = AZ::RHI::GetFormatSize(imageDescriptor.m_format);
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y <= bottomRight.second; ++y)
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x)
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * pixelSize;
|
||||
|
||||
@@ -381,9 +382,9 @@ namespace AZ
|
||||
const uint32_t pixelSize = AZ::RHI::GetFormatSize(imageDescriptor.m_format);
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y <= bottomRight.second; ++y)
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x)
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * pixelSize;
|
||||
|
||||
@@ -408,9 +409,9 @@ namespace AZ
|
||||
const uint32_t pixelSize = AZ::RHI::GetFormatSize(imageDescriptor.m_format);
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y <= bottomRight.second; ++y)
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x)
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * pixelSize;
|
||||
|
||||
|
||||
@@ -752,7 +752,7 @@ namespace UnitTest
|
||||
// Validate retrieving a region of pixels
|
||||
AZStd::vector<float> pixelValues(size.m_width * size.m_height);
|
||||
auto topLeft = AZStd::make_pair<uint32_t, uint32_t>(0, 0);
|
||||
auto bottomRight = AZStd::make_pair<uint32_t, uint32_t>(size.m_width - 1, size.m_height - 1);
|
||||
auto bottomRight = AZStd::make_pair<uint32_t, uint32_t>(size.m_width, size.m_height);
|
||||
streamingImageAsset->GetSubImagePixelValues(topLeft, bottomRight, pixelValues);
|
||||
for (uint32_t index = 0; index < pixelValues.size(); ++index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user