mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #377 from irskep/doc-improvements
Document remaining Image* modules listed in PIL handbook
This commit is contained in:
commit
4ed588294f
|
@ -19,11 +19,9 @@
|
||||||
import array
|
import array
|
||||||
from PIL import Image, ImageColor
|
from PIL import Image, ImageColor
|
||||||
|
|
||||||
##
|
|
||||||
# Colour palette wrapper for palette mapped images.
|
|
||||||
|
|
||||||
class ImagePalette:
|
class ImagePalette:
|
||||||
"Colour palette for palette mapped images"
|
"Color palette for palette mapped images"
|
||||||
|
|
||||||
def __init__(self, mode = "RGB", palette = None):
|
def __init__(self, mode = "RGB", palette = None):
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
@ -35,14 +33,21 @@ class ImagePalette:
|
||||||
raise ValueError("wrong palette size")
|
raise ValueError("wrong palette size")
|
||||||
|
|
||||||
def getdata(self):
|
def getdata(self):
|
||||||
# experimental: get palette contents in format suitable
|
"""
|
||||||
# for the low-level im.putpalette primitive
|
Get palette contents in format suitable # for the low-level
|
||||||
|
``im.putpalette`` primitive.
|
||||||
|
|
||||||
|
.. warning:: This method is experimental.
|
||||||
|
"""
|
||||||
if self.rawmode:
|
if self.rawmode:
|
||||||
return self.rawmode, self.palette
|
return self.rawmode, self.palette
|
||||||
return self.mode + ";L", self.tobytes()
|
return self.mode + ";L", self.tobytes()
|
||||||
|
|
||||||
def tobytes(self):
|
def tobytes(self):
|
||||||
# experimental: convert palette to bytes
|
"""Convert palette to bytes.
|
||||||
|
|
||||||
|
.. warning:: This method is experimental.
|
||||||
|
"""
|
||||||
if self.rawmode:
|
if self.rawmode:
|
||||||
raise ValueError("palette contains raw palette data")
|
raise ValueError("palette contains raw palette data")
|
||||||
if isinstance(self.palette, bytes):
|
if isinstance(self.palette, bytes):
|
||||||
|
@ -57,7 +62,10 @@ class ImagePalette:
|
||||||
tostring = tobytes
|
tostring = tobytes
|
||||||
|
|
||||||
def getcolor(self, color):
|
def getcolor(self, color):
|
||||||
# experimental: given an rgb tuple, allocate palette entry
|
"""Given an rgb tuple, allocate palette entry.
|
||||||
|
|
||||||
|
.. warning:: This method is experimental.
|
||||||
|
"""
|
||||||
if self.rawmode:
|
if self.rawmode:
|
||||||
raise ValueError("palette contains raw palette data")
|
raise ValueError("palette contains raw palette data")
|
||||||
if isinstance(color, tuple):
|
if isinstance(color, tuple):
|
||||||
|
@ -80,7 +88,10 @@ class ImagePalette:
|
||||||
raise ValueError("unknown color specifier: %r" % color)
|
raise ValueError("unknown color specifier: %r" % color)
|
||||||
|
|
||||||
def save(self, fp):
|
def save(self, fp):
|
||||||
# (experimental) save palette to text file
|
"""Save palette to text file.
|
||||||
|
|
||||||
|
.. warning:: This method is experimental.
|
||||||
|
"""
|
||||||
if self.rawmode:
|
if self.rawmode:
|
||||||
raise ValueError("palette contains raw palette data")
|
raise ValueError("palette contains raw palette data")
|
||||||
if isinstance(fp, str):
|
if isinstance(fp, str):
|
||||||
|
@ -192,6 +203,3 @@ def load(filename):
|
||||||
raise IOError("cannot load palette")
|
raise IOError("cannot load palette")
|
||||||
|
|
||||||
return lut # data, rawmode
|
return lut # data, rawmode
|
||||||
|
|
||||||
|
|
||||||
# add some psuedocolour palettes as well
|
|
||||||
|
|
|
@ -16,17 +16,12 @@
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
##
|
|
||||||
# Path wrapper.
|
# the Python class below is overridden by the C implementation.
|
||||||
|
|
||||||
|
|
||||||
class Path:
|
class Path:
|
||||||
|
|
||||||
##
|
|
||||||
# Creates a path object.
|
|
||||||
#
|
|
||||||
# @param xy Sequence. The sequence can contain 2-tuples [(x, y), ...]
|
|
||||||
# or a flat list of numbers [x, y, ...].
|
|
||||||
|
|
||||||
def __init__(self, xy):
|
def __init__(self, xy):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,18 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
##
|
##
|
||||||
# This class implements an iterator object that can be used to loop
|
|
||||||
# over an image sequence.
|
|
||||||
|
|
||||||
class Iterator:
|
class Iterator:
|
||||||
|
"""
|
||||||
|
This class implements an iterator object that can be used to loop
|
||||||
|
over an image sequence.
|
||||||
|
|
||||||
##
|
You can use the ``[]`` operator to access elements by index. This operator
|
||||||
# Create an iterator.
|
will raise an :py:exc:`IndexError` if you try to access a nonexistent
|
||||||
#
|
frame.
|
||||||
# @param im An image object.
|
|
||||||
|
:param im: An image object.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, im):
|
def __init__(self, im):
|
||||||
if not hasattr(im, "seek"):
|
if not hasattr(im, "seek"):
|
||||||
|
|
|
@ -25,25 +25,8 @@ from PIL import Image
|
||||||
import operator, math
|
import operator, math
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
##
|
|
||||||
# The <b>ImageStat</b> module calculates global statistics for an
|
|
||||||
# image, or a region of an image.
|
|
||||||
##
|
|
||||||
|
|
||||||
##
|
|
||||||
# Calculate statistics for the given image. If a mask is included,
|
|
||||||
# only the regions covered by that mask are included in the
|
|
||||||
# statistics.
|
|
||||||
|
|
||||||
class Stat:
|
class Stat:
|
||||||
"Get image or feature statistics"
|
|
||||||
|
|
||||||
##
|
|
||||||
# Create a statistics object.
|
|
||||||
#
|
|
||||||
# @def __init__(image, mask=None)
|
|
||||||
# @param image A PIL image, or a precalculate histogram.
|
|
||||||
# @param mask An optional mask.
|
|
||||||
|
|
||||||
def __init__(self, image_or_list, mask = None):
|
def __init__(self, image_or_list, mask = None):
|
||||||
try:
|
try:
|
||||||
|
|
157
PIL/ImageTk.py
157
PIL/ImageTk.py
|
@ -34,13 +34,6 @@ except ImportError:
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
##
|
|
||||||
# The <b>ImageTk</b> module contains support to create and modify
|
|
||||||
# Tkinter <b>BitmapImage</b> and <b>PhotoImage</b> objects.
|
|
||||||
# <p>
|
|
||||||
# For examples, see the demo programs in the <i>Scripts</i>
|
|
||||||
# directory.
|
|
||||||
##
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Check for Tkinter interface hooks
|
# Check for Tkinter interface hooks
|
||||||
|
@ -61,28 +54,25 @@ def _pilbitmap_check():
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# PhotoImage
|
# PhotoImage
|
||||||
|
|
||||||
##
|
|
||||||
# Creates a Tkinter-compatible photo image. This can be used
|
|
||||||
# everywhere Tkinter expects an image object. If the image is an RGBA
|
|
||||||
# image, pixels having alpha 0 are treated as transparent.
|
|
||||||
|
|
||||||
class PhotoImage:
|
class PhotoImage:
|
||||||
|
"""
|
||||||
|
A Tkinter-compatible photo image. This can be used
|
||||||
|
everywhere Tkinter expects an image object. If the image is an RGBA
|
||||||
|
image, pixels having alpha 0 are treated as transparent.
|
||||||
|
|
||||||
##
|
The constructor takes either a PIL image, or a mode and a size.
|
||||||
# Create a photo image object. The constructor takes either
|
Alternatively, you can use the **file** or **data** options to initialize
|
||||||
# a PIL image, or a mode and a size. Alternatively, you can
|
the photo image object.
|
||||||
# use the <b>file</b> or <b>data</b> options to initialize
|
|
||||||
# the photo image object.
|
:param image: Either a PIL image, or a mode string. If a mode string is
|
||||||
# <p>
|
used, a size must also be given.
|
||||||
# @def __init__(image=None, size=None, **options)
|
:param size: If the first argument is a mode string, this defines the size
|
||||||
# @param image Either a PIL image, or a mode string. If a
|
of the image.
|
||||||
# mode string is used, a size must also be given.
|
:keyword file: A filename to load the image from (using
|
||||||
# @param size If the first argument is a mode string, this
|
``Image.open(file)``).
|
||||||
# defines the size of the image.
|
:keyword data: An 8-bit string containing image data (as loaded from an
|
||||||
# @keyparam file A filename to load the image from (using
|
image file).
|
||||||
# Image.open(file)).
|
"""
|
||||||
# @keyparam data An 8-bit string containing image data (as
|
|
||||||
# loaded from an image file).
|
|
||||||
|
|
||||||
def __init__(self, image=None, size=None, **kw):
|
def __init__(self, image=None, size=None, **kw):
|
||||||
|
|
||||||
|
@ -130,44 +120,48 @@ class PhotoImage:
|
||||||
except:
|
except:
|
||||||
pass # ignore internal errors
|
pass # ignore internal errors
|
||||||
|
|
||||||
##
|
|
||||||
# Get the Tkinter photo image identifier. This method is
|
|
||||||
# automatically called by Tkinter whenever a PhotoImage object is
|
|
||||||
# passed to a Tkinter method.
|
|
||||||
#
|
|
||||||
# @return A Tkinter photo image identifier (a string).
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
"""
|
||||||
|
Get the Tkinter photo image identifier. This method is automatically
|
||||||
|
called by Tkinter whenever a PhotoImage object is passed to a Tkinter
|
||||||
|
method.
|
||||||
|
|
||||||
|
:return: A Tkinter photo image identifier (a string).
|
||||||
|
"""
|
||||||
return str(self.__photo)
|
return str(self.__photo)
|
||||||
|
|
||||||
##
|
|
||||||
# Get the width of the image.
|
|
||||||
#
|
|
||||||
# @return The width, in pixels.
|
|
||||||
|
|
||||||
def width(self):
|
def width(self):
|
||||||
|
"""
|
||||||
|
Get the width of the image.
|
||||||
|
|
||||||
|
:return: The width, in pixels.
|
||||||
|
"""
|
||||||
return self.__size[0]
|
return self.__size[0]
|
||||||
|
|
||||||
##
|
|
||||||
# Get the height of the image.
|
|
||||||
#
|
|
||||||
# @return The height, in pixels.
|
|
||||||
|
|
||||||
def height(self):
|
def height(self):
|
||||||
|
"""
|
||||||
|
Get the height of the image.
|
||||||
|
|
||||||
|
:return: The height, in pixels.
|
||||||
|
"""
|
||||||
return self.__size[1]
|
return self.__size[1]
|
||||||
|
|
||||||
##
|
|
||||||
# Paste a PIL image into the photo image. Note that this can
|
|
||||||
# be very slow if the photo image is displayed.
|
|
||||||
#
|
|
||||||
# @param im A PIL image. The size must match the target region.
|
|
||||||
# If the mode does not match, the image is converted to the
|
|
||||||
# mode of the bitmap image.
|
|
||||||
# @param box A 4-tuple defining the left, upper, right, and
|
|
||||||
# lower pixel coordinate. If None is given instead of a
|
|
||||||
# tuple, all of the image is assumed.
|
|
||||||
|
|
||||||
def paste(self, im, box=None):
|
def paste(self, im, box=None):
|
||||||
|
"""
|
||||||
|
Paste a PIL image into the photo image. Note that this can
|
||||||
|
be very slow if the photo image is displayed.
|
||||||
|
|
||||||
|
:param im: A PIL image. The size must match the target region. If the
|
||||||
|
mode does not match, the image is converted to the mode of
|
||||||
|
the bitmap image.
|
||||||
|
:param box: A 4-tuple defining the left, upper, right, and lower pixel
|
||||||
|
coordinate. If None is given instead of a tuple, all of
|
||||||
|
the image is assumed.
|
||||||
|
"""
|
||||||
|
|
||||||
# convert to blittable
|
# convert to blittable
|
||||||
im.load()
|
im.load()
|
||||||
|
@ -197,24 +191,21 @@ class PhotoImage:
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# BitmapImage
|
# BitmapImage
|
||||||
|
|
||||||
##
|
|
||||||
# Create a Tkinter-compatible bitmap image. This can be used
|
|
||||||
# everywhere Tkinter expects an image object.
|
|
||||||
|
|
||||||
class BitmapImage:
|
class BitmapImage:
|
||||||
|
"""
|
||||||
|
|
||||||
##
|
A Tkinter-compatible bitmap image. This can be used everywhere Tkinter
|
||||||
# Create a Tkinter-compatible bitmap image.
|
expects an image object.
|
||||||
# <p>
|
|
||||||
# The given image must have mode "1". Pixels having value 0 are
|
The given image must have mode "1". Pixels having value 0 are treated as
|
||||||
# treated as transparent. Options, if any, are passed on to
|
transparent. Options, if any, are passed on to Tkinter. The most commonly
|
||||||
# Tkinter. The most commonly used option is <b>foreground</b>,
|
used option is **foreground**, which is used to specify the color for the
|
||||||
# which is used to specify the colour for the non-transparent
|
non-transparent parts. See the Tkinter documentation for information on
|
||||||
# parts. See the Tkinter documentation for information on how to
|
how to specify colours.
|
||||||
# specify colours.
|
|
||||||
#
|
:param image: A PIL image.
|
||||||
# @def __init__(image=None, **options)
|
"""
|
||||||
# @param image A PIL image.
|
|
||||||
|
|
||||||
def __init__(self, image=None, **kw):
|
def __init__(self, image=None, **kw):
|
||||||
|
|
||||||
|
@ -249,36 +240,38 @@ class BitmapImage:
|
||||||
except:
|
except:
|
||||||
pass # ignore internal errors
|
pass # ignore internal errors
|
||||||
|
|
||||||
##
|
|
||||||
# Get the width of the image.
|
|
||||||
#
|
|
||||||
# @return The width, in pixels.
|
|
||||||
|
|
||||||
def width(self):
|
def width(self):
|
||||||
|
"""
|
||||||
|
Get the width of the image.
|
||||||
|
|
||||||
|
:return: The width, in pixels.
|
||||||
|
"""
|
||||||
return self.__size[0]
|
return self.__size[0]
|
||||||
|
|
||||||
##
|
|
||||||
# Get the height of the image.
|
|
||||||
#
|
|
||||||
# @return The height, in pixels.
|
|
||||||
|
|
||||||
def height(self):
|
def height(self):
|
||||||
|
"""
|
||||||
|
Get the height of the image.
|
||||||
|
|
||||||
|
:return: The height, in pixels.
|
||||||
|
"""
|
||||||
return self.__size[1]
|
return self.__size[1]
|
||||||
|
|
||||||
##
|
|
||||||
# Get the Tkinter bitmap image identifier. This method is
|
|
||||||
# automatically called by Tkinter whenever a BitmapImage object
|
|
||||||
# is passed to a Tkinter method.
|
|
||||||
#
|
|
||||||
# @return A Tkinter bitmap image identifier (a string).
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
"""
|
||||||
|
Get the Tkinter bitmap image identifier. This method is automatically
|
||||||
|
called by Tkinter whenever a BitmapImage object is passed to a Tkinter
|
||||||
|
method.
|
||||||
|
|
||||||
|
:return: A Tkinter bitmap image identifier (a string).
|
||||||
|
"""
|
||||||
return str(self.__photo)
|
return str(self.__photo)
|
||||||
|
|
||||||
##
|
|
||||||
# Copies the contents of a PhotoImage to a PIL image memory.
|
|
||||||
|
|
||||||
def getimage(photo):
|
def getimage(photo):
|
||||||
|
"""Copies the contents of a PhotoImage to a PIL image memory."""
|
||||||
photo.tk.call("PyImagingPhotoGet", photo)
|
photo.tk.call("PyImagingPhotoGet", photo)
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
139
PIL/ImageWin.py
139
PIL/ImageWin.py
|
@ -20,44 +20,49 @@
|
||||||
import warnings
|
import warnings
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
##
|
|
||||||
# The <b>ImageWin</b> module contains support to create and display
|
|
||||||
# images under Windows 95/98, NT, 2000 and later.
|
|
||||||
|
|
||||||
class HDC:
|
class HDC:
|
||||||
|
"""
|
||||||
|
Wraps a HDC integer. The resulting object can be passed to the
|
||||||
|
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
|
||||||
|
methods.
|
||||||
|
"""
|
||||||
def __init__(self, dc):
|
def __init__(self, dc):
|
||||||
self.dc = dc
|
self.dc = dc
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return self.dc
|
return self.dc
|
||||||
|
|
||||||
class HWND:
|
class HWND:
|
||||||
|
"""
|
||||||
|
Wraps a HWND integer. The resulting object can be passed to the
|
||||||
|
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
|
||||||
|
methods, instead of a DC.
|
||||||
|
"""
|
||||||
def __init__(self, wnd):
|
def __init__(self, wnd):
|
||||||
self.wnd = wnd
|
self.wnd = wnd
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return self.wnd
|
return self.wnd
|
||||||
|
|
||||||
##
|
|
||||||
# Create a Windows bitmap with the given mode and size. The mode can
|
|
||||||
# be one of "1", "L", "P", or "RGB".
|
|
||||||
#
|
|
||||||
# If the display requires a palette, this constructor creates a
|
|
||||||
# suitable palette and associates it with the image. For an "L" image,
|
|
||||||
# 128 greylevels are allocated. For an "RGB" image, a 6x6x6 colour
|
|
||||||
# cube is used, together with 20 greylevels.
|
|
||||||
#
|
|
||||||
# To make sure that palettes work properly under Windows, you must
|
|
||||||
# call the <b>palette</b> method upon certain events from Windows.
|
|
||||||
|
|
||||||
class Dib:
|
class Dib:
|
||||||
|
"""
|
||||||
|
A Windows bitmap with the given mode and size. The mode can be one of "1",
|
||||||
|
"L", "P", or "RGB".
|
||||||
|
|
||||||
##
|
If the display requires a palette, this constructor creates a suitable
|
||||||
# Create Windows bitmap.
|
palette and associates it with the image. For an "L" image, 128 greylevels
|
||||||
#
|
are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
|
||||||
# @param image Either a PIL image, or a mode string. If a
|
with 20 greylevels.
|
||||||
# mode string is used, a size must also be given. The
|
|
||||||
# mode can be one of "1", "L", "P", or "RGB".
|
To make sure that palettes work properly under Windows, you must call the
|
||||||
# @param size If the first argument is a mode string, this
|
**palette** method upon certain events from Windows.
|
||||||
# defines the size of the image.
|
|
||||||
|
:param image: Either a PIL image, or a mode string. If a mode string is
|
||||||
|
used, a size must also be given. The mode can be one of "1",
|
||||||
|
"L", "P", or "RGB".
|
||||||
|
:param size: If the first argument is a mode string, this
|
||||||
|
defines the size of the image.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, image, size=None):
|
def __init__(self, image, size=None):
|
||||||
if hasattr(image, "mode") and hasattr(image, "size"):
|
if hasattr(image, "mode") and hasattr(image, "size"):
|
||||||
|
@ -74,15 +79,15 @@ class Dib:
|
||||||
if image:
|
if image:
|
||||||
self.paste(image)
|
self.paste(image)
|
||||||
|
|
||||||
##
|
|
||||||
# Copy the bitmap contents to a device context.
|
|
||||||
#
|
|
||||||
# @param handle Device context (HDC), cast to a Python integer,
|
|
||||||
# or a HDC or HWND instance. In PythonWin, you can use the
|
|
||||||
# <b>GetHandleAttrib</b> method of the <b>CDC</b> class to get
|
|
||||||
# a suitable handle.
|
|
||||||
|
|
||||||
def expose(self, handle):
|
def expose(self, handle):
|
||||||
|
"""
|
||||||
|
Copy the bitmap contents to a device context.
|
||||||
|
|
||||||
|
:param handle: Device context (HDC), cast to a Python integer, or a HDC
|
||||||
|
or HWND instance. In PythonWin, you can use the
|
||||||
|
:py:meth:`CDC.GetHandleAttrib` to get a suitable handle.
|
||||||
|
"""
|
||||||
if isinstance(handle, HWND):
|
if isinstance(handle, HWND):
|
||||||
dc = self.image.getdc(handle)
|
dc = self.image.getdc(handle)
|
||||||
try:
|
try:
|
||||||
|
@ -94,6 +99,15 @@ class Dib:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def draw(self, handle, dst, src=None):
|
def draw(self, handle, dst, src=None):
|
||||||
|
"""
|
||||||
|
Same as expose, but allows you to specify where to draw the image, and
|
||||||
|
what part of it to draw.
|
||||||
|
|
||||||
|
The destination and source areas are given as 4-tuple rectangles. If
|
||||||
|
the source is omitted, the entire image is copied. If the source and
|
||||||
|
the destination have different sizes, the image is resized as
|
||||||
|
necessary.
|
||||||
|
"""
|
||||||
if not src:
|
if not src:
|
||||||
src = (0,0) + self.size
|
src = (0,0) + self.size
|
||||||
if isinstance(handle, HWND):
|
if isinstance(handle, HWND):
|
||||||
|
@ -106,22 +120,22 @@ class Dib:
|
||||||
result = self.image.draw(handle, dst, src)
|
result = self.image.draw(handle, dst, src)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
##
|
|
||||||
# Installs the palette associated with the image in the
|
|
||||||
# given device context.
|
|
||||||
# <p>
|
|
||||||
# This method should be called upon <b>QUERYNEWPALETTE</b>
|
|
||||||
# and <b>PALETTECHANGED</b> events from Windows. If this
|
|
||||||
# method returns a non-zero value, one or more display
|
|
||||||
# palette entries were changed, and the image should be
|
|
||||||
# redrawn.
|
|
||||||
#
|
|
||||||
# @param handle Device context (HDC), cast to a Python integer,
|
|
||||||
# or an HDC or HWND instance.
|
|
||||||
# @return A true value if one or more entries were changed
|
|
||||||
# (this indicates that the image should be redrawn).
|
|
||||||
|
|
||||||
def query_palette(self, handle):
|
def query_palette(self, handle):
|
||||||
|
"""
|
||||||
|
Installs the palette associated with the image in the given device
|
||||||
|
context.
|
||||||
|
|
||||||
|
This method should be called upon **QUERYNEWPALETTE** and
|
||||||
|
**PALETTECHANGED** events from Windows. If this method returns a
|
||||||
|
non-zero value, one or more display palette entries were changed, and
|
||||||
|
the image should be redrawn.
|
||||||
|
|
||||||
|
:param handle: Device context (HDC), cast to a Python integer, or an
|
||||||
|
HDC or HWND instance.
|
||||||
|
:return: A true value if one or more entries were changed (this
|
||||||
|
indicates that the image should be redrawn).
|
||||||
|
"""
|
||||||
if isinstance(handle, HWND):
|
if isinstance(handle, HWND):
|
||||||
handle = self.image.getdc(handle)
|
handle = self.image.getdc(handle)
|
||||||
try:
|
try:
|
||||||
|
@ -132,17 +146,18 @@ class Dib:
|
||||||
result = self.image.query_palette(handle)
|
result = self.image.query_palette(handle)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
##
|
|
||||||
# Paste a PIL image into the bitmap image.
|
|
||||||
#
|
|
||||||
# @param im A PIL image. The size must match the target region.
|
|
||||||
# If the mode does not match, the image is converted to the
|
|
||||||
# mode of the bitmap image.
|
|
||||||
# @param box A 4-tuple defining the left, upper, right, and
|
|
||||||
# lower pixel coordinate. If None is given instead of a
|
|
||||||
# tuple, all of the image is assumed.
|
|
||||||
|
|
||||||
def paste(self, im, box=None):
|
def paste(self, im, box=None):
|
||||||
|
"""
|
||||||
|
Paste a PIL image into the bitmap image.
|
||||||
|
|
||||||
|
:param im: A PIL image. The size must match the target region.
|
||||||
|
If the mode does not match, the image is converted to the
|
||||||
|
mode of the bitmap image.
|
||||||
|
:param box: A 4-tuple defining the left, upper, right, and
|
||||||
|
lower pixel coordinate. If None is given instead of a
|
||||||
|
tuple, all of the image is assumed.
|
||||||
|
"""
|
||||||
im.load()
|
im.load()
|
||||||
if self.mode != im.mode:
|
if self.mode != im.mode:
|
||||||
im = im.convert(self.mode)
|
im = im.convert(self.mode)
|
||||||
|
@ -151,21 +166,23 @@ class Dib:
|
||||||
else:
|
else:
|
||||||
self.image.paste(im.im)
|
self.image.paste(im.im)
|
||||||
|
|
||||||
##
|
|
||||||
# Load display memory contents from byte data.
|
|
||||||
#
|
|
||||||
# @param buffer A buffer containing display data (usually
|
|
||||||
# data returned from <b>tobytes</b>)
|
|
||||||
|
|
||||||
def frombytes(self, buffer):
|
def frombytes(self, buffer):
|
||||||
|
"""
|
||||||
|
Load display memory contents from byte data.
|
||||||
|
|
||||||
|
:param buffer: A buffer containing display data (usually
|
||||||
|
data returned from <b>tobytes</b>)
|
||||||
|
"""
|
||||||
return self.image.frombytes(buffer)
|
return self.image.frombytes(buffer)
|
||||||
|
|
||||||
##
|
|
||||||
# Copy display memory contents to bytes object.
|
|
||||||
#
|
|
||||||
# @return A bytes object containing display data.
|
|
||||||
|
|
||||||
def tobytes(self):
|
def tobytes(self):
|
||||||
|
"""
|
||||||
|
Copy display memory contents to bytes object.
|
||||||
|
|
||||||
|
:return: A bytes object containing display data.
|
||||||
|
"""
|
||||||
return self.image.tobytes()
|
return self.image.tobytes()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -23,6 +23,10 @@ from PIL import EpsImagePlugin
|
||||||
# Simple Postscript graphics interface.
|
# Simple Postscript graphics interface.
|
||||||
|
|
||||||
class PSDraw:
|
class PSDraw:
|
||||||
|
"""
|
||||||
|
Sets up printing to the given file. If **file** is omitted,
|
||||||
|
:py:attr:`sys.stdout` is assumed.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, fp=None):
|
def __init__(self, fp=None):
|
||||||
if not fp:
|
if not fp:
|
||||||
|
@ -31,7 +35,7 @@ class PSDraw:
|
||||||
self.fp = fp
|
self.fp = fp
|
||||||
|
|
||||||
def begin_document(self, id = None):
|
def begin_document(self, id = None):
|
||||||
"Write Postscript DSC header"
|
"""Set up printing of a document. (Write Postscript DSC header.)"""
|
||||||
# FIXME: incomplete
|
# FIXME: incomplete
|
||||||
self.fp.write("%!PS-Adobe-3.0\n"
|
self.fp.write("%!PS-Adobe-3.0\n"
|
||||||
"save\n"
|
"save\n"
|
||||||
|
@ -45,7 +49,7 @@ class PSDraw:
|
||||||
self.isofont = {}
|
self.isofont = {}
|
||||||
|
|
||||||
def end_document(self):
|
def end_document(self):
|
||||||
"Write Postscript DSC footer"
|
"""Ends printing. (Write Postscript DSC footer.)"""
|
||||||
self.fp.write("%%EndDocument\n"
|
self.fp.write("%%EndDocument\n"
|
||||||
"restore showpage\n"
|
"restore showpage\n"
|
||||||
"%%End\n")
|
"%%End\n")
|
||||||
|
@ -53,6 +57,12 @@ class PSDraw:
|
||||||
self.fp.flush()
|
self.fp.flush()
|
||||||
|
|
||||||
def setfont(self, font, size):
|
def setfont(self, font, size):
|
||||||
|
"""
|
||||||
|
Selects which font to use.
|
||||||
|
|
||||||
|
:param font: A Postscript font name
|
||||||
|
:param size: Size in points.
|
||||||
|
"""
|
||||||
if font not in self.isofont:
|
if font not in self.isofont:
|
||||||
# reencode font
|
# reencode font
|
||||||
self.fp.write("/PSDraw-%s ISOLatin1Encoding /%s E\n" %\
|
self.fp.write("/PSDraw-%s ISOLatin1Encoding /%s E\n" %\
|
||||||
|
@ -62,23 +72,49 @@ class PSDraw:
|
||||||
self.fp.write("/F0 %d /PSDraw-%s F\n" % (size, font))
|
self.fp.write("/F0 %d /PSDraw-%s F\n" % (size, font))
|
||||||
|
|
||||||
def setink(self, ink):
|
def setink(self, ink):
|
||||||
|
"""
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
This has been in the PIL API for ages but was never implemented.
|
||||||
|
"""
|
||||||
print("*** NOT YET IMPLEMENTED ***")
|
print("*** NOT YET IMPLEMENTED ***")
|
||||||
|
|
||||||
def line(self, xy0, xy1):
|
def line(self, xy0, xy1):
|
||||||
|
"""
|
||||||
|
Draws a line between the two points. Coordinates are given in
|
||||||
|
Postscript point coordinates (72 points per inch, (0, 0) is the lower
|
||||||
|
left corner of the page).
|
||||||
|
"""
|
||||||
xy = xy0 + xy1
|
xy = xy0 + xy1
|
||||||
self.fp.write("%d %d %d %d Vl\n" % xy)
|
self.fp.write("%d %d %d %d Vl\n" % xy)
|
||||||
|
|
||||||
def rectangle(self, box):
|
def rectangle(self, box):
|
||||||
|
"""
|
||||||
|
Draws a rectangle.
|
||||||
|
|
||||||
|
:param box: A 4-tuple of integers whose order and function is currently
|
||||||
|
undocumented.
|
||||||
|
|
||||||
|
Hint: the tuple is passed into this format string:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
%d %d M %d %d 0 Vr\n
|
||||||
|
"""
|
||||||
self.fp.write("%d %d M %d %d 0 Vr\n" % box)
|
self.fp.write("%d %d M %d %d 0 Vr\n" % box)
|
||||||
|
|
||||||
def text(self, xy, text):
|
def text(self, xy, text):
|
||||||
|
"""
|
||||||
|
Draws text at the given position. You must use
|
||||||
|
:py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
|
||||||
|
"""
|
||||||
text = "\\(".join(text.split("("))
|
text = "\\(".join(text.split("("))
|
||||||
text = "\\)".join(text.split(")"))
|
text = "\\)".join(text.split(")"))
|
||||||
xy = xy + (text,)
|
xy = xy + (text,)
|
||||||
self.fp.write("%d %d M (%s) S\n" % xy)
|
self.fp.write("%d %d M (%s) S\n" % xy)
|
||||||
|
|
||||||
def image(self, box, im, dpi = None):
|
def image(self, box, im, dpi = None):
|
||||||
"Write an PIL image"
|
"""Draw a PIL image, centered in the given box."""
|
||||||
# default resolution depends on mode
|
# default resolution depends on mode
|
||||||
if not dpi:
|
if not dpi:
|
||||||
if im.mode == "1":
|
if im.mode == "1":
|
||||||
|
|
64
docs/PIL.rst
64
docs/PIL.rst
|
@ -86,38 +86,6 @@ can be found here.
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
:mod:`ImagePalette` Module
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImagePalette
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImagePath` Module
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImagePath
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImageQt` Module
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImageQt
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImageSequence` Module
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImageSequence
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImageShow` Module
|
:mod:`ImageShow` Module
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
@ -126,22 +94,6 @@ can be found here.
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
:mod:`ImageStat` Module
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImageStat
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImageTk` Module
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImageTk
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`ImageTransform` Module
|
:mod:`ImageTransform` Module
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
@ -150,14 +102,6 @@ can be found here.
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
:mod:`ImageWin` Module
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.ImageWin
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`JpegPresets` Module
|
:mod:`JpegPresets` Module
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
@ -174,14 +118,6 @@ can be found here.
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
:mod:`PSDraw` Module
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
.. automodule:: PIL.PSDraw
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
:mod:`PaletteFile` Module
|
:mod:`PaletteFile` Module
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
.. py:module:: PIL.ImageChops
|
.. py:module:: PIL.ImageChops
|
||||||
.. py:currentmodule:: PIL.ImageChops
|
.. py:currentmodule:: PIL.ImageChops
|
||||||
|
|
||||||
:py:mod:`ImageChops` Module
|
:py:mod:`ImageChops` ("Channel Operations") Module
|
||||||
===========================
|
==================================================
|
||||||
|
|
||||||
The :py:mod:`ImageChops` module contains a number of arithmetical image
|
The :py:mod:`ImageChops` module contains a number of arithmetical image
|
||||||
operations, called channel operations (“chops”). These can be used for various
|
operations, called channel operations (“chops”). These can be used for various
|
||||||
|
|
21
docs/reference/ImagePalette.rst
Normal file
21
docs/reference/ImagePalette.rst
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
.. py:module:: PIL.ImagePalette
|
||||||
|
.. py:currentmodule:: PIL.ImagePalette
|
||||||
|
|
||||||
|
:py:mod:`ImagePalette` Module
|
||||||
|
=============================
|
||||||
|
|
||||||
|
The :py:mod:`ImagePalette` module contains a class of the same name to
|
||||||
|
represent the color palette of palette mapped images.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
This module was never well-documented. It hasn't changed since 2001,
|
||||||
|
though, so it's probably safe for you to read the source code and puzzle
|
||||||
|
out the internals if you need to.
|
||||||
|
|
||||||
|
The :py:class:`~PIL.ImagePalette.ImagePalette` class has several methods,
|
||||||
|
but they are all marked as "experimental." Read that as you will. The
|
||||||
|
``[source]`` link is there for a reason.
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImagePalette.ImagePalette
|
||||||
|
:members:
|
68
docs/reference/ImagePath.rst
Normal file
68
docs/reference/ImagePath.rst
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
.. py:module:: PIL.ImagePath
|
||||||
|
.. py:currentmodule:: PIL.ImagePath
|
||||||
|
|
||||||
|
:py:mod:`ImagePath` Module
|
||||||
|
==========================
|
||||||
|
|
||||||
|
The :py:mod:`ImagePath` module is used to store and manipulate 2-dimensional
|
||||||
|
vector data. Path objects can be passed to the methods on the
|
||||||
|
:py:mod:`~PIL.ImageDraw` module.
|
||||||
|
|
||||||
|
.. py:class:: PIL.ImagePath.Path
|
||||||
|
|
||||||
|
A path object. The coordinate list can be any sequence object containing
|
||||||
|
either 2-tuples [(x, y), …] or numeric values [x, y, …].
|
||||||
|
|
||||||
|
You can also create a path object from another path object.
|
||||||
|
|
||||||
|
In 1.1.6 and later, you can also pass in any object that implements
|
||||||
|
Python’s buffer API. The buffer should provide read access, and contain C
|
||||||
|
floats in machine byte order.
|
||||||
|
|
||||||
|
The path object implements most parts of the Python sequence interface, and
|
||||||
|
behaves like a list of (x, y) pairs. You can use len(), item access, and
|
||||||
|
slicing as usual. However, the current version does not support slice
|
||||||
|
assignment, or item and slice deletion.
|
||||||
|
|
||||||
|
:param xy: A sequence. The sequence can contain 2-tuples [(x, y), ...]
|
||||||
|
or a flat list of numbers [x, y, ...].
|
||||||
|
|
||||||
|
.. py:method:: PIL.ImagePath.Path.compact(distance=2)
|
||||||
|
|
||||||
|
Compacts the path, by removing points that are close to each other. This
|
||||||
|
method modifies the path in place, and returns the number of points left in
|
||||||
|
the path.
|
||||||
|
|
||||||
|
**distance** is measured as `Manhattan distance`_ and defaults to two
|
||||||
|
pixels.
|
||||||
|
|
||||||
|
.. _Manhattan distance: http://en.wikipedia.org/wiki/Manhattan_distance
|
||||||
|
|
||||||
|
.. py:method:: PIL.ImagePath.Path.getbbox()
|
||||||
|
|
||||||
|
Gets the bounding box of the path.
|
||||||
|
|
||||||
|
:return: ``(x0, y0, x1, y1)``
|
||||||
|
|
||||||
|
.. py:method:: PIL.ImagePath.Path.map(function)
|
||||||
|
|
||||||
|
Maps the path through a function.
|
||||||
|
|
||||||
|
.. py:method:: PIL.ImagePath.Path.tolist(flat=0)
|
||||||
|
|
||||||
|
Converts the path to a Python list [(x, y), …].
|
||||||
|
|
||||||
|
:param flat: By default, this function returns a list of 2-tuples
|
||||||
|
[(x, y), ...]. If this argument is :keyword:`True`, it
|
||||||
|
returns a flat list [x, y, ...] instead.
|
||||||
|
:return: A list of coordinates. See **flat**.
|
||||||
|
|
||||||
|
.. py:method:: PIL.ImagePath.Path.transform(matrix)
|
||||||
|
|
||||||
|
Transforms the path in place, using an affine transform. The matrix is a
|
||||||
|
6-tuple (a, b, c, d, e, f), and each point is mapped as follows:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
xOut = xIn * a + yIn * b + c
|
||||||
|
yOut = xIn * d + yIn * e + f
|
20
docs/reference/ImageQt.rst
Normal file
20
docs/reference/ImageQt.rst
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
.. py:module:: PIL.ImageQt
|
||||||
|
.. py:currentmodule:: PIL.ImageQt
|
||||||
|
|
||||||
|
:py:mod:`ImageQt` Module
|
||||||
|
========================
|
||||||
|
|
||||||
|
The :py:mod:`ImageQt` module contains support for creating PyQt4 QImage objects
|
||||||
|
from PIL images.
|
||||||
|
|
||||||
|
.. versionadded:: 1.1.6
|
||||||
|
|
||||||
|
.. py:class:: ImageQt.ImageQt(image)
|
||||||
|
|
||||||
|
Creates an :py:class:`~PIL.ImageQt.ImageQt` object from a PIL
|
||||||
|
:py:class:`~PIL.Image.Image` object. This class is a subclass of
|
||||||
|
QtGui.QImage, which means that you can pass the resulting objects directly
|
||||||
|
to PyQt4 API functions and methods.
|
||||||
|
|
||||||
|
This operation is currently supported for mode 1, L, P, RGB, and RGBA
|
||||||
|
images. To handle other modes, you need to convert the image first.
|
27
docs/reference/ImageSequence.rst
Normal file
27
docs/reference/ImageSequence.rst
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
.. py:module:: PIL.ImageSequence
|
||||||
|
.. py:currentmodule:: PIL.ImageSequence
|
||||||
|
|
||||||
|
:py:mod:`ImageSequence` Module
|
||||||
|
==============================
|
||||||
|
|
||||||
|
The :py:mod:`ImageSequence` module contains a wrapper class that lets you
|
||||||
|
iterate over the frames of an image sequence.
|
||||||
|
|
||||||
|
Extracting frames from an animation
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image, ImageSequence
|
||||||
|
|
||||||
|
im = Image.open("animation.fli")
|
||||||
|
|
||||||
|
index = 1
|
||||||
|
for frame in ImageSequence.Iterator(im):
|
||||||
|
frame.save("frame%d.png" % index)
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
The :py:class:`~PIL.ImageSequence.Iterator` class
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImageSequence.Iterator
|
53
docs/reference/ImageStat.rst
Normal file
53
docs/reference/ImageStat.rst
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
.. py:module:: PIL.ImageStat
|
||||||
|
.. py:currentmodule:: PIL.ImageStat
|
||||||
|
|
||||||
|
:py:mod:`ImageStat` Module
|
||||||
|
==========================
|
||||||
|
|
||||||
|
The :py:mod:`ImageStat` module calculates global statistics for an image, or
|
||||||
|
for a region of an image.
|
||||||
|
|
||||||
|
.. py:class:: PIL.ImageStat.Stat(image_or_list, mask=None)
|
||||||
|
|
||||||
|
Calculate statistics for the given image. If a mask is included,
|
||||||
|
only the regions covered by that mask are included in the
|
||||||
|
statistics. You can also pass in a previously calculated histogram.
|
||||||
|
|
||||||
|
:param image: A PIL image, or a precalculated histogram.
|
||||||
|
:param mask: An optional mask.
|
||||||
|
|
||||||
|
.. py:attribute:: extrema
|
||||||
|
|
||||||
|
Min/max values for each band in the image.
|
||||||
|
|
||||||
|
.. py:attribute:: count
|
||||||
|
|
||||||
|
Total number of pixels.
|
||||||
|
|
||||||
|
.. py:attribute:: sum
|
||||||
|
|
||||||
|
Sum of all pixels.
|
||||||
|
|
||||||
|
.. py:attribute:: sum2
|
||||||
|
|
||||||
|
Squared sum of all pixels.
|
||||||
|
|
||||||
|
.. py:attribute:: pixel
|
||||||
|
|
||||||
|
Average pixel level.
|
||||||
|
|
||||||
|
.. py:attribute:: median
|
||||||
|
|
||||||
|
Median pixel level.
|
||||||
|
|
||||||
|
.. py:attribute:: rms
|
||||||
|
|
||||||
|
RMS (root-mean-square).
|
||||||
|
|
||||||
|
.. py:attribute:: var
|
||||||
|
|
||||||
|
Variance.
|
||||||
|
|
||||||
|
.. py:attribute:: stddev
|
||||||
|
|
||||||
|
Standard deviation.
|
16
docs/reference/ImageTk.rst
Normal file
16
docs/reference/ImageTk.rst
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
.. py:module:: PIL.ImageTk
|
||||||
|
.. py:currentmodule:: PIL.ImageTk
|
||||||
|
|
||||||
|
:py:mod:`ImageTk` Module
|
||||||
|
========================
|
||||||
|
|
||||||
|
The :py:mod:`ImageTk` module contains support to create and modify Tkinter
|
||||||
|
BitmapImage and PhotoImage objects from PIL images.
|
||||||
|
|
||||||
|
For examples, see the demo programs in the Scripts directory.
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImageTk.BitmapImage
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImageTk.PhotoImage
|
||||||
|
:members:
|
29
docs/reference/ImageWin.rst
Normal file
29
docs/reference/ImageWin.rst
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
.. py:module:: PIL.ImageWin
|
||||||
|
.. py:currentmodule:: PIL.ImageWin
|
||||||
|
|
||||||
|
:py:mod:`ImageWin` Module (Windows-only)
|
||||||
|
========================================
|
||||||
|
|
||||||
|
The :py:mod:`ImageWin` module contains support to create and display images on
|
||||||
|
Windows.
|
||||||
|
|
||||||
|
ImageWin can be used with PythonWin and other user interface toolkits that
|
||||||
|
provide access to Windows device contexts or window handles. For example,
|
||||||
|
Tkinter makes the window handle available via the winfo_id method:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import ImageWin
|
||||||
|
|
||||||
|
dib = ImageWin.Dib(...)
|
||||||
|
|
||||||
|
hwnd = ImageWin.HWND(widget.winfo_id())
|
||||||
|
dib.draw(hwnd, xy)
|
||||||
|
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImageWin.Dib
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
.. autoclass:: PIL.ImageWin.HDC
|
||||||
|
.. autoclass:: PIL.ImageWin.HWND
|
11
docs/reference/PSDraw.rst
Normal file
11
docs/reference/PSDraw.rst
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.. py:module:: PIL.PSDraw
|
||||||
|
.. py:currentmodule:: PIL.PSDraw
|
||||||
|
|
||||||
|
:py:mod:`PSDraw` Module
|
||||||
|
=======================
|
||||||
|
|
||||||
|
The :py:mod:`PSDraw` module provides simple print support for Postscript
|
||||||
|
printers. You can print text, graphics and images through this module.
|
||||||
|
|
||||||
|
.. autoclass:: PIL.PSDraw.PSDraw
|
||||||
|
:members:
|
|
@ -15,4 +15,12 @@ Reference
|
||||||
ImageGrab
|
ImageGrab
|
||||||
ImageMath
|
ImageMath
|
||||||
ImageOps
|
ImageOps
|
||||||
|
ImagePalette
|
||||||
|
ImagePath
|
||||||
|
ImageQt
|
||||||
|
ImageSequence
|
||||||
|
ImageStat
|
||||||
|
ImageTk
|
||||||
|
ImageWin
|
||||||
|
PSDraw
|
||||||
../PIL
|
../PIL
|
||||||
|
|
Loading…
Reference in New Issue
Block a user