Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Pillow (PIL Fork) 12.0.0 documentation
Light LogoDark Logo
Pillow (PIL Fork) 12.0.0 documentation
Back to top

Source code for PIL.ImageMode

## The Python Imaging Library.# $Id$## standard mode descriptors## History:# 2006-03-20 fl   Added## Copyright (c) 2006 by Secret Labs AB.# Copyright (c) 2006 by Fredrik Lundh.## See the README file for information on usage and redistribution.#from__future__importannotationsimportsysfromfunctoolsimportlru_cachefromtypingimportNamedTuple
[docs]classModeDescriptor(NamedTuple):"""Wrapper for mode strings."""mode:strbands:tuple[str,...]basemode:strbasetype:strtypestr:strdef__str__(self)->str:returnself.mode
[docs]@lru_cachedefgetmode(mode:str)->ModeDescriptor:"""Gets a mode descriptor for the given mode."""endian="<"ifsys.byteorder=="little"else">"modes={# core modes# Bits need to be extended to bytes"1":("L","L",("1",),"|b1"),"L":("L","L",("L",),"|u1"),"I":("L","I",("I",),f"{endian}i4"),"F":("L","F",("F",),f"{endian}f4"),"P":("P","L",("P",),"|u1"),"RGB":("RGB","L",("R","G","B"),"|u1"),"RGBX":("RGB","L",("R","G","B","X"),"|u1"),"RGBA":("RGB","L",("R","G","B","A"),"|u1"),"CMYK":("RGB","L",("C","M","Y","K"),"|u1"),"YCbCr":("RGB","L",("Y","Cb","Cr"),"|u1"),# UNDONE - unsigned |u1i1i1"LAB":("RGB","L",("L","A","B"),"|u1"),"HSV":("RGB","L",("H","S","V"),"|u1"),# extra experimental modes"RGBa":("RGB","L",("R","G","B","a"),"|u1"),"LA":("L","L",("L","A"),"|u1"),"La":("L","L",("L","a"),"|u1"),"PA":("RGB","L",("P","A"),"|u1"),}ifmodeinmodes:base_mode,base_type,bands,type_str=modes[mode]returnModeDescriptor(mode,bands,base_mode,base_type,type_str)mapping_modes={# I;16 == I;16L, and I;32 == I;32L"I;16":"<u2","I;16S":"<i2","I;16L":"<u2","I;16LS":"<i2","I;16B":">u2","I;16BS":">i2","I;16N":f"{endian}u2","I;16NS":f"{endian}i2","I;32":"<u4","I;32B":">u4","I;32L":"<u4","I;32S":"<i4","I;32BS":">i4","I;32LS":"<i4",}type_str=mapping_modes[mode]returnModeDescriptor(mode,("I",),"L","L",type_str)
Copyright © 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors.
Made withSphinx and@pradyunsg'sFuro

[8]
ページ先頭

©2009-2025 Movatter.jp