[wxPython-dev] img2py script
Robin Dunn
robin at alldunn.com
Wed Nov 14 17:07:49 PST 2007
Anthony Tuininga wrote:
> Hi everyone. I thought I would ask this question about the img2py
> script since it seems to me this would be an improvement -- but
> perhaps I'm missing something. :-)
>
> The current script generates fairly ugly code -- which bugs me even
> though it doesn't matter since its generated. :-) The generated code
> is also quite lengthy thanks to binary data being encoded with four
> characters in most cases. Finally the generated code is fairly
> intrusive in terms of namespace since three methods are generated for
> each image. My suggestion handles all of these, I believe, but I'd
> appreciate feedback.
>
> A class could be created (wx.PyImage?) that would encompass the
> routines for getting the data, bitmap and image (see attached) which
> would clear up the namespace intrusiveness. Then using base64 encoding
> dramatically reduces the size of the generated script (see attached
> for an example). The names, case, style, etc. are all subject to
> change if the concept is accepted, of course.
>
> Comments?
In general I like it, although I think I would prefer if the embedded
images were all instances of the same class, instead of individual
classes derived from the same base and using classmethods.
Using base64 is also a good idea. IIRC that module wasn't available, or
at least not part of the standard build, when img2py was first
conceived. Have you looked at how much space savings that using zlib is
buying? At the beginning when the embedded format was XPM then
compressing gained us quite a bit in size reduction, but since the
format has been switched to PNG which is already at least RLE compressed
it may be possible that the gain is not worth the decompression time.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-dev
mailing list