65
68
if self.orientation == "v" and sx == sy:
69
gc.clip_to_rect(self.x, self.y, self.width, self.height)
70
gc.set_alpha(self.alpha)
72
gc.clip_to_rect(self.x, self.y, self.width, self.height)
73
gc.set_alpha(self.alpha)
72
# Kiva image interpolation note:
73
# Kiva's Agg backend uses the interpolation setting of the *source*
74
# image to determine the type of interpolation to use when drawing the
75
# image. The mac backend uses the interpolation setting on the
77
old_interp = self._cached_image.get_image_interpolation()
78
if hasattr(gc, "set_interpolation_quality"):
79
from enthought.kiva.mac.ABCGI import InterpolationQuality
80
interp_quality_dict = {"nearest": InterpolationQuality.none,
81
"bilinear": InterpolationQuality.low,
82
"bicubic": InterpolationQuality.high}
83
gc.set_interpolation_quality(interp_quality_dict[self.interpolation])
84
elif hasattr(gc, "set_image_interpolation"):
85
self._cached_image.set_image_interpolation(self.interpolation)
86
x, y, w, h = self._cached_dest_rect
87
if self.orientation == "h": # for horizontal orientation:
88
gc.translate_ctm(x+w/2, y+h/2) # translate back normally
89
else: # for vertical orientation:
90
gc.translate_ctm(y+h/2, x+w/2) # translate back with dx,dy swap
91
gc.scale_ctm(sx, sy) # flip axes as appropriate
92
if self.orientation == "v": # for vertical orientation:
93
gc.scale_ctm(1,-1) # restore origin to lower left
94
gc.rotate_ctm(pi/2) # rotate 1/4 turn clockwise
95
gc.translate_ctm(-x-w/2, -y-h/2) # translate image center to origin
96
gc.draw_image(self._cached_image, self._cached_dest_rect)
97
self._cached_image.set_image_interpolation(old_interp)
75
# Kiva image interpolation note:
76
# Kiva's Agg backend uses the interpolation setting of the *source*
77
# image to determine the type of interpolation to use when drawing the
78
# image. The mac backend uses the interpolation setting on the
80
old_interp = self._cached_image.get_image_interpolation()
81
if hasattr(gc, "set_interpolation_quality"):
82
from enthought.kiva.quartz.ABCGI import InterpolationQuality
83
interp_quality_dict = {"nearest": InterpolationQuality.none,
84
"bilinear": InterpolationQuality.low,
85
"bicubic": InterpolationQuality.high}
86
gc.set_interpolation_quality(interp_quality_dict[self.interpolation])
87
elif hasattr(gc, "set_image_interpolation"):
88
self._cached_image.set_image_interpolation(self.interpolation)
89
x, y, w, h = self._cached_dest_rect
90
if self.orientation == "h": # for horizontal orientation:
91
gc.translate_ctm(x+w/2, y+h/2) # translate back normally
92
else: # for vertical orientation:
93
gc.translate_ctm(y+h/2, x+w/2) # translate back with dx,dy swap
94
gc.scale_ctm(sx, sy) # flip axes as appropriate
95
if self.orientation == "v": # for vertical orientation:
96
gc.scale_ctm(1,-1) # restore origin to lower left
97
gc.rotate_ctm(pi/2) # rotate 1/4 turn clockwise
98
gc.translate_ctm(-x-w/2, -y-h/2) # translate image center to origin
99
gc.draw_image(self._cached_image, self._cached_dest_rect)
100
self._cached_image.set_image_interpolation(old_interp)
100
102
def map_index(self, screen_pt, threshold=0.0, outside_returns_none=True,
101
103
index_only=False):