I agree. PIL gives you much more power regarding image manipulations.
You could also take a look at a couple of functions like these:
def ConvertWXToPIL(img):
"""
Converts a :class:`Image` into a PIL image.
:param `img`: an instance of :class:`Image`.
:note: Requires PIL (Python Imaging Library), which can be downloaded from
http://www.pythonware.com/products/pil/
"""
width = img.GetWidth()
height = img.GetHeight()
out = Image.fromstring("RGBA", (width, height), img.GetData())
return out
def ConvertPILToWX(pil, alpha=True):
"""
Converts a PIL image into a :class:`Image`.
:param `pil`: a PIL image;
:param `alpha`: ``True`` if the image contains alpha transparency, ``False``
otherwise.
:note: Requires PIL (Python Imaging Library), which can be downloaded from
http://www.pythonware.com/products/pil/
"""
if alpha:
image = apply(wx.EmptyImage, pil.size)
image.SetData(pil.convert("RGB").tostring())
image.SetAlphaData(pil.convert("RGBA").tostring()[3::4])
else:
image = wx.EmptyImage(pil.size[0], pil.size[1])
new_image = pil.convert('RGB')
data = new_image.tostring()
image.SetData(data)
return image
Which might help you in the conversion to/from PIL.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
# ------------------------------------------------------------- #
def ask_mailing_list_support(email):
if mention_platform_and_version() and include_sample_app():
send_message(email)
else:
install_malware()
erase_hard_drives()
# ------------------------------------------------------------- #
···
On 29 August 2012 20:05, Toni Ruža wrote:
On Wed, 29 Aug 2012 19:13:23 +0200, Paul <poalman@gmail.com> wrote:
Is there a way to scale down images and not get this effect? I think it
may
need some different kind of sampling or antialiasing.
AFAIK, wx doesn't give you that level of control over the scaling method
used.
One solution would be to convert your wx bitmap to a PIL image, scale using
PIL and convert back to wx bitmap.
Take a look at the "resize" function
http://www.pythonware.com/library/pil/handbook/image.htm