mirror of
https://github.com/dnet/pySSTV.git
synced 2026-01-02 14:50:00 +01:00
added IronPython wrapper for PIL
This commit is contained in:
parent
63b97f07cf
commit
f34d1f7db7
|
|
@ -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
26
pysstv/monoPIL.py
Normal 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)
|
||||
Loading…
Reference in a new issue