MCPcopy Index your code
hub / github.com/CesiumGS/obj2gltf / decodePng

Function decodePng

lib/loadTexture.js:96–120  ·  view source on GitHub ↗
(texture, options)

Source from the content-addressed store, hash-verified

94}
95
96function 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
122function decodeJpeg(texture, options) {
123 if (options.decode) {

Callers 1

loadTextureFunction · 0.85

Calls 3

getChannelsFunction · 0.85
parsePngFunction · 0.85
hasTransparencyFunction · 0.85

Tested by

no test coverage detected