File: draw_text_helper.py

package info (click to toggle)
gamera 1:3.4.2+git20160808.1725654-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,312 kB
  • ctags: 24,991
  • sloc: xml: 122,324; ansic: 52,869; cpp: 50,664; python: 35,034; makefile: 118; sh: 101
file content (46 lines) | stat: -rw-r--r-- 5,404 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python

# This script (including  the following line) was generated by running itself:
DATA = 320, 300, 'QlpoOTFBWSZTWdT8V9AAWJt//5JJJJJJJpJZJJJBIpCpJJJJJppNpLJJJIBJJEKVJJLI4A/ufO53Prd6Mni97e15cWWKl3prPPd7eeNnbwdWntjmcc3tyAHoZvduEiQQnop6BTap4EnkjT1NPTUMTamRpp6gDQB6mjIJETIiapijGSDIA0aAAaGgAAAADhoZNNDTI0NMjIMjI0MgMTRk0AZMjEMJNSJNBMmTCamjTKAGgNqPUGjQAGgAHqApKpKbTaICNGifqBPQEMI9QwAGpkYAnoAIkiaelIZFNT1P0oaA0DR6magANAABoDQPagQc/V5u+jPOOthnhRyPQ0BV7HVgNrJhTdUAuymBSUwmoQmoScE+f5aDbk21aqrVyDSMARwBCFJOcQ3sIZECzwYTB4488CGYm4PfFJFDpDEO05LlI90SiLqei/RhTExF1LPDphJx6KwVnuzkkpqk64N0UuMeSzI5WBtE8+pJxBBpGOtxnJZKqQnBtIC+ZWcCc81dIbCXWDRtqiAYai4Ps9M3fRYmVL82mOHtrYzxuqGOTXqkF7EsGJYNLSKCBlEIZqM9iEqM1pNqQLOlKZSdpIFVUimiBcBuPSC9IIOIi+o4pXO6JEwyTL3Z3WHImYp0apUC4i4gc+nJk62OjKOJkU6mlV0VEifCKgIQQAN/pDvh4bozisYrEPX6/hw6YCmlaoOX9qzp42YJ7bNys2uni0dbALWpYsKbYdoFi8OOEvfZez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bz2
import base64

from gamera.core import init_gamera, Point, Dim, RGB, DENSE
from gamera import plugin
from gamera.plugins.draw import draw_text
from gamera.plugins.string_io import _from_raw_string

sys.stdout = file(os.devnull, 'w')
init_gamera()
sys.stdout = sys.__stdout__

if __name__ == '__main__':
	if not os.getenv('DISPLAY'):
		print >>sys.stderr, 'This script needs access to an X server'
		sys.exit(1)
	import wxversion
	wxversion.select(['2.8', '2.6', '2.5', '2.4'])
	image = draw_text().__doc_example1__()
	raw_string = image._to_raw_string()
	bz2_string = bz2.compress(raw_string)
	base64_string = base64.b64encode(bz2_string)
	for line in open(__file__, 'rt'):
		if line.startswith('DATA = '):
			sys.stdout.write('DATA = %d, %d, %r\n' % (image.dim.ncols, image.dim.nrows, base64_string))
		else:
			sys.stdout.write(line)
	sys.exit(0)

if not os.getenv('DISPLAY'):
	ncols, nrows, base64_string = DATA
	bz2_string = base64.decodestring(base64_string)
	raw_string = bz2.decompress(bz2_string)
	image = _from_raw_string(Point(0, 0), Dim(ncols, nrows), RGB, DENSE, raw_string)
	def static_draw_text_example(self, image=image):
		return image
	plugin.plugin_methods[RGB]['Draw']['draw_text'].doc_examples = [static_draw_text_example]

# vim:ts=4 sw=4 noet