MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / HasAlpha

Method HasAlpha

src/Nazara/Utility/Image.cpp:826–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824 }
825
826 bool Image::HasAlpha() const
827 {
828 NazaraAssert(m_sharedImage != &emptyImage, "Image must be valid");
829
830 if (!PixelFormat::HasAlpha(m_sharedImage->format))
831 return false;
832
833 if (!PixelFormat::IsCompressed(m_sharedImage->format))
834 {
835 const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format);
836
837 Bitset<> workingBitset;
838 std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth);
839 if (pixelCount == 0)
840 return false;
841
842 auto seq = workingBitset.Read(GetConstPixels(), info.bitsPerPixel);
843 do
844 {
845 workingBitset &= info.alphaMask;
846 if (workingBitset.Count() != info.alphaMask.Count()) //< Means that at least one bit of the alpha mask of this pixel is disabled
847 return true;
848
849 workingBitset.Clear();
850 workingBitset.Read(seq, info.bitsPerPixel);
851 }
852 while (--pixelCount > 0);
853
854 return false;
855 }
856 else
857 {
858 // FIXME: Currently, we assume the pixel format is already the right one
859 return true;
860 }
861 }
862
863 bool Image::IsValid() const
864 {

Callers

nothing calls this directly

Calls 3

CountMethod · 0.80
ReadMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected