diff options
| author | 2014-09-06 20:04:13 -0700 | |
|---|---|---|
| committer | 2014-09-07 12:09:02 -0700 | |
| commit | 0167e9140e2a732c2267bdc4672ecd0360d49227 (patch) | |
| tree | 0016a1230b4ee9299eb6ae2180b2ef513e7406c5 /src | |
| parent | Merge pull request #93 from lioncash/ref (diff) | |
| download | yuzu-0167e9140e2a732c2267bdc4672ecd0360d49227.tar.gz yuzu-0167e9140e2a732c2267bdc4672ecd0360d49227.tar.xz yuzu-0167e9140e2a732c2267bdc4672ecd0360d49227.zip | |
utils: cleaned up DumpTGA, removing redundancies
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/utils.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/utils.h | 2 |
2 files changed, 13 insertions, 21 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 | ||
| 10 | namespace VideoCore { | 10 | namespace 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 | */ |
| 19 | void DumpTGA(std::string filename, int width, int height, u8* raw_data) { | 20 | void 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 |
diff --git a/src/video_core/utils.h b/src/video_core/utils.h index 20d4ec9e0..9cb3d4d43 100644 --- a/src/video_core/utils.h +++ b/src/video_core/utils.h | |||
| @@ -59,6 +59,6 @@ struct TGAHeader { | |||
| 59 | * @param raw_data Raw RGBA8 texture data to dump | 59 | * @param raw_data Raw RGBA8 texture data to dump |
| 60 | * @todo This should be moved to some general purpose/common code | 60 | * @todo This should be moved to some general purpose/common code |
| 61 | */ | 61 | */ |
| 62 | void DumpTGA(std::string filename, int width, int height, u8* raw_data); | 62 | void DumpTGA(std::string filename, short width, short height, u8* raw_data); |
| 63 | 63 | ||
| 64 | } // namespace | 64 | } // namespace |