You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
620 B
Python
24 lines
620 B
Python
import lib
|
|
import math
|
|
|
|
class BiLinear(lib.Interpolator):
|
|
def get_pixel(self, pic, x, y, r, qx, qy):
|
|
leftx = math.floor(x)
|
|
rightx = math.ceil(x)
|
|
topy = math.floor(y)
|
|
bottomy = math.ceil(y)
|
|
|
|
left = pic.at(leftx, topy)
|
|
right = pic.at(leftx, topy)
|
|
dist = x % 1
|
|
top = (left * (1 - dist) + right * dist)
|
|
|
|
left = pic.at(leftx, bottomy)
|
|
right = pic.at(leftx, bottomy)
|
|
bottom = (left * (1 - dist) + right * dist)
|
|
|
|
dist = y % 1
|
|
pix = (top * (1 - dist) + bottom * dist)
|
|
|
|
return pix
|