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