added IronPython wrapper for PIL

This commit is contained in:
András Veres-Szentkirályi 2013-12-07 10:49:43 +01:00
parent 63b97f07cf
commit f34d1f7db7
2 changed files with 30 additions and 1 deletions

View file

@ -1,7 +1,10 @@
#!/usr/bin/env python
from __future__ import print_function
from PIL import Image
try:
from PIL import Image
except ImportError:
from monoPIL import Image
from argparse import ArgumentParser
from sys import stderr
import color

26
pysstv/monoPIL.py Normal file
View file

@ -0,0 +1,26 @@
#!/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)