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.

PcdImagePlugin.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #
  2. # The Python Imaging Library.
  3. # $Id$
  4. #
  5. # PCD file handling
  6. #
  7. # History:
  8. # 96-05-10 fl Created
  9. # 96-05-27 fl Added draft mode (128x192, 256x384)
  10. #
  11. # Copyright (c) Secret Labs AB 1997.
  12. # Copyright (c) Fredrik Lundh 1996.
  13. #
  14. # See the README file for information on usage and redistribution.
  15. #
  16. from . import Image, ImageFile
  17. ##
  18. # Image plugin for PhotoCD images. This plugin only reads the 768x512
  19. # image from the file; higher resolutions are encoded in a proprietary
  20. # encoding.
  21. class PcdImageFile(ImageFile.ImageFile):
  22. format = "PCD"
  23. format_description = "Kodak PhotoCD"
  24. def _open(self):
  25. # rough
  26. self.fp.seek(2048)
  27. s = self.fp.read(2048)
  28. if s[:4] != b"PCD_":
  29. msg = "not a PCD file"
  30. raise SyntaxError(msg)
  31. orientation = s[1538] & 3
  32. self.tile_post_rotate = None
  33. if orientation == 1:
  34. self.tile_post_rotate = 90
  35. elif orientation == 3:
  36. self.tile_post_rotate = -90
  37. self.mode = "RGB"
  38. self._size = 768, 512 # FIXME: not correct for rotated images!
  39. self.tile = [("pcd", (0, 0) + self.size, 96 * 2048, None)]
  40. def load_end(self):
  41. if self.tile_post_rotate:
  42. # Handle rotated PCDs
  43. self.im = self.im.rotate(self.tile_post_rotate)
  44. self._size = self.im.size
  45. #
  46. # registry
  47. Image.register_open(PcdImageFile.format, PcdImageFile)
  48. Image.register_extension(PcdImageFile.format, ".pcd")