aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorCecilio Pardo2024-11-04 18:58:40 +0100
committerEli Zaretskii2024-11-05 14:37:07 +0200
commit4e8bf2977e6d1abf6d3cf82e9c1ae3dee5bfcda0 (patch)
treec52d029ee9f13d91f075bf2b34d0380274955d84 /src/w32term.c
parent8a7910fb67e3b89de430d3b3e5009b145ec0c602 (diff)
downloademacs-4e8bf2977e6d1abf6d3cf82e9c1ae3dee5bfcda0.tar.gz
emacs-4e8bf2977e6d1abf6d3cf82e9c1ae3dee5bfcda0.zip
Support :transform-smoothing on images (MS-Windows) (bug#57166)
* src/dispextern.h (struct image): Add field 'smoothing' for NTGUI. * src/image.c (image_set_transform): Assign the 'smoothing' field of the image struct. * src/w32gdiplus.h: Add references to more GDI+ functions. * src/w32image.c (gdiplus_init): Add references to more GDI+ functions. * src/w32term.c (w32_draw_image_foreground): If the image is marked for smoothing and GDI+ is available, draw it with GDI+ bilinear interpolation. * etc/NEWS: New entry for this change.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 88622700386..e18f39dd2a8 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -24,6 +24,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
24#include "blockinput.h" 24#include "blockinput.h"
25#include "w32term.h" 25#include "w32term.h"
26#include "w32common.h" /* for OS version info */ 26#include "w32common.h" /* for OS version info */
27#include <wtypes.h>
28#include <gdiplus.h>
29#include "w32gdiplus.h"
27 30
28#include <ctype.h> 31#include <ctype.h>
29#include <errno.h> 32#include <errno.h>
@@ -2106,16 +2109,53 @@ w32_draw_image_foreground (struct glyph_string *s)
2106 compat_hdc, s->slice.x, s->slice.y, SRCCOPY); 2109 compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
2107 else 2110 else
2108 { 2111 {
2109 int pmode = 0; 2112#ifdef HAVE_NATIVE_IMAGE_API
2110 /* Windows 9X doesn't support HALFTONE. */ 2113 if (s->img->smoothing && w32_gdiplus_startup ())
2111 if (os_subtype == OS_SUBTYPE_NT 2114 {
2112 && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) 2115 GpGraphics *graphics;
2113 SetBrushOrgEx (s->hdc, 0, 0, NULL); 2116 if (GdipCreateFromHDC (s->hdc, &graphics) == Ok)
2114 StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, 2117 {
2115 compat_hdc, orig_slice_x, orig_slice_y, 2118 GpBitmap *gp_bitmap;
2116 orig_slice_width, orig_slice_height, SRCCOPY); 2119 /* Can't create a GpBitmap from a HBITMAP that was
2117 if (pmode) 2120 ever selected into a DC, so we need to copy. */
2118 SetStretchBltMode (s->hdc, pmode); 2121 HBITMAP copy
2122 = CopyImage (GetCurrentObject (compat_hdc, OBJ_BITMAP),
2123 IMAGE_BITMAP, 0, 0, 0);
2124 if (GdipCreateBitmapFromHBITMAP (copy, NULL,
2125 &gp_bitmap) == Ok)
2126 {
2127 GdipSetInterpolationMode (graphics,
2128 InterpolationModeHighQualityBilinear);
2129 GdipDrawImageRectRectI (graphics,
2130 gp_bitmap, x, y,
2131 s->slice.width,
2132 s->slice.height,
2133 orig_slice_x,
2134 orig_slice_y,
2135 orig_slice_width,
2136 orig_slice_height,
2137 UnitPixel,
2138 NULL, NULL, NULL);
2139 GdipDisposeImage (gp_bitmap);
2140 }
2141 DeleteObject (copy);
2142 GdipDeleteGraphics (graphics);
2143 }
2144 }
2145 else
2146#endif
2147 {
2148 int pmode = 0;
2149 /* Windows 9X doesn't support HALFTONE. */
2150 if (os_subtype == OS_SUBTYPE_NT
2151 && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0)
2152 SetBrushOrgEx (s->hdc, 0, 0, NULL);
2153 StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height,
2154 compat_hdc, orig_slice_x, orig_slice_y,
2155 orig_slice_width, orig_slice_height, SRCCOPY);
2156 if (pmode)
2157 SetStretchBltMode (s->hdc, pmode);
2158 }
2119 } 2159 }
2120 2160
2121 /* When the image has a mask, we can expect that at 2161 /* When the image has a mask, we can expect that at