gdiplus: Implement bilinear interpolation.
authorVincent Povirk <vincent@codeweavers.com>
Thu, 10 Mar 2011 17:03:39 +0000 (11:03 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 11 Mar 2011 10:47:34 +0000 (11:47 +0100)
dlls/gdiplus/graphics.c

index 3b7b7ba8ab39385cc1dde3a58c9cf6863cd7812a..07239e08b759abafde5d690d7392658cfafd006a 100644 (file)
@@ -538,6 +538,40 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
         if (!fixme++)
             FIXME("Unimplemented interpolation %i\n", interpolation);
         /* fall-through */
+    case InterpolationModeBilinear:
+    {
+        REAL leftxf, topyf;
+        INT leftx, rightx, topy, bottomy;
+        ARGB topleft, topright, bottomleft, bottomright;
+        ARGB top, bottom;
+        float x_offset;
+
+        leftxf = floorf(point->X);
+        leftx = (INT)leftxf;
+        rightx = (INT)ceilf(point->X);
+        topyf = floorf(point->Y);
+        topy = (INT)topyf;
+        bottomy = (INT)ceilf(point->Y);
+
+        if (leftx == rightx && topy == bottomy)
+            return sample_bitmap_pixel(src_rect, bits, width, height,
+                leftx, topy, attributes);
+
+        topleft = sample_bitmap_pixel(src_rect, bits, width, height,
+            leftx, topy, attributes);
+        topright = sample_bitmap_pixel(src_rect, bits, width, height,
+            rightx, topy, attributes);
+        bottomleft = sample_bitmap_pixel(src_rect, bits, width, height,
+            leftx, bottomy, attributes);
+        bottomright = sample_bitmap_pixel(src_rect, bits, width, height,
+            rightx, bottomy, attributes);
+
+        x_offset = point->X - leftxf;
+        top = blend_colors(topleft, topright, x_offset);
+        bottom = blend_colors(bottomleft, bottomright, x_offset);
+
+        return blend_colors(top, bottom, point->Y - topyf);
+    }
     case InterpolationModeNearestNeighbor:
         return sample_bitmap_pixel(src_rect, bits, width, height,
             roundr(point->X), roundr(point->Y), attributes);