From: John H. <jdh...@ac...> - 2004-03-09 16:10:57
|
I'm starting to think about adding image support and wanted to get some input about what it should include and how it should be designed. The ideas are still pretty nascent but here is where I was planning to start. Create an image extension built around agg (not backend_agg). This would be a free standing extension not tied to any of the backends with the responsibility of loading image data from a variety of sources into a pixel buffer, and resizing it to a desired pixel size (dependent on the axes window) with customizable interpolation. Inputs: what file formats should be supported? * I can do PNG rather easily since I already had to interface agg with png for save capabilities in backend_agg. * As for raw pixel data, should we try to support grayscale/luminance, rgb and rgba with the platform dependent byte ordering problems, or leave it to the user to load these into a numeric/numarray and init the image with that? Should we follow PILs lead here and just provide a fromstring method with format strings? * What raw types should be supported: 8 bit luminance, 16 bit luminance, 8 bit rgb, 8bit rgba, 16 bit rgb or rgba? Resizing: Generally the axes viewport and the image dimensions will not agree. Several possible solutions - perhaps all need to be supported: * a custom axes creation func that fits the image when you just want to view and draw onto single image (ie no multiple subplots). * resize to fit, resize constrained aspect ratio, plot in current axes and clip image outside axes viewlim * with resizing, what pixel interpolation schemes are critical? agg supports several: nearest neighbor, blinear, bicubic, spline, sinc. Backends: I am thinking about using the same approach as in ft2font. Have the image backend provide the load/resize/interpolate methods and fill a pixel buffer of appropriate size and letting the backends do whatever they want with it. Agg can blend the image with the drawing buffer, gtk can draw from an rgba buffer. Not sure about PS yet. paint and wx can use their respective APIs to copy the pixel buffer. Any other thoughts welcome... JDH |