|
|
|
@ -51,8 +51,29 @@ class Picture:
|
|
|
|
|
assert result.h == ht
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def _to_pil(self):
|
|
|
|
|
# Create int iterable
|
|
|
|
|
# TODO: If this is slow, we should use a generator.
|
|
|
|
|
seq = []
|
|
|
|
|
for line in self.pixels:
|
|
|
|
|
for pix in line:
|
|
|
|
|
seq.extend(pix)
|
|
|
|
|
|
|
|
|
|
# bytes…
|
|
|
|
|
b = bytes(seq)
|
|
|
|
|
|
|
|
|
|
# PIL image
|
|
|
|
|
from PIL import Image
|
|
|
|
|
img = Image.frombytes('RGB', (self.w, self.h), b)
|
|
|
|
|
return img
|
|
|
|
|
|
|
|
|
|
def show(self): ...
|
|
|
|
|
def show(self):
|
|
|
|
|
img = self._to_pil()
|
|
|
|
|
img.show()
|
|
|
|
|
|
|
|
|
|
def save(self, filename):
|
|
|
|
|
img = self._to_pil()
|
|
|
|
|
img.save(filename)
|
|
|
|
|
|
|
|
|
|
class Interpolator:
|
|
|
|
|
def interpolate(self, picture, new_h, new_w):
|
|
|
|
|