From: SourceForge.net <no...@so...> - 2007-02-13 13:34:34
|
Patches item #1658954, was opened at 2007-02-13 13:34 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376094&aid=1658954&group_id=22470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Connelly (connelly) Assigned to: Nobody/Anonymous (nobody) Summary: Add tostring(), topil(), fromstring(), frompil() Initial Comment: I added tostring(), topil(), fromstring(), frompil() methods to the Bitmap class. Then I noticed that there is a from_string() method which already exists in the Bitmap class (I didn't see it because it didn't show up in the documentation). This patch is also diff'ed against the "post-templated" source and text files as opposed to the "pre-templated" source and text files (as I didn't realize that the C file was the output of a templating process). In general frustration, I am submitting this patch, so that either (a) You can tell me, "No this API is entirely wrong; here's how to change it" and I can resubmit; (b) You can use this code as a reference to develop your preferred API; or (c) You can remove the undocumented from_string() and just incorporate the patch as-is. Let me know what your preferences are. >From the patched documentation: * fromstring(str, mode, w, h, s, stride=-1) -> Bitmap Static method, creates a bitmap from a string of raw color data. Here mode should be one of 'RGB', 'RGBA', 'ARGB', 'BGR', 'BGRA', 'ABGR', w and h are the size of the raw image, and s is a string with the contents of the raw image. By default, it is assumed that rows are packed in without any extra padding; to change this, supply the stride argument, which specifies the size in bytes of each row. * frompil(img) -> Bitmap Static method, creates an alpy Bitmap from a Python Imaging Library (PIL) Image.Image instance. The conversion is done in RGB format, so any alpha channel will be lost. PIL is only required if this method is called; it is not required in general for alpy. * tostring(mode='RGB', stride=-1) -> str Converts a bitmap to a raw string of color data. Here mode should be one of 'RGB', 'RGBA', 'ARGB', 'BGR', 'BGRA', 'ABGR'. By default, it is assumed that rows are packed in without any extra padding; to change this, supply the stride argument, which specifies the size in bytes of each row. * topil() -> Image.Image instance Converts a bitmap to a Python Imaging Library (PIL) Image.Image instance. The conversion is done in RGB format, so any alpha channel will be lost. PIL is only required if this method is called; it is not required in general for alpy. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376094&aid=1658954&group_id=22470 |