Fixed Image::Get[Width|Height|Depth] returning 1 on invalid images
Former-commit-id: 0822a90c3e4b29addcb74ab9a268fd88ff167f76
This commit is contained in:
parent
62dc2dbdf3
commit
eda4ef852d
|
|
@ -11,12 +11,16 @@
|
||||||
#include <Nazara/Utility/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
///TODO: Rajouter des warnings (Formats compressés avec les méthodes Copy/Update, tests taille dans Copy)
|
///TODO: Rajouter des warnings (Formats compressés avec les méthodes Copy/Update, tests taille dans Copy)
|
||||||
///TODO: Rendre les méthodes exception-safe
|
///TODO: Rendre les méthodes exception-safe (Virer toute cette merde de calcul de pointeurs, faire usage du RAII)
|
||||||
|
///FIXME: Gérer correctement les formats utilisant moins d'un octet par pixel
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
inline unsigned int GetLevelSize(unsigned int size, nzUInt8 level)
|
inline unsigned int GetLevelSize(unsigned int size, nzUInt8 level)
|
||||||
{
|
{
|
||||||
|
if (size == 0) // Possible dans le cas d'une image invalide
|
||||||
|
return 0;
|
||||||
|
|
||||||
return std::max(size >> level, 1U);
|
return std::max(size >> level, 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +32,7 @@ namespace
|
||||||
|
|
||||||
bool NzImageParams::IsValid() const
|
bool NzImageParams::IsValid() const
|
||||||
{
|
{
|
||||||
return true;
|
return true; // Rien à vérifier
|
||||||
}
|
}
|
||||||
|
|
||||||
NzImage::NzImage() :
|
NzImage::NzImage() :
|
||||||
|
|
@ -195,7 +199,7 @@ void NzImage::Copy(const NzImage& source, const NzBoxui& srcBox, const NzVector3
|
||||||
|
|
||||||
bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, nzUInt8 levelCount)
|
bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, nzUInt8 levelCount)
|
||||||
{
|
{
|
||||||
ReleaseImage();
|
Destroy();
|
||||||
|
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!NzPixelFormat::IsValid(format))
|
if (!NzPixelFormat::IsValid(format))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue