Skip to content

Commit

Permalink
Use TGAWriter.
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed May 21, 2012
1 parent 92d5f62 commit f6b29a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/gource.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2005,17 +2005,6 @@ void Gource::setMessage(const char* str, ...) {


void Gource::screenshot() { void Gource::screenshot() {


char* screenbuff = new char[display.width * display.height * 4];

glReadPixels(0, 0, display.width, display.height,
GL_RGBA, GL_UNSIGNED_BYTE, screenbuff);

const char tga_header[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
short width = display.width;
short height = display.height;
char bitsperpixel = 32;
char imagedescriptor = 8;

//get next free recording name //get next free recording name
char tganame[256]; char tganame[256];
struct stat finfo; struct stat finfo;
Expand All @@ -2030,22 +2019,9 @@ void Gource::screenshot() {
//write tga //write tga
std::string filename(tganame); std::string filename(tganame);


std::ofstream tga; TGAWriter tga(gGourceSettings.transparent ? 4 : 3);
tga.open(filename.c_str(), std::ios::out | std::ios::binary ); tga.screenshot(filename);


if(!tga.is_open()) return;

tga.write(tga_header, 12);
tga.write((char*)&width, sizeof(short));
tga.write((char*)&height, sizeof(short));
tga.write(&bitsperpixel, 1);
tga.write(&imagedescriptor, 1);

tga.write(screenbuff, display.width * display.height * 4);
tga.close();

delete[] screenbuff;

setMessage("Wrote screenshot %s", tganame); setMessage("Wrote screenshot %s", tganame);
} }


Expand Down
1 change: 1 addition & 0 deletions src/gource.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "core/regex.h" #include "core/regex.h"
#include "core/ppm.h" #include "core/ppm.h"
#include "core/mousecursor.h" #include "core/mousecursor.h"
#include "core/tga.h"


#include "gource_settings.h" #include "gource_settings.h"


Expand Down

0 comments on commit f6b29a7

Please sign in to comment.