@@ -178,6 +178,8 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
178178
179179 if (ColorType == PNG_COLOR_TYPE_PALETTE)
180180 png_set_palette_to_rgb (png_ptr);
181+ else if (ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
182+ png_set_gray_to_rgb (png_ptr);
181183
182184 // Convert low bit colors to 8 bit colors
183185 if (BitDepth < 8 )
@@ -238,7 +240,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
238240 imgInfo.flags = static_cast <IImage::E_CREATE_FLAGS>(0u );
239241 core::smart_refctd_ptr<ICPUImage> image = nullptr ;
240242
241- bool lumaAlphaType = false ;
242243 switch (ColorType) {
243244 case PNG_COLOR_TYPE_RGB_ALPHA:
244245 imgInfo.format = EF_R8G8B8A8_SRGB;
@@ -251,7 +252,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
251252 break ;
252253 case PNG_COLOR_TYPE_GRAY_ALPHA:
253254 imgInfo.format = EF_R8G8B8A8_SRGB;
254- lumaAlphaType = true ;
255255 break ;
256256 default :
257257 {
@@ -309,20 +309,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
309309 png_read_image (png_ptr, RowPointers);
310310
311311 png_read_end (png_ptr, nullptr );
312- if (lumaAlphaType)
313- {
314- assert (imgInfo.format ==asset::EF_R8G8B8A8_SRGB);
315- for (uint32_t i=0u ; i<Height; ++i)
316- for (uint32_t j=0u ; j<Width;)
317- {
318- uint32_t in = reinterpret_cast <uint16_t *>(RowPointers[i])[j];
319- j++;
320- auto & out = reinterpret_cast <uint32_t *>(RowPointers[i])[Width-j];
321- out = in|(in << 16u ); // LXLA
322- out &= 0xffff00ffu ;
323- out |= (in&0xffu ) << 8u ;
324- }
325- }
326312 _NBL_DELETE_ARRAY (RowPointers, Height);
327313 png_destroy_read_struct (&png_ptr,&info_ptr, 0 ); // Clean up memory
328314#else
0 commit comments