25 int component_count = 0;
26 bool gotInfo = !!stbi_info(mInfo.Utf8Path.GetPath().c_str(), &width, &height, &component_count);
35 StbLoaderCache& cache = *
reinterpret_cast<StbLoaderCache*
>(&mCustomLoaderInfo);
36 new(&cache) StbLoaderCache();
38 cache.Is16bit = !!stbi_is_16_bit(mInfo.Utf8Path.GetPath().c_str());
39 cache.IsHdr = !!stbi_is_hdr(mInfo.Utf8Path.GetPath().c_str());
41 switch(component_count)
56 mInfo.Extent.width =
static_cast<uint32_t
>(width);
57 mInfo.Extent.height =
static_cast<uint32_t
>(height);
59 if constexpr(FORMAT_TRAITS::COMPONENT_TRAITS::IS_FLOAT && FORMAT_TRAITS::COMPONENT_TRAITS::SIZE != 4)
61 logger()->warn(
"ImageLoad: Stb image loader does not support half or double precision floating point values!");
66 mInfo.Valid = width > 0 && height > 0 && !!mInfo.Channels.size();
100 using namespace impl;
102 uint8_t* stbdata =
nullptr;
103 std::string namestr(mInfo.Utf8Path.GetPath());
104 const char* name = namestr.c_str();
106 int desired_channels =
static_cast<int>(FORMAT_TRAITS::COMPONENT_COUNT);
108 if constexpr(FORMAT_TRAITS::COMPONENT_TRAITS::IS_FLOAT)
110 stbdata = lReadStbFp32<FORMAT_TRAITS>(name, desired_channels);
112 if constexpr(FORMAT_TRAITS::COMPONENT_TRAITS::SIZE == 1)
114 stbdata = lReadStbUint8<FORMAT_TRAITS>(name, desired_channels);
116 if constexpr(FORMAT_TRAITS::COMPONENT_TRAITS::SIZE == 2)
118 stbdata = lReadStbUint16<FORMAT_TRAITS>(name, desired_channels);
126 mRawData.resize(FORMAT_TRAITS::BYTESTRIDE * mInfo.Extent.width * mInfo.Extent.height);
128 memcpy(mRawData.data(), stbdata, mRawData.size());
129 stbi_image_free(stbdata);