master
LEdoian 3 years ago
parent a41c94bf30
commit bcf5eeb3f3

@ -78,12 +78,12 @@ class Picture:
class Interpolator:
def interpolate(self, picture, new_h, new_w):
quantum_x = new_w / picture.w
quantum_y = new_h / picture.h
quantum_x = picture.w / new_w
quantum_y = picture.h / new_h
result = [[None for _ in range(new_w)] for _ in range(new_h)]
for x in range(new_w):
for y in range(new_h):
result[y][x] = self.get_pixel(picture, x, y, result, quantum_x, quantum_y)
result[y][x] = self.get_pixel(picture, x*quantum_x, y*quantum_y, result, quantum_x, quantum_y)
return Picture(result)

@ -4,6 +4,6 @@ class Nearest(lib.Interpolator):
def get_pixel(self, pic, x, y, r, qx, qy):
rx = round(x)
ry = round(y)
pix = pic.pixels[y][x]
pix = pic.pixels[ry][rx]
return pix

Loading…
Cancel
Save