Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de96c0e

Browse files
committed
added image blending
svn path=/trunk/matplotlib/; revision=354
1 parent 9211cb3 commit de96c0e

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

examples/pcolor_demo2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ def func3(x,y):
2020
cmap = ColormapJet(500)
2121

2222
ax = subplot(111)
23-
imshow(Z, cmap)
24-
ax.set_image_extent(-3, 3, -3, 3)
23+
im = imshow(Z, cmap)
24+
#im.set_interpolation('nearest')
25+
im.set_interpolation('bicubic')
26+
#im.set_interpolation('bilinear')
27+
#ax.set_image_extent(-3, 3, -3, 3)
2528
savefig('pcolor_demo2')
2629
show()
2730

src/_backend_agg.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,10 +887,26 @@ RendererAgg::draw_image(const Py::Tuple& args) {
887887

888888

889889
//todo: handle x and y
890-
agg::rect r(0, 0, image->colsOut, image->rowsOut);
891-
892-
rendererBase->copy_from(*image->rbufOut, &r, x, y);
893-
890+
//agg::rect r(0, 0, image->colsOut, image->rowsOut);
891+
//rendererBase->copy_from(*image->rbufOut, &r, x, y);
892+
size_t ind=0;
893+
size_t thisx, thisy;
894+
for (size_t j=0; j<image->rowsOut; j++) {
895+
for (size_t i=0; i<image->colsOut; i++) {
896+
thisx = i+x;
897+
thisy = j+y;
898+
if (thisx<0 || thisx>=width) continue;
899+
if (thisy<0 || thisy>=height) continue;
900+
pixfmt::color_type p;
901+
p.r = *(image->bufferOut+ind++);
902+
p.g = *(image->bufferOut+ind++);
903+
p.b = *(image->bufferOut+ind++);
904+
p.a = *(image->bufferOut+ind++);
905+
906+
pixFmt->blend_pixel(thisx, thisy, p, p.a);
907+
}
908+
}
909+
894910
return Py::Object();
895911

896912
}

0 commit comments

Comments
 (0)