MCPcopy Create free account
hub / github.com/ddnet/ddnet / PngliteIncompatibility

Function PngliteIncompatibility

src/engine/gfx/image_loader.cpp:86–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86static int PngliteIncompatibility(png_structp pPngStruct, png_infop pPngInfo)
87{
88 int Result = 0;
89
90 const int ColorType = png_get_color_type(pPngStruct, pPngInfo);
91 switch(ColorType)
92 {
93 case PNG_COLOR_TYPE_GRAY:
94 case PNG_COLOR_TYPE_RGB:
95 case PNG_COLOR_TYPE_RGB_ALPHA:
96 case PNG_COLOR_TYPE_GRAY_ALPHA:
97 break;
98 default:
99 log_debug("png", "color type %d unsupported by pnglite", ColorType);
100 Result |= CImageLoader::PNGLITE_COLOR_TYPE;
101 }
102
103 const int BitDepth = png_get_bit_depth(pPngStruct, pPngInfo);
104 switch(BitDepth)
105 {
106 case 8:
107 case 16:
108 break;
109 default:
110 log_debug("png", "bit depth %d unsupported by pnglite", BitDepth);
111 Result |= CImageLoader::PNGLITE_BIT_DEPTH;
112 }
113
114 const int InterlaceType = png_get_interlace_type(pPngStruct, pPngInfo);
115 if(InterlaceType != PNG_INTERLACE_NONE)
116 {
117 log_debug("png", "interlace type %d unsupported by pnglite", InterlaceType);
118 Result |= CImageLoader::PNGLITE_INTERLACE_TYPE;
119 }
120
121 if(png_get_compression_type(pPngStruct, pPngInfo) != PNG_COMPRESSION_TYPE_BASE)
122 {
123 log_debug("png", "non-default compression type unsupported by pnglite");
124 Result |= CImageLoader::PNGLITE_COMPRESSION_TYPE;
125 }
126
127 if(png_get_filter_type(pPngStruct, pPngInfo) != PNG_FILTER_TYPE_BASE)
128 {
129 log_debug("png", "non-default filter type unsupported by pnglite");
130 Result |= CImageLoader::PNGLITE_FILTER_TYPE;
131 }
132
133 return Result;
134}
135
136bool CImageLoader::LoadPng(CByteBufferReader &Reader, const char *pContextName, CImageInfo &Image, int &PngliteIncompatible)
137{

Callers 1

LoadPngMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected