(texture, options)
| 94 | } |
| 95 | |
| 96 | function decodePng(texture, options) { |
| 97 | // Color type is encoded in the 25th bit of the png |
| 98 | const source = texture.source; |
| 99 | const colorType = source[25]; |
| 100 | const channels = getChannels(colorType); |
| 101 | |
| 102 | const checkTransparency = channels === 4 && options.checkTransparency; |
| 103 | const decode = options.decode || checkTransparency; |
| 104 | |
| 105 | if (decode) { |
| 106 | return parsePng(source).then(function (decodedResults) { |
| 107 | if (options.checkTransparency) { |
| 108 | texture.transparent = hasTransparency(decodedResults.data); |
| 109 | } |
| 110 | if (options.decode) { |
| 111 | texture.pixels = decodedResults.data; |
| 112 | texture.width = decodedResults.width; |
| 113 | texture.height = decodedResults.height; |
| 114 | if (!options.keepSource) { |
| 115 | texture.source = undefined; // Unload resources |
| 116 | } |
| 117 | } |
| 118 | }); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | function decodeJpeg(texture, options) { |
| 123 | if (options.decode) { |
no test coverage detected