<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xreadbfman'>
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XReadBF.man,v 1.4 2003/04/28 22:17:56 herrb Exp $ -->

<!-- .na -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<refmeta>
<refentrytitle>XReadBitmapFile</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XReadBitmapFile</refname>
<refname>XReadBitmapFileData</refname>
<refname>XWriteBitmapFile</refname>
<refname>XCreatePixmapFromBitmapData</refname>
<refname>XCreateBitmapFromData</refname>
<refpurpose>manipulate bitmaps</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>int XReadBitmapFile(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Drawable <emphasis remap='I'>d</emphasis>&hairsp;, char
*<emphasis remap='I'>filename</emphasis>&hairsp;, unsigned int *<emphasis remap='I'>width_return</emphasis>, unsigned int
*<emphasis remap='I'>height_return</emphasis>&hairsp;, Pixmap *<emphasis remap='I'>bitmap_return</emphasis>&hairsp;, int
*<emphasis remap='I'>x_hot_return</emphasis>, int *<emphasis remap='I'>y_hot_return</emphasis>&hairsp;);</para> 

<para>int XReadBitmapFileData(&hairsp;char *<emphasis remap='I'>filename</emphasis>&hairsp;, unsigned int
*<emphasis remap='I'>width_return</emphasis>, unsigned int *<emphasis remap='I'>height_return</emphasis>&hairsp;, unsigned char
*<emphasis remap='I'>data_return</emphasis>&hairsp;, int *<emphasis remap='I'>x_hot_return</emphasis>, int *<emphasis remap='I'>y_hot_return</emphasis>&hairsp;);</para> 

<para>int XWriteBitmapFile(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, char *<emphasis remap='I'>filename</emphasis>&hairsp;,
Pixmap <emphasis remap='I'>bitmap</emphasis>&hairsp;, unsigned int <emphasis remap='I'>width</emphasis>, unsigned int <emphasis remap='I'>height</emphasis>&hairsp;,
int <emphasis remap='I'>x_hot</emphasis>, int <emphasis remap='I'>y_hot</emphasis>&hairsp;);</para> 

<para>Pixmap XCreatePixmapFromBitmapData&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Drawable
<emphasis remap='I'>d</emphasis>&hairsp;, char *<emphasis remap='I'>data</emphasis>&hairsp;, unsigned int <emphasis remap='I'>width</emphasis>, unsigned int
<emphasis remap='I'>height</emphasis>&hairsp;, unsigned long <emphasis remap='I'>fg</emphasis>, unsigned int <emphasis remap='I'>bg</emphasis>&hairsp;, unsigned int
<emphasis remap='I'>depth</emphasis>&hairsp;);</para> 

<para>Pixmap XCreateBitmapFromData(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Drawable <emphasis remap='I'>d</emphasis>&hairsp;,
char *<emphasis remap='I'>data</emphasis>&hairsp;, unsigned int <emphasis remap='I'>width</emphasis>, unsigned int <emphasis remap='I'>height</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>bitmap</emphasis></term>
  <listitem>
<para>Specifies the bitmap.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>bitmap_return</emphasis></term>
  <listitem>
<para>Returns the bitmap that is created.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>d</emphasis></term>
  <listitem>
<para>Specifies the drawable&nbsp;that indicates the screen.</para> 
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>data</emphasis></term>
  <listitem>
<para>Specifies the data in bitmap format.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>data</emphasis></term>
  <listitem>
<para>Specifies the location of the bitmap data.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>data_return</emphasis></term>
  <listitem>
<para>Returns the bitmap data.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>depth</emphasis></term>
  <listitem>
<para>Specifies the depth of the pixmap.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>display</emphasis></term>
  <listitem>
<para>Specifies the connection to the X server.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>fg</emphasis></term>
<!-- .br -->
<!-- .ns -->
  <term><emphasis remap='I'>bg</emphasis></term>
  <listitem>
<para>Specify the foreground and background pixel values to use.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>filename</emphasis></term>
  <listitem>
<para>Specifies the file name to use.
The format of the file name is operating-system dependent.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>width</emphasis></term>
<!-- .br -->
<!-- .ns -->
  <term><emphasis remap='I'>height</emphasis></term>
  <listitem>
<para>Specify the width and height.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>width_return</emphasis></term>
<!-- .br -->
<!-- .ns -->
  <term><emphasis remap='I'>height_return</emphasis></term>
  <listitem>
<para>Return the width and height values of the read in bitmap file.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>x_hot</emphasis></term>
<!-- .br -->
<!-- .ns -->
  <term><emphasis remap='I'>y_hot</emphasis></term>
  <listitem>
<para>Specify where to place the hotspot coordinates (or -1,-1 if none are present)
in the file.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>x_hot_return</emphasis></term>
<!-- .br -->
<!-- .ns -->
  <term><emphasis remap='I'>y_hot_return</emphasis></term>
  <listitem>
<para>Return the hotspot coordinates.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>The
<emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>
function reads in a file containing a bitmap.
The file is parsed in the encoding of the current locale.
The ability to read other than the standard format 
is implementation-dependent.
If the file cannot be opened, 
<emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>
returns 
<emphasis remap='I'>&hairsp;BitmapOpenFailed&hairsp;</emphasis>.
If the file can be opened but does not contain valid bitmap data, 
it returns 
<emphasis remap='I'>&hairsp;BitmapFileInvalid&hairsp;</emphasis>.
If insufficient working storage is allocated,
it returns
<emphasis remap='I'>&hairsp;BitmapNoMemory&hairsp;</emphasis>.
If the file is readable and valid,
it returns 
<emphasis remap='I'>&hairsp;BitmapSuccess&hairsp;</emphasis>.</para>

<para><emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>
returns the bitmap's height and width, as read
from the file, to width_return and height_return.
It then creates a pixmap of the appropriate size, 
reads the bitmap data from the file into the pixmap,
and assigns the pixmap to the caller's variable bitmap.  
The caller must free the bitmap using 
<emphasis remap='I'>&hairsp;XFreePixmap&hairsp;</emphasis>
when finished.
If <emphasis remap='I'>name</emphasis>_x_hot and <emphasis remap='I'>name</emphasis>_y_hot exist,
<emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>
returns them to x_hot_return and y_hot_return;
otherwise, it returns -1,-1.</para>

<para><emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;BadDrawable&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XReadBitmapFileData&hairsp;</emphasis>
function reads in a file containing a bitmap, in the same manner as
<emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>,
but returns the data directly rather than creating a pixmap in the server.
The bitmap data is returned in data_return; the client must free this
storage when finished with it by calling
<emphasis remap='I'>&hairsp;XFree&hairsp;</emphasis>.
The status and other return values are the same as for
<emphasis remap='I'>&hairsp;XReadBitmapFile&hairsp;</emphasis>.</para>

<para>The
<emphasis remap='I'>&hairsp;XWriteBitmapFile&hairsp;</emphasis>
function writes a bitmap out to a file in the X Version 11 format.
The name used in the output file is derived from the file name
by deleting the directory prefix.
The file is written in the encoding of the current locale.
If the file cannot be opened for writing, 
it returns 
<emphasis remap='I'>&hairsp;BitmapOpenFailed&hairsp;</emphasis>.
If insufficient memory is allocated,
<emphasis remap='I'>&hairsp;XWriteBitmapFile&hairsp;</emphasis>
returns
<emphasis remap='I'>&hairsp;BitmapNoMemory&hairsp;</emphasis>;
otherwise, on no error,
it returns
<emphasis remap='I'>&hairsp;BitmapSuccess&hairsp;</emphasis>.
If x_hot and y_hot are not -1, -1, 
<emphasis remap='I'>&hairsp;XWriteBitmapFile&hairsp;</emphasis>
writes them out as the hotspot coordinates for the bitmap.</para>

<para><emphasis remap='I'>&hairsp;XWriteBitmapFile&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadDrawable&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XCreatePixmapFromBitmapData&hairsp;</emphasis>
function creates a pixmap of the given depth and then does a bitmap-format
<emphasis remap='I'>&hairsp;XPutImage&hairsp;</emphasis>
of the data into it.
The depth must be supported by the screen of the specified drawable,
or a
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
error results.</para>

<para><emphasis remap='I'>&hairsp;XCreatePixmapFromBitmapData&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XCreateBitmapFromData&hairsp;</emphasis>
function allows you to include in your C program (using
<emphasis remap='I'>&hairsp;#include&hairsp;</emphasis>)
a bitmap file that was written out by
<emphasis remap='I'>&hairsp;XWriteBitmapFile&hairsp;</emphasis>
(X version 11 format only) without reading in the bitmap file.
The following example creates a gray bitmap:</para>

<literallayout remap='.nf'>
<!-- .0D  0 -->

<!-- .ps \n(PS -->
<!-- .if \n(VS&gt;=40 .vs \n(VSu -->
<!-- .if \n(VS&lt;=39 .vs \n(VSp -->
#include "gray.bitmap"

Pixmap bitmap;
bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);
<!-- .ce 0  IGNORED -->
<!-- .in \n(OIu  IGNORED -->

</literallayout> <!-- .fi -->

<para>If insufficient working storage was allocated,
<emphasis remap='I'>&hairsp;XCreateBitmapFromData&hairsp;</emphasis>
returns
<emphasis remap='I'>&hairsp;None&hairsp;</emphasis>.
It is your responsibility to free the
bitmap using
<emphasis remap='I'>&hairsp;XFreePixmap&hairsp;</emphasis>
when finished.</para>

<para><emphasis remap='I'>&hairsp;XCreateBitmapFromData&hairsp;</emphasis>
can generate a
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
error.</para>
</refsect1>

<refsect1 id='diagnostics'><title>DIAGNOSTICS</title>
<variablelist remap='TP'>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis></term>
  <listitem>
<para>The server failed to allocate the requested resource or server memory.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadDrawable&hairsp;</emphasis></term>
  <listitem>
<para>A value for a Drawable argument does not name a defined Window or Pixmap.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis></term>
  <listitem>
<para>An
<emphasis remap='I'>&hairsp;InputOnly&hairsp;</emphasis>
window is used as a Drawable.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XCreatePixmap(3X11),
XPutImage(3X11)
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

