Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DcxImagePlugin.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #
  2. # The Python Imaging Library.
  3. # $Id$
  4. #
  5. # DCX file handling
  6. #
  7. # DCX is a container file format defined by Intel, commonly used
  8. # for fax applications. Each DCX file consists of a directory
  9. # (a list of file offsets) followed by a set of (usually 1-bit)
  10. # PCX files.
  11. #
  12. # History:
  13. # 1995-09-09 fl Created
  14. # 1996-03-20 fl Properly derived from PcxImageFile.
  15. # 1998-07-15 fl Renamed offset attribute to avoid name clash
  16. # 2002-07-30 fl Fixed file handling
  17. #
  18. # Copyright (c) 1997-98 by Secret Labs AB.
  19. # Copyright (c) 1995-96 by Fredrik Lundh.
  20. #
  21. # See the README file for information on usage and redistribution.
  22. #
  23. from . import Image
  24. from ._binary import i32le as i32
  25. from .PcxImagePlugin import PcxImageFile
  26. MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
  27. def _accept(prefix):
  28. return len(prefix) >= 4 and i32(prefix) == MAGIC
  29. ##
  30. # Image plugin for the Intel DCX format.
  31. class DcxImageFile(PcxImageFile):
  32. format = "DCX"
  33. format_description = "Intel DCX"
  34. _close_exclusive_fp_after_loading = False
  35. def _open(self):
  36. # Header
  37. s = self.fp.read(4)
  38. if not _accept(s):
  39. msg = "not a DCX file"
  40. raise SyntaxError(msg)
  41. # Component directory
  42. self._offset = []
  43. for i in range(1024):
  44. offset = i32(self.fp.read(4))
  45. if not offset:
  46. break
  47. self._offset.append(offset)
  48. self._fp = self.fp
  49. self.frame = None
  50. self.n_frames = len(self._offset)
  51. self.is_animated = self.n_frames > 1
  52. self.seek(0)
  53. def seek(self, frame):
  54. if not self._seek_check(frame):
  55. return
  56. self.frame = frame
  57. self.fp = self._fp
  58. self.fp.seek(self._offset[frame])
  59. PcxImageFile._open(self)
  60. def tell(self):
  61. return self.frame
  62. Image.register_open(DcxImageFile.format, DcxImageFile, _accept)
  63. Image.register_extension(DcxImageFile.format, ".dcx")