gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3044 - Extractor/src/plugins


From: durner
Subject: [GNUnet-SVN] r3044 - Extractor/src/plugins
Date: Sat, 24 Jun 2006 18:32:04 -0700 (PDT)

Author: durner
Date: 2006-06-24 18:32:01 -0700 (Sat, 24 Jun 2006)
New Revision: 3044

Modified:
   Extractor/src/plugins/thumbnailextractorqt.cc
Log:
improve thumbnail quality

Modified: Extractor/src/plugins/thumbnailextractorqt.cc
===================================================================
--- Extractor/src/plugins/thumbnailextractorqt.cc       2006-06-25 01:28:21 UTC 
(rev 3043)
+++ Extractor/src/plugins/thumbnailextractorqt.cc       2006-06-25 01:32:01 UTC 
(rev 3044)
@@ -192,20 +192,28 @@
     height = 1;
   if (width == 0)
     width = 1;
+ 
+  /* Resize image */
+  QImage thumb = img->convertToFormat(colors);
+  delete img;
 
-  if (height > THUMBSIZE) {
-    width = width * THUMBSIZE / height;
-    height = THUMBSIZE;
+  while(true)
+  {
+    width /= 2;
+    if (width < THUMBSIZE)
+      width = THUMBSIZE;
+
+    height /= 2;
+    if (height < THUMBSIZE)
+      height = THUMBSIZE;
+    
+    thumb = thumb.scaled(width, height, Qt::KeepAspectRatio,
+      Qt::SmoothTransformation);
+    
+    if (width == THUMBSIZE && height == THUMBSIZE)
+      break;
   }
-  if (width > THUMBSIZE) {
-    height = height * THUMBSIZE / width;
-    width = THUMBSIZE;
-  }
   
-  QImage thumb = img->scaled(width, height, Qt::KeepAspectRatio,
-    Qt::SmoothTransformation).convertToFormat(colors);
-  delete img;
-  
   buffer.setBuffer(&bytes);
   buffer.open(QIODevice::WriteOnly);
   thumb.save(&buffer, "PNG");





reply via email to

[Prev in Thread] Current Thread [Next in Thread]