~ubuntu-branches/debian/stretch/electrum/stretch

« back to all changes in this revision

Viewing changes to gui/kivy/tools/.buildozer/android/platform/python-for-android/dist/kivy/python-install/lib/python2.7/site-packages/PIL/GdImageFile.py

  • Committer: Package Import Robot
  • Author(s): Tristan Seligmann
  • Date: 2016-04-04 03:02:39 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20160404030239-0szgkio8yryjv7c9
Tags: 2.6.3-1
* New upstream release.
  - Drop backported install-wizard-connect.patch.
* Add Suggests: python-zbar and update the installation hint to suggest
  apt-get instead of pip (closes: #819517).
* Bump Standards-Version to 3.9.7 (no changes).
* Update Vcs-* links.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# The Python Imaging Library.
 
3
# $Id$
 
4
#
 
5
# GD file handling
 
6
#
 
7
# History:
 
8
# 1996-04-12 fl   Created
 
9
#
 
10
# Copyright (c) 1997 by Secret Labs AB.
 
11
# Copyright (c) 1996 by Fredrik Lundh.
 
12
#
 
13
# See the README file for information on usage and redistribution.
 
14
#
 
15
 
 
16
 
 
17
# NOTE: This format cannot be automatically recognized, so the
 
18
# class is not registered for use with Image.open().  To open a
 
19
# gd file, use the GdImageFile.open() function instead.
 
20
 
 
21
# THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE.  This
 
22
# implementation is provided for convenience and demonstrational
 
23
# purposes only.
 
24
 
 
25
 
 
26
__version__ = "0.1"
 
27
 
 
28
import ImageFile, ImagePalette
 
29
 
 
30
def i16(c):
 
31
    return ord(c[1]) + (ord(c[0])<<8)
 
32
 
 
33
##
 
34
# Image plugin for the GD uncompressed format.  Note that this format
 
35
# is not supported by the standard <b>Image.open</b> function.  To use
 
36
# this plugin, you have to import the <b>GdImageFile</b> module and
 
37
# use the <b>GdImageFile.open</b> function.
 
38
 
 
39
class GdImageFile(ImageFile.ImageFile):
 
40
 
 
41
    format = "GD"
 
42
    format_description = "GD uncompressed images"
 
43
 
 
44
    def _open(self):
 
45
 
 
46
        # Header
 
47
        s = self.fp.read(775)
 
48
 
 
49
        self.mode = "L" # FIXME: "P"
 
50
        self.size = i16(s[0:2]), i16(s[2:4])
 
51
 
 
52
        # transparency index
 
53
        tindex = i16(s[5:7])
 
54
        if tindex < 256:
 
55
            self.info["transparent"] = tindex
 
56
 
 
57
        self.palette = ImagePalette.raw("RGB", s[7:])
 
58
 
 
59
        self.tile = [("raw", (0,0)+self.size, 775, ("L", 0, -1))]
 
60
 
 
61
##
 
62
# Load texture from a GD image file.
 
63
#
 
64
# @param filename GD file name, or an opened file handle.
 
65
# @param mode Optional mode.  In this version, if the mode argument
 
66
#     is given, it must be "r".
 
67
# @return An image instance.
 
68
# @exception IOError If the image could not be read.
 
69
 
 
70
def open(fp, mode = "r"):
 
71
 
 
72
    if mode != "r":
 
73
        raise ValueError("bad mode")
 
74
 
 
75
    if type(fp) == type(""):
 
76
        import __builtin__
 
77
        filename = fp
 
78
        fp = __builtin__.open(fp, "rb")
 
79
    else:
 
80
        filename = ""
 
81
 
 
82
    try:
 
83
        return GdImageFile(fp, filename)
 
84
    except SyntaxError:
 
85
        raise IOError("cannot identify this image file")