8000 added basic image support to agg · matplotlib/matplotlib@d0f4115 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0f4115

Browse files
committed
added basic image support to agg
svn path=/trunk/matplotlib/; revision=177
1 parent 5ead3e0 commit d0f4115

File tree

13 files changed

+655
-50
lines changed

13 files changed

+655
-50
lines changed

MANIFEST

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ GOALS
66
INSTALL
77
INTERACTIVE
88
KNOWN_BUGS
9-
LICENSE
10-
LICENSE_PAINT
119
MANIFEST
1210
MANIFEST.in
1311
Makefile
@@ -384,6 +382,9 @@ images/stock_zoom-in.ppm
384382
images/stock_zoom-in.xpm
385383
images/stock_zoom-out.ppm
386384
images/stock_zoom-out.xpm
385+
license/LICENSE
386+
license/LICENSE_PAINT
387+
license/LICENSE_PIL
387388
matplotlib/__init__.py
388389
matplotlib/_matlab_helpers.py
389390
matplotlib/afm.py

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include LICENSE LICENSE_PAINT API_CHANGES CHANGELOG KNOWN_BUGS GOALS INSTALL
1+
include API_CHANGES CHANGELOG KNOWN_BUGS GOALS INSTALL
22
include INTERACTIVE TODO
33
include Makefile MANIFEST.in MANIFEST
44
include .matplotlibrc
@@ -8,6 +8,7 @@ include images/*
88
include test/*.py
99
include test/README
1010
recursive-include fonts *.ttf *.afm *.TXT
11+
recursive-include license LICENSE*
1112
recursive-include examples README *.py *.glade
1213
prune examples/_tmp_*
1314
recursive-include src *.cpp *.c *.h

TODO

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,8 @@
264264

265265
-- DONE 2004-03-02 - why are aliased lines of varying widths on agg?
266266

267-
-- update dynamic_demo_wx
267+
-- DONE update dynamic_demo_wx
268+
269+
-- DONE add figure legend
270+
271+
-- fix newlines across backends

examples/data/ct.raw

512 KB
Binary file not shown.

examples/image_demo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from matplotlib.image import ASPECT_FREE, ASPECT_PRESERVE
2+
from matplotlib.image import NEAREST, BILINEAR, BICUBIC, SPLINE16
3+
from matplotlib.matlab import *
4+
5+
6+
s = file('data/ct.raw', 'rb').read()
7+
A = fromstring(s, typecode=UInt16).astype(Float)
8+
A *= 1.0/max(A)
9+
A.shape = 512, 512
10+
11+
im = imshow(A)
12+
#im.set_interpolation(BICUBIC)
13+
#im.set_interpolation(NEAREST)
14+
im.set_interpolation(BILINEAR)
15+
#im.set_preserve_aspect(ASPECT_PRESERVE)
16+
17+
18+
19+
show()
20+

examples/mathtext_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
tex = r'$\cal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\rm{sin}(2 \pi f x_i)$'
2020
#tex = r'$\alpha\beta\gamma$'
2121
text(1, 2.6, tex, fontsize=20)
22-
title(r'$\Delta_i \rm{versus} \Delta_{i+1}$', fontsize=15)
22+
title(r'$\Delta_i\rm{ versus }\Delta_{i+1}$', fontsize=15)
2323
#savefig('mathtext_demo', dpi=100)
2424
show()

examples/object_picker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def set_color(button):
151151
marker = line.get_marker()
152152
if marker is None: marker = 'None'
153153
styles = [marker]
154-
for key in lineMarkers.keys():
154+
for key in keys:
155155
if key == marker: continue
156156
styles.append(key)
157157

examples/simple_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
figure(1)
44
t = arange(0.0, 1.0, 0.01)
55
s = sin(2*2*pi*t)
6-
plot(t, s, linewidth=1.0)
6+
plot(t, s, antialiased=False)
77

88
xlabel('time (s)')
99
ylabel('voltage (mV)')

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Requires freetype2, and libz
88
BUILD_FT2FONT = 1
99

10+
# build the image support module - requires agg
11+
BUILD_IMAGE = 1
12+
1013
# Build the fonttools and TTFQuery packages, required by the Paint,
1114
# Agg and GD backends.
1215
BUILD_FONTTOOLS = 1
@@ -37,7 +40,7 @@
3740
import sys,os
3841
import glob
3942
from setupext import build_gtkgd, build_agg, build_fonttools, build_gtkagg, \
40-
build_tkagg, build_ft2font
43+
build_tkagg, build_ft2font, build_image
4144
import distutils.sysconfig
4245

4346
data = []
@@ -77,6 +80,10 @@
7780
BUILD_FONTTOOLS = 1
7881
build_ft2font(ext_modules, packages)
7982

83+
if BUILD_IMAGE:
84+
BUILD_IMAGE = 1
85+
build_image(ext_modules, packages)
86+
8087
if BUILD_FONTTOOLS:
8188
build_fonttools(ext_modules, packages)
8289
# we need to manually install FontTools.pth since we can't use
@@ -92,7 +99,7 @@
9299

93100

94101
setup(name="matplotlib",
95-
version= '0.51.1',
102+
version= '0.52b',
96103
description = "Matlab style python plotting package",
97104
author = "John D. Hunter",
98105
author_email="jdhunter@ace.bsd.uchicago.edu",

setupext.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
If you are sufficiently masochistic that you want to build this
2424
yourself, contact me and I'll send you win32_static as a zip file.
2525
26-
python setup.py build --compiler=mingw32 bdist_wininst --install-script postinstall.py > build23.out
26+
> python setup.py build --compiler=mingw32 bdist_wininst --install-script postinstall.py > build23.out
2727
2828
"""
2929

@@ -49,10 +49,11 @@
4949

5050
BUILT_AGG = False
5151
BUILT_FONTTOOLS = False
52-
BUILT_GTKGD = False
52+
BUILT_FT2FONT = False
5353
BUILT_GTKAGG = False
54+
BUILT_GTKGD = False
55+
BUILT_IMAGE = False
5456
BUILT_TKAGG = False
55-
BUILT_FT2FONT = False
5657

5758
def getoutput(s):
5859
'get the output of a system command'
@@ -67,8 +68,6 @@ def add_agg_flags(module):
6768
# before adding the freetype flags since -z comes later
6869
module.libraries.append('png')
6970

70-
add_ft2font_flags(module)
71-
7271
module.include_dirs.extend(['src','agg2/include'])
7372

7473
# put these later for correct link order
@@ -181,7 +180,8 @@ def build_gtkagg(ext_modules, packages):
181180

182181
# add agg flags before pygtk because agg only supports freetype1
183182
# and pygtk includes freetype2. This is a bit fragile.
184-
183+
184+
add_ft2font_flags(module)
185185
add_agg_flags(module)
186186
add_pygtk_flags(module)
187187

@@ -201,7 +201,9 @@ def build_tkagg(ext_modules, packages):
201201
# add agg flags before pygtk because agg only supports freetype1
202202
# and pygtk includes freetype2. This is a bit fragile.
203203

204+
204205
add_tk_flags(module) # do this first
206+
add_ft2font_flags(module)
205207
add_agg_flags(module)
206208

207209

@@ -221,9 +223,26 @@ def build_agg(ext_modules, packages):
221223
deps
222224
,
223225
)
226+
add_ft2font_flags(module)
224227
add_agg_flags(module)
225228
ext_modules.append(module)
226229
BUILT_AGG = True
230+
231+
def build_image(ext_modules, packages):
232+
global BUILT_IMAGE
233+
if BUILT_IMAGE: return # only build it if you you haven't already
234+
235+
deps = ['src/image.cpp']
236+
deps.extend(glob.glob('agg2/src/*.cpp'))
237+
238+
module = Extension(
239+
'matplotlib.image',
240+
deps
241+
,
242+
)
243+
add_agg_flags(module)
244+
ext_modules.append(module)
245+
BUILT_IMAGE = True
227246

228247
def build_fonttools(ext_modules, packages):
229248

0 commit comments

Comments
 (0)
0