diff options
| author | Eli Zaretskii | 2019-03-28 18:00:06 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-03-28 18:00:06 +0200 |
| commit | 2da9f8bf4222fda504f43b4757e154999cdbbf2c (patch) | |
| tree | 1d26e676a935a1897906a425c7eb8b9d6a8281dd | |
| parent | 2654c0b61b2cb8ee14d84f042ae6fc605adf64a8 (diff) | |
| download | emacs-2da9f8bf4222fda504f43b4757e154999cdbbf2c.tar.gz emacs-2da9f8bf4222fda504f43b4757e154999cdbbf2c.zip | |
Fix display of sliced images on MS-Windows
* src/w32term.c (x_draw_image_foreground): Fix detection of
scaled images for sliced images. Scale the original width of
a slice and its coordinates of origin as well.
| -rw-r--r-- | src/w32term.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/w32term.c b/src/w32term.c index 0f0d6482fc3..4d5f2e7c3cc 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -1896,6 +1896,24 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 1896 | orig_height = s->slice.height; | 1896 | orig_height = s->slice.height; |
| 1897 | } | 1897 | } |
| 1898 | 1898 | ||
| 1899 | double w_factor = 1.0, h_factor = 1.0; | ||
| 1900 | bool scaled = false; | ||
| 1901 | int orig_slice_width = s->slice.width, | ||
| 1902 | orig_slice_height = s->slice.height; | ||
| 1903 | int orig_slice_x = s->slice.x, orig_slice_y = s->slice.y; | ||
| 1904 | /* For scaled images we need to restore the original slice's | ||
| 1905 | dimensions and origin coordinates, from before the scaling. */ | ||
| 1906 | if (s->img->width != orig_width || s->img->height != orig_height) | ||
| 1907 | { | ||
| 1908 | scaled = true; | ||
| 1909 | w_factor = (double) orig_width / (double) s->img->width; | ||
| 1910 | h_factor = (double) orig_height / (double) s->img->height; | ||
| 1911 | orig_slice_width = s->slice.width * w_factor + 0.5; | ||
| 1912 | orig_slice_height = s->slice.height * h_factor + 0.5; | ||
| 1913 | orig_slice_x = s->slice.x * w_factor + 0.5; | ||
| 1914 | orig_slice_y = s->slice.y * h_factor + 0.5; | ||
| 1915 | } | ||
| 1916 | |||
| 1899 | if (s->img->mask) | 1917 | if (s->img->mask) |
| 1900 | { | 1918 | { |
| 1901 | HDC mask_dc = CreateCompatibleDC (s->hdc); | 1919 | HDC mask_dc = CreateCompatibleDC (s->hdc); |
| @@ -1903,7 +1921,7 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 1903 | 1921 | ||
| 1904 | SetTextColor (s->hdc, RGB (255, 255, 255)); | 1922 | SetTextColor (s->hdc, RGB (255, 255, 255)); |
| 1905 | SetBkColor (s->hdc, RGB (0, 0, 0)); | 1923 | SetBkColor (s->hdc, RGB (0, 0, 0)); |
| 1906 | if (s->slice.width == orig_width && s->slice.height == orig_height) | 1924 | if (!scaled) |
| 1907 | { | 1925 | { |
| 1908 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1926 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1909 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); | 1927 | compat_hdc, s->slice.x, s->slice.y, SRCINVERT); |
| @@ -1922,14 +1940,14 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 1922 | && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) | 1940 | && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) |
| 1923 | SetBrushOrgEx (s->hdc, 0, 0, NULL); | 1941 | SetBrushOrgEx (s->hdc, 0, 0, NULL); |
| 1924 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1942 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1925 | compat_hdc, s->slice.x, s->slice.y, | 1943 | compat_hdc, orig_slice_x, orig_slice_y, |
| 1926 | orig_width, orig_height, SRCINVERT); | 1944 | orig_slice_width, orig_slice_height, SRCINVERT); |
| 1927 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1945 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1928 | mask_dc, s->slice.x, s->slice.y, | 1946 | mask_dc, orig_slice_x, orig_slice_y, |
| 1929 | orig_width, orig_height, SRCAND); | 1947 | orig_slice_width, orig_slice_height, SRCAND); |
| 1930 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1948 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1931 | compat_hdc, s->slice.x, s->slice.y, | 1949 | compat_hdc, orig_slice_x, orig_slice_y, |
| 1932 | orig_width, orig_height, SRCINVERT); | 1950 | orig_slice_width, orig_slice_height, SRCINVERT); |
| 1933 | if (pmode) | 1951 | if (pmode) |
| 1934 | SetStretchBltMode (s->hdc, pmode); | 1952 | SetStretchBltMode (s->hdc, pmode); |
| 1935 | } | 1953 | } |
| @@ -1940,7 +1958,7 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 1940 | { | 1958 | { |
| 1941 | SetTextColor (s->hdc, s->gc->foreground); | 1959 | SetTextColor (s->hdc, s->gc->foreground); |
| 1942 | SetBkColor (s->hdc, s->gc->background); | 1960 | SetBkColor (s->hdc, s->gc->background); |
| 1943 | if (s->slice.width == orig_width && s->slice.height == orig_height) | 1961 | if (!scaled) |
| 1944 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1962 | BitBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1945 | compat_hdc, s->slice.x, s->slice.y, SRCCOPY); | 1963 | compat_hdc, s->slice.x, s->slice.y, SRCCOPY); |
| 1946 | else | 1964 | else |
| @@ -1951,8 +1969,8 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 1951 | && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) | 1969 | && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0) |
| 1952 | SetBrushOrgEx (s->hdc, 0, 0, NULL); | 1970 | SetBrushOrgEx (s->hdc, 0, 0, NULL); |
| 1953 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, | 1971 | StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height, |
| 1954 | compat_hdc, s->slice.x, s->slice.y, | 1972 | compat_hdc, orig_slice_x, orig_slice_y, |
| 1955 | orig_width, orig_height, SRCCOPY); | 1973 | orig_slice_width, orig_slice_height, SRCCOPY); |
| 1956 | if (pmode) | 1974 | if (pmode) |
| 1957 | SetStretchBltMode (s->hdc, pmode); | 1975 | SetStretchBltMode (s->hdc, pmode); |
| 1958 | } | 1976 | } |