当前位置: 首页>>代码示例>>Python>>正文


Python Image.getmodebase方法代码示例

本文整理汇总了Python中lib.pil.Image.getmodebase方法的典型用法代码示例。如果您正苦于以下问题:Python Image.getmodebase方法的具体用法?Python Image.getmodebase怎么用?Python Image.getmodebase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.pil.Image的用法示例。


在下文中一共展示了Image.getmodebase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getcolor

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import getmodebase [as 别名]
def getcolor(color, mode):
	# same as getrgb, but converts the result to the given mode
	color = getrgb(color)
	if mode == "RGB":
		return color
	if mode == "RGBA":
		r, g, b = color
		return r, g, b, 255
	if Image.getmodebase(mode) == "L":
		r, g, b = color
		return (r*299 + g*587 + b*114)/1000
	return color
开发者ID:TheArchives,项目名称:blockBox,代码行数:14,代码来源:ImageColor.py

示例2: __init__

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import getmodebase [as 别名]
	def __init__(self, image, size=None):
		if hasattr(image, "mode") and hasattr(image, "size"):
			mode = image.mode
			size = image.size
		else:
			mode = image
			image = None
		if mode not in ["1", "L", "P", "RGB"]:
			mode = Image.getmodebase(mode)
		self.image = Image.core.display(mode, size)
		self.mode = mode
		self.size = size
		if image:
			self.paste(image)
开发者ID:TheArchives,项目名称:blockBox,代码行数:16,代码来源:ImageWin.py

示例3: show

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import getmodebase [as 别名]
	def show(self, image, **options):

		# save temporary image to disk
		if image.mode[:4] == "I;16":
			# @PIL88 @PIL101
			# "I;16" isn't an 'official' mode, but we still want to
			# provide a simple way to show 16-bit images.
			base = "L"
			# FIXME: auto-contrast if max() > 255?
		else:
			base = Image.getmodebase(image.mode)
		if base != image.mode and image.mode != "1":
			image = image.convert(base)

		self.show_image(image, **options)
开发者ID:TheArchives,项目名称:blockBox,代码行数:17,代码来源:ImageShow.py

示例4: _save

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import getmodebase [as 别名]
def _save(im, fp, filename):

	if _imaging_gif:
		# call external driver
		try:
			_imaging_gif.save(im, fp, filename)
			return
		except IOError:
			pass # write uncompressed file

	try:
		rawmode = RAWMODE[im.mode]
		imOut = im
	except KeyError:
		# convert on the fly (EXPERIMENTAL -- I'm not sure PIL
		# should automatically convert images on save...)
		if Image.getmodebase(im.mode) == "RGB":
			imOut = im.convert("P")
			rawmode = "P"
		else:
			imOut = im.convert("L")
			rawmode = "L"

	# header
	for s in getheader(imOut, im.encoderinfo):
		fp.write(s)

	flags = 0

	try:
		interlace = im.encoderinfo["interlace"]
	except KeyError:
		interlace = 1

	# workaround for @PIL153
	if min(im.size) < 16:
		interlace = 0

	if interlace:
		flags = flags | 64

	try:
		transparency = im.encoderinfo["transparency"]
	except KeyError:
		pass
	else:
		# transparency extension block
		fp.write("!" +
				 chr(249) +			 # extension intro
				 chr(4) +			   # length
				 chr(1) +			   # transparency info present
				 o16(0) +			   # duration
				 chr(int(transparency)) # transparency index
				 + chr(0))

	# local image header
	fp.write("," +
			 o16(0) + o16(0) +		  # bounding box
			 o16(im.size[0]) +		  # size
			 o16(im.size[1]) +
			 chr(flags) +			   # flags
			 chr(8))					# bits

	imOut.encoderconfig = (8, interlace)

	ImageFile._save(imOut, fp, [("gif", (0,0)+im.size, 0, rawmode)])

	fp.write("\0") # end of image data

	fp.write(";") # end of file

	try:
		fp.flush()
	except: pass
开发者ID:TheArchives,项目名称:blockBox,代码行数:76,代码来源:GifImagePlugin.py


注:本文中的lib.pil.Image.getmodebase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。