changeset 489:8f7293125059

Implemented natural image scaling when only one dimenssion is given. Part #2
author Jorge Arellano Cid <jcid@dillo.org>
date Sun, 11 Jan 2009 08:50:21 -0300
parents 66fda00f15d2
children a7095f0cfc4f 0f34d430a80b
files dw/image.cc
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/dw/image.cc	Sat Jan 10 21:37:17 2009 -0300
+++ b/dw/image.cc	Sun Jan 11 08:50:21 2009 -0300
@@ -207,10 +207,9 @@
           " = %d - %d = %d\n", this->getHeight(), getStyle()->boxDiffHeight(),
           this->getHeight() - getStyle()->boxDiffHeight());
 #endif
-   if (buffer != NULL &&
-       /* It may be, that the image is allocated at zero content size. In this
-        * case, we simply wait. */
-       getContentWidth () > 0 && getContentHeight () > 0) {
+   if (buffer && (getContentWidth () > 0 || getContentHeight () > 0)) {
+      // Zero content size : simply wait...
+      // Only one dimension: naturally scale
       oldBuffer = buffer;
       buffer = oldBuffer->getScaledBuf (allocation->width - dx,
                                         allocation->ascent
@@ -355,11 +354,10 @@
    if (resize)
       queueResize (0, true);
 
-   // If the image has not yet been allocated, or is allocated at zero
-   // content size, the first part is useless.
    if (wasAllocated () && getContentWidth () > 0 && getContentHeight () > 0) {
-         this->buffer =
-            buffer->getScaledBuf (getContentWidth (), getContentHeight ());
+      // Only scale when both dimensions are known.
+      this->buffer =
+         buffer->getScaledBuf (getContentWidth (), getContentHeight ());
    } else {
       this->buffer = buffer;
       buffer->ref ();