]> mj.ucw.cz Git - libucw.git/blobdiff - images/scale.c
rest of bbuf printf
[libucw.git] / images / scale.c
index f617b01e49589678c3c11957faf7c6bf921f2123..2c351cbdcb6714d47e4a4f74a69bff680dbea3d3 100644 (file)
@@ -68,13 +68,13 @@ image_scale(struct image_thread *it, struct image *dest, struct image *src)
 void
 image_dimensions_fit_to_box(u32 *cols, u32 *rows, u32 max_cols, u32 max_rows, uns upsample)
 {
-  ASSERT(*cols && *rows && *cols <= 0xffff && *rows <= 0xffff);
-  ASSERT(max_cols && max_rows && max_cols <= 0xffff && max_rows <= 0xffff);
+  ASSERT(*cols && *rows && *cols <= IMAGE_MAX_SIZE && *rows <= IMAGE_MAX_SIZE);
+  ASSERT(max_cols && max_rows && max_cols <= IMAGE_MAX_SIZE && max_rows <= IMAGE_MAX_SIZE);
   if (*cols <= max_cols && *rows <= max_rows)
     {
       if (!upsample)
        return;
-      if (max_cols / *cols > max_rows / *rows)
+      if (max_cols * *rows > max_rows * *cols)
         {
          *cols = *cols * max_rows / *rows;
          *cols = MIN(*cols, max_cols);
@@ -100,5 +100,4 @@ down_rows:
   *rows = *rows * max_cols / *cols;
   *rows = MAX(*rows, 1);
   *cols = max_cols;
-  return;
 }