📄 module-rgbimg.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>14.8 rgbimg -- Read and write ``SGI RGB'' files</title>
<META NAME="description" CONTENT="14.8 rgbimg -- Read and write ``SGI RGB'' files">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html">
<LINK REL="previous" href="module-colorsys.html" tppabs="http://www.python.org/doc/current/lib/module-colorsys.html">
<LINK REL="up" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">
<LINK REL="next" href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-colorsys.html" tppabs="http://www.python.org/doc/current/lib/module-colorsys.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-colorsys.html" tppabs="http://www.python.org/doc/current/lib/module-colorsys.html">14.7 colorsys </A>
<b class="navlabel">Up:</b> <a class="sectref" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">14. Multimedia Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html">14.9 imghdr </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0016800000000000000000">
14.8 <tt class="module">rgbimg</tt> --
Read and write ``SGI RGB'' files</A>
</H1>
<P>
<P>
The <tt class="module">rgbimg</tt> module allows Python programs to access SGI imglib image
files (also known as <span class="file">.rgb</span> files). The module is far from
complete, but is provided anyway since the functionality that there is
enough in some cases. Currently, colormap files are not supported.
<P>
The module defines the following variables and functions:
<P>
<dl><dt><b><a name='l2h-2927'><tt class='exception'>error</tt></a></b>
<dd>
This exception is raised on all errors, such as unsupported file type, etc.
</dl>
<P>
<dl><dt><b><a name='l2h-2928'><tt class='function'>sizeofimage</tt></a></b> (<var>file</var>)
<dd>
This function returns a tuple <code>(<var>x</var>, <var>y</var>)</code> where
<var>x</var> and <var>y</var> are the size of the image in pixels.
Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels
are currently supported.
</dl>
<P>
<dl><dt><b><a name='l2h-2929'><tt class='function'>longimagedata</tt></a></b> (<var>file</var>)
<dd>
This function reads and decodes the image on the specified file, and
returns it as a Python string. The string has 4 byte RGBA pixels.
The bottom left pixel is the first in
the string. This format is suitable to pass to <tt class="function">gl.lrectwrite()</tt>,
for instance.
</dl>
<P>
<dl><dt><b><a name='l2h-2930'><tt class='function'>longstoimage</tt></a></b> (<var>data, x, y, z, file</var>)
<dd>
This function writes the RGBA data in <var>data</var> to image
file <var>file</var>. <var>x</var> and <var>y</var> give the size of the image.
<var>z</var> is 1 if the saved image should be 1 byte greyscale, 3 if the
saved image should be 3 byte RGB data, or 4 if the saved images should
be 4 byte RGBA data. The input data always contains 4 bytes per pixel.
These are the formats returned by <tt class="function">gl.lrectread()</tt>.
</dl>
<P>
<dl><dt><b><a name='l2h-2931'><tt class='function'>ttob</tt></a></b> (<var>flag</var>)
<dd>
This function sets a global flag which defines whether the scan lines
of the image are read or written from bottom to top (flag is zero,
compatible with SGI GL) or from top to bottom(flag is one,
compatible with X). The default is zero.
</dl>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-colorsys.html" tppabs="http://www.python.org/doc/current/lib/module-colorsys.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-colorsys.html" tppabs="http://www.python.org/doc/current/lib/module-colorsys.html">14.7 colorsys </A>
<b class="navlabel">Up:</b> <a class="sectref" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">14. Multimedia Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-imghdr.html" tppabs="http://www.python.org/doc/current/lib/module-imghdr.html">14.9 imghdr </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -