summaryrefslogtreecommitdiff
path: root/src/video_core/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/utils.cpp')
-rw-r--r--src/video_core/utils.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp
index b94376ac1..c1848f923 100644
--- a/src/video_core/utils.cpp
+++ b/src/video_core/utils.cpp
@@ -8,6 +8,7 @@
8#include "video_core/utils.h" 8#include "video_core/utils.h"
9 9
10namespace VideoCore { 10namespace VideoCore {
11
11/** 12/**
12 * Dumps a texture to TGA 13 * Dumps a texture to TGA
13 * @param filename String filename to dump texture to 14 * @param filename String filename to dump texture to
@@ -16,29 +17,20 @@ namespace VideoCore {
16 * @param raw_data Raw RGBA8 texture data to dump 17 * @param raw_data Raw RGBA8 texture data to dump
17 * @todo This should be moved to some general purpose/common code 18 * @todo This should be moved to some general purpose/common code
18 */ 19 */
19void DumpTGA(std::string filename, int width, int height, u8* raw_data) { 20void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
20 TGAHeader hdr; 21 TGAHeader hdr = {0, 0, 2, 0, 0, 0, 0, width, height, 24, 0};
21 FILE* fout; 22 FILE* fout = fopen(filename.c_str(), "wb");
22 u8 r, g, b; 23
23
24 memset(&hdr, 0, sizeof(hdr));
25 hdr.datatypecode = 2; // uncompressed RGB
26 hdr.bitsperpixel = 24; // 24 bpp
27 hdr.width = width;
28 hdr.height = height;
29
30 fout = fopen(filename.c_str(), "wb");
31 fwrite(&hdr, sizeof(TGAHeader), 1, fout); 24 fwrite(&hdr, sizeof(TGAHeader), 1, fout);
32 for (int i = 0; i < height; i++) { 25
33 for (int j = 0; j < width; j++) { 26 for (int y = 0; y < height; y++) {
34 b = raw_data[(3 * (i * width)) + (3 * j) + 0]; 27 for (int x = 0; x < width; x++) {
35 g = raw_data[(3 * (i * width)) + (3 * j) + 1]; 28 putc(raw_data[(3 * (y * width)) + (3 * x) + 0], fout); // b
36 r = raw_data[(3 * (i * width)) + (3 * j) + 2]; 29 putc(raw_data[(3 * (y * width)) + (3 * x) + 1], fout); // g
37 putc(b, fout); 30 putc(raw_data[(3 * (y * width)) + (3 * x) + 2], fout); // r
38 putc(g, fout);
39 putc(r, fout);
40 } 31 }
41 } 32 }
33
42 fclose(fout); 34 fclose(fout);
43} 35}
44} // namespace 36} // namespace