| 580 | } |
| 581 | |
| 582 | const UInt8* Image::GetConstPixels(unsigned int x, unsigned int y, unsigned int z, UInt8 level) const |
| 583 | { |
| 584 | #if NAZARA_UTILITY_SAFE |
| 585 | if (m_sharedImage == &emptyImage) |
| 586 | { |
| 587 | NazaraError("Image must be valid"); |
| 588 | return nullptr; |
| 589 | } |
| 590 | |
| 591 | if (level >= m_sharedImage->levels.size()) |
| 592 | { |
| 593 | NazaraError("Level out of bounds (" + String::Number(level) + " >= " + String::Number(m_sharedImage->levels.size()) + ')'); |
| 594 | return nullptr; |
| 595 | } |
| 596 | #endif |
| 597 | |
| 598 | unsigned int width = GetLevelSize(m_sharedImage->width, level); |
| 599 | #if NAZARA_UTILITY_SAFE |
| 600 | if (x >= width) |
| 601 | { |
| 602 | NazaraError("X value exceeds width (" + String::Number(x) + " >= " + String::Number(width) + ')'); |
| 603 | return nullptr; |
| 604 | } |
| 605 | #endif |
| 606 | |
| 607 | unsigned int height = GetLevelSize(m_sharedImage->height, level); |
| 608 | #if NAZARA_UTILITY_SAFE |
| 609 | if (y >= height) |
| 610 | { |
| 611 | NazaraError("Y value exceeds height (" + String::Number(y) + " >= " + String::Number(height) + ')'); |
| 612 | return nullptr; |
| 613 | } |
| 614 | |
| 615 | unsigned int depth = (m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level); |
| 616 | if (z >= depth) |
| 617 | { |
| 618 | NazaraError("Z value exceeds depth (" + String::Number(z) + " >= " + String::Number(depth) + ')'); |
| 619 | return nullptr; |
| 620 | } |
| 621 | #endif |
| 622 | |
| 623 | return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height); |
| 624 | } |
| 625 | |
| 626 | unsigned int Image::GetDepth(UInt8 level) const |
| 627 | { |
no test coverage detected