예제 #1
0
 def __init__(self, image, filename='', cache=1):
     # convert image to mode 'L' or 'RGB' if necessary
     if image.mode not in ('RGB', 'RGBA', 'L'):
         if image.mode == '1':
             mode = 'L'
         else:
             mode = 'RGB'
         image = image.convert(mode)
     else:
         image.load()
     self.image = image
     ExternalData.__init__(self, filename, cache)
예제 #2
0
파일: image.py 프로젝트: shumik/skencil-c
    def __init__(self, image, filename = '', cache = 1):
	# convert image to mode 'L' or 'RGB' if necessary
	if image.mode not in ('RGB', 'RGBA', 'L'):
	    if image.mode == '1':
		mode = 'L'
	    else:
		mode = 'RGB'
	    image = image.convert(mode)
	else:
	    image.load()
	self.image = image
	ExternalData.__init__(self, filename, cache)
예제 #3
0
 def __init__(self, image, filename="", cache=1):
     # convert image to mode 'L' or 'RGB' if necessary
     if image.mode not in ("RGB", "RGBA", "L"):
         if image.mode == "1":
             mode = "L"
         else:
             mode = "RGB"
         image = image.convert(mode)
     else:
         image.load()
     self.image = image
     ExternalData.__init__(self, filename, cache)
예제 #4
0
    def __init__(self, filename):
        self.info = info = dscparser.parse_eps_file(filename)
        self.filename = filename
        if info.BoundingBox:
            llx, lly, urx, ury = info.BoundingBox
            self.width = Point(urx - llx, 0)
            self.height = Point(0, ury - lly)
            self.start = (llx, lly)
            self.size = (urx - llx, ury - lly)
            self.image = None
            try:
                self.image = render_preview(filename, llx, lly, urx - llx,
                                            ury - lly)
            except IOError:
                pass
        else:
            raise TypeError, '%s has no BoundingBox' % filename

        ExternalData.__init__(self, filename)
예제 #5
0
	def __init__(self, filename):
		self.info = info = dscparser.parse_eps_file(filename)
		self.filename = filename
		if info.BoundingBox:
			llx, lly, urx, ury = info.BoundingBox
			self.width = Point(urx - llx, 0)
			self.height = Point(0, ury - lly)
			self.start = (llx, lly)
			self.size = (urx - llx, ury - lly)
			self.image = None
			try:
				self.image = render_preview(filename, llx, lly,
											urx - llx, ury - lly)
			except IOError:
				pass
		else:
			raise TypeError, '%s has no BoundingBox' % filename

		ExternalData.__init__(self, filename)
예제 #6
0
파일: image.py 프로젝트: kindlychung/sk1
	def __init__(self, image, filename='', cache=1):
		self.orig_image = image.copy()

		if image.mode == '1':
			self.image_mode = BW_IMAGE
		elif image.mode == 'L':
			self.image_mode = GRAYSCALE_IMAGE
		elif image.mode == 'RGB':
			self.image_mode = RGB_IMAGE
		elif image.mode == 'RGBA':
			self.image_mode = RGBA_IMAGE
		elif image.mode == 'CMYK':
			self.image_mode = CMYK_IMAGE
			colormanager.add_to_image_pool(self)
			self.cached = 1
		else:
			self.image_mode = UNSUPPORTED

		if image.mode not in ('RGB', 'RGBA'):
			image.load()
			if image.mode == 'CMYK':
				if app.config.preferences.use_cms_for_bitmap:
					self.image = colormanager.ImageCMYKtoRGB(image)
				else:
					self.image = image.convert('RGB')
			else:
				self.image = image.convert('RGB')
		else:
			image.load()
			self.image = image

		if self.image_mode == UNSUPPORTED:
			self.orig_image = self.image.copy()
			self.image_mode = RGB_IMAGE

		ExternalData.__init__(self, filename, cache)
예제 #7
0
    def __init__(self, image, filename='', cache=1):
        self.orig_image = image.copy()

        if image.mode == '1':
            self.image_mode = BW_IMAGE
        elif image.mode == 'L':
            self.image_mode = GRAYSCALE_IMAGE
        elif image.mode == 'RGB':
            self.image_mode = RGB_IMAGE
        elif image.mode == 'RGBA':
            self.image_mode = RGBA_IMAGE
        elif image.mode == 'CMYK':
            self.image_mode = CMYK_IMAGE
            colormanager.add_to_image_pool(self)
            self.cached = 1
        else:
            self.image_mode = UNSUPPORTED

        if image.mode not in ('RGB', 'RGBA'):
            image.load()
            if image.mode == 'CMYK':
                if app.config.preferences.use_cms_for_bitmap:
                    self.image = colormanager.ImageCMYKtoRGB(image)
                else:
                    self.image = image.convert('RGB')
            else:
                self.image = image.convert('RGB')
        else:
            image.load()
            self.image = image

        if self.image_mode == UNSUPPORTED:
            self.orig_image = self.image.copy()
            self.image_mode = RGB_IMAGE

        ExternalData.__init__(self, filename, cache)