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.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp
index 67d74a2d8..9fcefaad3 100644
--- a/src/video_core/utils.cpp
+++ b/src/video_core/utils.cpp
@@ -8,39 +8,39 @@
8#include "video_core/utils.h" 8#include "video_core/utils.h"
9 9
10namespace VideoCore { 10namespace VideoCore {
11 11
12/** 12 /**
13 * Dumps a texture to TGA 13 * Dumps a texture to TGA
14 * @param filename String filename to dump texture to 14 * @param filename String filename to dump texture to
15 * @param width Width of texture in pixels 15 * @param width Width of texture in pixels
16 * @param height Height of texture in pixels 16 * @param height Height of texture in pixels
17 * @param raw_data Raw RGBA8 texture data to dump 17 * @param raw_data Raw RGBA8 texture data to dump
18 * @todo This should be moved to some general purpose/common code 18 * @todo This should be moved to some general purpose/common code
19 */ 19 */
20void DumpTGA(std::string filename, int width, int height, u8* raw_data) { 20 void DumpTGA(std::string filename, int width, int height, u8* raw_data) {
21 TGAHeader hdr; 21 TGAHeader hdr;
22 FILE* fout; 22 FILE* fout;
23 u8 r, g, b; 23 u8 r, g, b;
24 24
25 memset(&hdr, 0, sizeof(hdr)); 25 memset(&hdr, 0, sizeof(hdr));
26 hdr.datatypecode = 2; // uncompressed RGB 26 hdr.datatypecode = 2; // uncompressed RGB
27 hdr.bitsperpixel = 24; // 24 bpp 27 hdr.bitsperpixel = 24; // 24 bpp
28 hdr.width = width; 28 hdr.width = width;
29 hdr.height = height; 29 hdr.height = height;
30 30
31 fout = fopen(filename.c_str(), "wb"); 31 fout = fopen(filename.c_str(), "wb");
32 fwrite(&hdr, sizeof(TGAHeader), 1, fout); 32 fwrite(&hdr, sizeof(TGAHeader), 1, fout);
33 for (int i = 0; i < height; i++) { 33 for (int i = 0; i < height; i++) {
34 for (int j = 0; j < width; j++) { 34 for (int j = 0; j < width; j++) {
35 r = raw_data[(4 * (i * width)) + (4 * j) + 0]; 35 b = raw_data[(3 * (i * width)) + (3 * j) + 0];
36 g = raw_data[(4 * (i * width)) + (4 * j) + 1]; 36 g = raw_data[(3 * (i * width)) + (3 * j) + 1];
37 b = raw_data[(4 * (i * width)) + (4 * j) + 2]; 37 r = raw_data[(3 * (i * width)) + (3 * j) + 2];
38 putc(b, fout); 38 putc(b, fout);
39 putc(g, fout); 39 putc(g, fout);
40 putc(r, fout); 40 putc(r, fout);
41 } 41 }
42 } 42 }
43 fclose(fout); 43 fclose(fout);
44} 44 }
45 45
46} // namespace 46} // namespace \ No newline at end of file