mirror of
https://github.com/dnet/pySSTV.git
synced 2026-04-21 06:03:43 +00:00
added IronPython wrapper for PIL
This commit is contained in:
parent
63b97f07cf
commit
f34d1f7db7
2 changed files with 30 additions and 1 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
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 argparse import ArgumentParser
|
||||||
from sys import stderr
|
from sys import stderr
|
||||||
import color
|
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…
Add table
Add a link
Reference in a new issue