Trying to scale to different sizes
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 13 Aug 2008 03:42:39 +0000 (00:42 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 13 Aug 2008 03:42:39 +0000 (00:42 -0300)
movie.c

diff --git a/movie.c b/movie.c
index 290787b..05595a4 100644 (file)
--- a/movie.c
+++ b/movie.c
@@ -162,17 +162,18 @@ CairoTarget (SDL_Surface *image)
   static cairo_surface_t *surface = NULL;
   static cairo_t *ctx = NULL;
   cairo_surface_t *source;
-  double rx, ry;
+  static double rx = 1.0, ry = 1.0;
   if (data == NULL && surface == NULL && ctx == NULL)
   {
     data = malloc (WIDTH * HEIGHT * 4);
     surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
                                                   WIDTH, HEIGHT, WIDTH * 4);
     ctx = cairo_create (surface);
-    rx = (double) WIDTH / (double) image->w;
-    ry = (double) HEIGHT / (double) image->h;
-    cairo_scale (ctx, rx, ry);
   }
+  cairo_scale (ctx, 1.0/rx, 1.0/ry);
+  rx = (double) WIDTH / (double) image->w;
+  ry = (double) HEIGHT / (double) image->h;
+  cairo_scale (ctx, rx, ry);
   source = CairoFromSDL (image);
   cairo_set_source_surface (ctx, source, 0, 0);
   cairo_paint (ctx);
@@ -189,9 +190,17 @@ GetNextImage (SDL_Surface *image)
   SDL_Surface *text;
   SDL_Rect box;
   SDL_Color Yellow = { 255, 255, 0, 0};
-  double rx, ry;
-  rx = RX;
-  ry = RY;
+  static double rx = RX, ry = RY, factor = 0.5;
+  if (rx < 0.25)
+  {
+    factor = 2;
+  }
+  if (rx > 2)
+  {
+    factor = 0.5;
+  }
+  rx *= RX;
+  ry *= RY;
   center = GetNextPoint ();
   slice = SDL_CreateRGBSurface (SDL_SWSURFACE, WIDTH*rx, HEIGHT*ry,
                                 32,