@@ -1032,13 +1032,21 @@ def __init__(self, bbox,
1032
1032
filternorm = 1 ,
1033
1033
filterrad = 4.0 ,
1034
1034
resample = False ,
1035
+ interp_at_native = True ,
1035
1036
** kwargs
1036
1037
):
1037
1038
1038
1039
"""
1039
1040
cmap is a colors.Colormap instance
1040
1041
norm is a colors.Normalize instance to map luminance to 0-1
1041
1042
1043
+ interp_at_native is a flag that determines whether or not interpolation should
1044
+ still be applied when the image is displayed at its native resolution. A common
1045
+ use case for this is when displaying an image for annotational purposes; it is
1046
+ treated similarly to Photoshop (interpolation is only used when displaying the
1047
+ image at non-native resolutions).
1048
+
1049
+
1042
1050
kwargs are an optional list of Artist keyword args
1043
1051
1044
1052
"""
@@ -1054,6 +1062,7 @@ def __init__(self, bbox,
1054
1062
)
1055
1063
1056
1064
self .bbox = bbox
1065
+ self .interp_at_native = interp_at_native
1057
1066
1058
1067
def get_window_extent (self , renderer = None ):
1059
1068
if renderer is None :
@@ -1120,13 +1129,16 @@ def make_image(self, renderer, magnification=1.0):
1120
1129
im .set_resample (self ._resample )
1121
1130
1122
1131
l , b , r , t = self .get_window_extent (renderer ).extents #bbox.extents
1123
- widthDisplay = ( round (r ) + 0.5 ) - ( round (l ) - 0.5 )
1124
- heightDisplay = ( round (t ) + 0.5 ) - ( round (b ) - 0.5 )
1132
+ widthDisplay = round (r ) - round (l )
1133
+ heightDisplay = round (t ) - round (b )
1125
1134
widthDisplay *= magnification
1126
1135
heightDisplay *= magnification
1127
1136
1128
1137
numrows , numcols = self ._A .shape [:2 ]
1129
1138
1139
+ if not self .interp_at_native and widthDisplay == numcols and heightDisplay == numrows :
1140
+ im .set_interpolation (0 )
1141
+
1130
1142
# resize viewport to display
1131
1143
rx = widthDisplay / numcols
1132
1144
ry = heightDisplay / numrows
0 commit comments