imgv

Sign in or create your account | Project List | Help

View 0001-properly-handles-image-ben-res.-addds-q-as-exit-key.patch

1From d02f132104cfc1885d48edde8259cfed6c087752 Mon Sep 17 00:00:00 2001
2From: steve <s.qi@pictorii.com>
3Date: Fri, 18 Jun 2010 12:50:03 +1000
4Subject: [PATCH] properly handles image < ben res. addds 'q' as exit key
5
6---
7 sdl-imageviewer.c | 9 +++++----
8 1 files changed, 5 insertions(+), 4 deletions(-)
9
10diff --git a/sdl-imageviewer.c b/sdl-imageviewer.c
11index 1b6bb7d..639a49f 100644
12--- a/sdl-imageviewer.c
13+++ b/sdl-imageviewer.c
14@@ -108,10 +108,8 @@ int main(int argc, char *argv[])
15     // Starting point (default view): uniform scaling to best screen fit, keep aspect ratio
16     scale_x = (double) (SCREENWIDTH) / (double) (imgWidth);
17     scale_y = (double) (SCREENHEIGHT) / (double) (imgHeight);
18- if (scale_y < scale_x)
19- scale = scale_y;
20- else
21- scale = scale_x;
22+ scale = fmin(scale_x, scale_y);
23+ scale = fmin(1,scale);
24     scaled_img = zoomSurface (picture, scale, scale, SMOOTHING_ON);
25     if (scaled_img == (SDL_Surface *) (NULL))
26     {
27@@ -184,6 +182,7 @@ int main(int argc, char *argv[])
28                           case SDLK_UP:
29                               upPressed = TRUE;
30                           break;
31+ case SDLK_q:
32                           case SDLK_ESCAPE:
33                             if (picture)
34                                 SDL_FreeSurface (picture);
35@@ -397,6 +396,8 @@ int main(int argc, char *argv[])
36             }
37 
38             SDL_FillRect(screen, (SDL_Rect *) NULL, 0); // draw background color (black)
39+ picturePortion.w = scaled_img->w;
40+ picturePortion.h = scaled_img->h;
41             SDL_BlitSurface(scaled_img, &picturePortion, screen, &screenPortion);
42             SDL_Flip(screen);
43         } // end of if(SDL_WaitEvent())
44--
451.7.0.4
46
47

Archive Download this file

Attachment to issue 80

Created: 10 years 5 months ago by Shuning Bian



interactive