| 163 | |
| 164 | private: |
| 165 | bool ReadPNGData(const std::string& pngData) { |
| 166 | std::istringstream iss(pngData); |
| 167 | PNGImageFile image(&iss); |
| 168 | if (!image.isOpen()) { |
| 169 | return false; |
| 170 | } |
| 171 | |
| 172 | type = GL_UNSIGNED_BYTE; |
| 173 | xsize = (GLint)image.getWidth(); |
| 174 | ysize = (GLint)image.getHeight(); |
| 175 | |
| 176 | // set the data format based on the number of channels |
| 177 | const int channels = image.getNumChannels(); |
| 178 | switch (channels) { |
| 179 | case 1: { format = GL_LUMINANCE; break; } |
| 180 | case 2: { format = GL_LUMINANCE_ALPHA; break; } |
| 181 | case 3: { format = GL_RGB; break; } |
| 182 | case 4: { format = GL_RGBA; break; } |
| 183 | default: { |
| 184 | return false; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | const int bufSize = (xsize * ysize * channels); |
| 189 | data = new char[bufSize]; |
| 190 | if (!image.read(data)) { |
| 191 | delete[] data; |
| 192 | data = NULL; |
| 193 | return false; |
| 194 | } |
| 195 | |
| 196 | ownData = true; |
| 197 | |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | public: |
| 202 | GLsizei xsize; |
nothing calls this directly
no test coverage detected