MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / GetUncompressedData

Method GetUncompressedData

Source/Images/texture_data.cpp:277–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277void TextureData::GetUncompressedData(unsigned char *data) {
278 if (is_loaded) {
279 pixel_format format = m_crnTex.get_format();
280 // In both `terrain.cpp` and `textures.cpp`, both uses of this function imply that the only valid data format
281 // expected is BGRA_8. Otherwise, one would expect the function signature to also return a `numBits` or similar.
282 // Therefore, I'll proclaim `imageBits` obsolete, and comment out the lesser bit depths and the conditional.
283 // int imageBits = 32;
284
285 // int bytesPerPixel = imageBits / 8;
286 int imageWidth = m_crnTex.get_width();
287 int imageHeight = m_crnTex.get_height();
288
289 // int heightDataSize = imageWidth * imageHeight;
290 // int imageDataSize = heightDataSize * bytesPerPixel;
291
292 image_u8 image;
293 image_u8 *pImg = m_crnTex.get_level_image(0, 0, image);
294
295 /*
296 if (imageBits == 8) {
297 for (int y = 0; y < imageHeight; y++) {
298 color_quad_u8 *bits = pImg->get_scanline(y);
299 for (int x = 0; x < imageWidth; x++) {
300 int curr_index = x + y * imageWidth;
301 data[curr_index] = bits[x].a;
302 }
303 }
304 } else if (imageBits == 24) {
305 for (int y = 0; y < imageHeight; y++) {
306 color_quad_u8 *bits = pImg->get_scanline(y);
307 for (int x = 0; x < imageWidth; x++) {
308 int curr_index = x + y * imageWidth;
309 data[4 * curr_index] = bits[x].b;
310 data[4 * curr_index + 1] = bits[x].g;
311 data[4 * curr_index + 2] = bits[x].r;
312 data[4 * curr_index + 3] = 255;
313 }
314 }
315 } else if (imageBits == 32) {
316 */
317
318 for (int y = 0; y < imageHeight; y++) {
319 color_quad_u8 *bits = pImg->get_scanline(y);
320 for (int x = 0; x < imageWidth; x++) {
321 int curr_index = x + y * imageWidth;
322 data[4 * curr_index] = bits[x].b;
323 data[4 * curr_index + 1] = bits[x].g;
324 data[4 * curr_index + 2] = bits[x].r;
325 data[4 * curr_index + 3] = bits[x].a;
326 }
327 }
328
329 // TODO: what is this?
330 /*
331 } else if (m_nImageBits == 96) {
332 for(int y = 0; y < m_nImageHeight; y++) {
333 BYTE *bits = FreeImage_GetScanLine(image, y);
334 for(int x = 0; x < m_nImageWidth; x++) {

Callers 2

GetAverageColorFunction · 0.80
CalcDetailTexturesMethod · 0.80

Calls 5

get_level_imageMethod · 0.80
get_scanlineMethod · 0.80
get_formatMethod · 0.45
get_widthMethod · 0.45
get_heightMethod · 0.45

Tested by

no test coverage detected