pySSTV/pysstv/monoPIL.py

27 lines
552 B
Python
Raw Permalink Normal View History

2013-12-07 10:49:43 +01:00
#!/usr/bin/env python
"""primitive partial PIL to IronPython (.Net) wrapper"""
import clr
clr.AddReference("System.Drawing")
from System.Drawing import Image as SDI
class Image(object):
@classmethod
def open(_cls, filename):
return Image(SDI.FromFile(filename))
def __init__(self, img):
self.img = img
self.size = (img.Width, img.Height)
def convert(self, _ignore):
return self # TODO
def load(self):
return self
def __getitem__(self, (x, y)):
color = self.img.GetPixel(x, y)
return int(color.R), int(color.G), int(color.B)