summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/video
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1993-01-27 11:39:37 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1993-01-27 11:39:37 (GMT)
commite6f49ecfa908c747ca976749fee6a047e3f1b1ad (patch)
tree65162cfd9507255a109ebadc00a72088e1b3f01a /Demo/sgi/video
parent2c49017279b89b9631a1cb6adc8fda72ff9c26c9 (diff)
downloadcpython-e6f49ecfa908c747ca976749fee6a047e3f1b1ad.zip
cpython-e6f49ecfa908c747ca976749fee6a047e3f1b1ad.tar.gz
cpython-e6f49ecfa908c747ca976749fee6a047e3f1b1ad.tar.bz2
Initial (skeleton) version of universal image format converter
Diffstat (limited to 'Demo/sgi/video')
-rwxr-xr-xDemo/sgi/video/imgconv.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Demo/sgi/video/imgconv.py b/Demo/sgi/video/imgconv.py
new file mode 100755
index 0000000..6e83806
--- /dev/null
+++ b/Demo/sgi/video/imgconv.py
@@ -0,0 +1,38 @@
+import imageop
+
+error = 'imgconv.error'
+
+LOSSY = 1
+NOT_LOSSY = 0
+
+def null(img, x, y):
+ return img
+
+def mono2grey(img, x, y):
+ imageop.mono2grey(img, x, y, 0, 255)
+
+converters = [ \
+ ('grey', 'grey4', imageop.grey2grey4, LOSSY), \
+ ('grey', 'grey2', imageop.dither2grey2, LOSSY), \
+ ('grey', 'mono', imageop.dither2mono, LOSSY), \
+ ('mono', 'grey', mono2grey, NOT_LOSSY), \
+ ('grey2', 'grey', imageop.grey22grey, NOT_LOSSY), \
+ ('grey4', 'grey', imageop.grey42grey, NOT_LOSSY), \
+]
+
+def addconverter(fcs, tcs, lossy, func):
+ for i in range(len(converters)):
+ ifcs, itcs, irtn, ilossy = converters[i]
+ if (fcs, tcs) == (ifcs, itcs):
+ converters[i] = (fcs, tcs, func, lossy)
+ return
+ converters.append((fcs,tcs,lossy,func))
+
+def getconverter(fcs, tcs):
+ if fcs == tcs: return null
+
+ for ifcs, itcs, irtn, ilossy in converters:
+ if (fcs, tcs) == (ifcs, itcs):
+ return irtn
+ raise error, 'Sorry, that conversion is not implemented'
+