mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-12 18:35:20 +00:00
SOIL patch from Jonathon, projectM-xmms will take an upside down screen shot if you press c and place it in ~/.projectM/*.bmp
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@532 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -47,12 +47,18 @@ int
|
||||
float sampley = y0;
|
||||
int intx, inty;
|
||||
int base_index;
|
||||
if( samplex < 0.0f ) { samplex = 0.0f; }
|
||||
if( samplex > width-2.000001f ) { samplex = width-2.000001f; }
|
||||
if( sampley < 0.0f ) { sampley = 0.0f; }
|
||||
if( sampley > height-2.000001f ) { sampley = height-2.000001f; }
|
||||
intx = (int)samplex;
|
||||
inty = (int)sampley;
|
||||
if( intx < 0 )
|
||||
intx = 0;
|
||||
else if( intx > width - 2 )
|
||||
intx = width - 2;
|
||||
if( inty < 0 )
|
||||
inty = 0;
|
||||
else if( inty > height - 2 )
|
||||
inty = height - 2;
|
||||
|
||||
|
||||
samplex -= intx;
|
||||
sampley -= inty;
|
||||
base_index = inty * width * channels + intx * channels;
|
||||
|
||||
@ -420,50 +420,55 @@ std::string read_config()
|
||||
}
|
||||
|
||||
int frame = 1;
|
||||
char dumpPath[128];
|
||||
|
||||
|
||||
void saveSnapshotToFile()
|
||||
{
|
||||
|
||||
char dumpPath[512];
|
||||
char Home[512];
|
||||
//char *home;
|
||||
|
||||
SDL_Surface * bitmap;
|
||||
|
||||
GLint viewport[4];
|
||||
long bytewidth;
|
||||
GLint width, height;
|
||||
long bytes;
|
||||
|
||||
glReadBuffer(GL_FRONT);
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
width = viewport[2];
|
||||
height = viewport[3];
|
||||
|
||||
GLint viewport[4];
|
||||
long bytewidth;
|
||||
GLint width, height;
|
||||
long bytes;
|
||||
|
||||
glReadBuffer(GL_FRONT);
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
width = viewport[2];
|
||||
height = viewport[3];
|
||||
|
||||
bytewidth = width * 4;
|
||||
bytewidth = (bytewidth + 3) & ~3;
|
||||
bytes = bytewidth * height;
|
||||
|
||||
/*
|
||||
glFinish();
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
*/
|
||||
|
||||
|
||||
bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,0,0,0,0);
|
||||
glReadPixels(0, 0, width, height,
|
||||
GL_BGRA,
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
bitmap->pixels);
|
||||
|
||||
sprintf(dumpPath, "/home/pete/.projectM/%.8d.bmp", frame++);
|
||||
|
||||
SDL_SaveBMP(bitmap, dumpPath);
|
||||
|
||||
SDL_FreeSurface(bitmap);
|
||||
|
||||
bytewidth = width * 4;
|
||||
bytewidth = (bytewidth + 3) & ~3;
|
||||
bytes = bytewidth * height;
|
||||
|
||||
/*
|
||||
glFinish();
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
*/
|
||||
|
||||
|
||||
bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,0,0,0,0);
|
||||
glReadPixels(0, 0, width, height,
|
||||
GL_BGRA,
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
bitmap->pixels);
|
||||
|
||||
sprintf(dumpPath, "/.projectM/%.8d.bmp", frame++);
|
||||
// home=getenv("HOME");
|
||||
strcpy(Home, getenv("HOME"));
|
||||
strcpy(Home+strlen(Home), dumpPath);
|
||||
Home[strlen(Home)]='\0';
|
||||
SDL_SaveBMP(bitmap, Home);
|
||||
|
||||
SDL_FreeSurface(bitmap);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user