@@ -178,6 +178,8 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
178
178
179
179
if (ColorType == PNG_COLOR_TYPE_PALETTE)
180
180
png_set_palette_to_rgb (png_ptr);
181
+ else if (ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
182
+ png_set_gray_to_rgb (png_ptr);
181
183
182
184
// Convert low bit colors to 8 bit colors
183
185
if (BitDepth < 8 )
@@ -238,7 +240,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
238
240
imgInfo.flags = static_cast <IImage::E_CREATE_FLAGS>(0u );
239
241
core::smart_refctd_ptr<ICPUImage> image = nullptr ;
240
242
241
- bool lumaAlphaType = false ;
242
243
switch (ColorType) {
243
244
case PNG_COLOR_TYPE_RGB_ALPHA:
244
245
imgInfo.format = EF_R8G8B8A8_SRGB;
@@ -251,7 +252,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
251
252
break ;
252
253
case PNG_COLOR_TYPE_GRAY_ALPHA:
253
254
imgInfo.format = EF_R8G8B8A8_SRGB;
254
- lumaAlphaType = true ;
255
255
break ;
256
256
default :
257
257
{
@@ -309,20 +309,6 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
309
309
png_read_image (png_ptr, RowPointers);
310
310
311
311
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
- }
326
312
_NBL_DELETE_ARRAY (RowPointers, Height);
327
313
png_destroy_read_struct (&png_ptr,&info_ptr, 0 ); // Clean up memory
328
314
#else
0 commit comments