X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=src%2Fscreen.cpp;h=7d43e418086a5cf23a7db5a4f3b531c578da5fa7;hb=e164c93218ed4599614f4f6e5e815429a3fedbf7;hp=59d4334ac89eb7ba4d1123531906b4e0e5916863;hpb=b1786b24148036a4d9402cc12ea97466072e988d;p=ipdf%2Fcode.git diff --git a/src/screen.cpp b/src/screen.cpp index 59d4334..7d43e41 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -2,6 +2,8 @@ #include "screen.h" #include "SDL_opengl.h" +#include // for access(2) +#include // for access(2) using namespace IPDF; using namespace std; @@ -139,6 +141,7 @@ void Screen::ScreenShot(const char * filename) const if (pixels == NULL) Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4); + for (int y = 0; y < h; ++y) { glReadPixels(0,h-y-1,w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[y*w*4]); @@ -169,6 +172,11 @@ void Screen::ScreenShot(const char * filename) const */ void Screen::RenderBMP(const char * filename) const { + if (access(filename, R_OK) == -1) + { + Error("No such file \"%s\" - Nothing to render - You might have done this deliberately?", filename); + return; + } SDL_Surface * bmp = SDL_LoadBMP(filename); if (bmp == NULL) Fatal("Failed to load BMP from %s - %s", filename, SDL_GetError());