From f5c2cd130b5275c1396fb7f7df400cd64e48dcfc Mon Sep 17 00:00:00 2001 From: psperl Date: Fri, 5 Oct 2007 17:47:48 +0000 Subject: [PATCH] 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 --- src/projectM-engine/image_helper.c | 14 ++++-- src/projectM-xmms/main.cpp | 81 ++++++++++++++++-------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/projectM-engine/image_helper.c b/src/projectM-engine/image_helper.c index 1fab1343a..203feda44 100644 --- a/src/projectM-engine/image_helper.c +++ b/src/projectM-engine/image_helper.c @@ -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; diff --git a/src/projectM-xmms/main.cpp b/src/projectM-xmms/main.cpp index f23e66e34..634f72f67 100755 --- a/src/projectM-xmms/main.cpp +++ b/src/projectM-xmms/main.cpp @@ -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); + }