Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > af7a4b7f1ee5a4a084c41b9005da5527 > files > 382

libfox1.1_46-devel-1.1.46-1mdk.i586.rpm

<html>
<head>
<link rel="stylesheet" href="page.css" type="text/css">
<title>fox-toolkit.org - Documentation</title>
</head>
<body bgcolor=#ffffff link=#990033 vlink=#990033 alink=#990033 text=#000000>
<font face='verdana,sans-serif' size=2 >

<!---- TOPIC TITLE WITH LOGO--->
<table border=0 cellpadding= cellspacing=2 width=100% ><tr><td><a href='http://www.fox-toolkit.org/doc.html'><img src='../art/foxlogo_small.jpg' border=0></a></td><td width=100% valign=bottom><font face='verdana,sans-serif' size=2 ><b>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a>
<br><img src='../art/line.gif' width=100% height=1></b></font></td></tr></table>
<p>
<!--- TOPIC TITLE WITH LOGO --->
<!-- Generated by Doxygen 1.3.3 -->
<h1>FXImage.h</h1><div class="fragment"><pre>00001 <span class="comment">/********************************************************************************</span>
00002 <span class="comment">*                                                                               *</span>
00003 <span class="comment">*                             I m a g e    O b j e c t                          *</span>
00004 <span class="comment">*                                                                               *</span>
00005 <span class="comment">*********************************************************************************</span>
00006 <span class="comment">* Copyright (C) 1997,2004 by Jeroen van der Zijp.   All Rights Reserved.        *</span>
00007 <span class="comment">*********************************************************************************</span>
00008 <span class="comment">* This library is free software; you can redistribute it and/or                 *</span>
00009 <span class="comment">* modify it under the terms of the GNU Lesser General Public                    *</span>
00010 <span class="comment">* License as published by the Free Software Foundation; either                  *</span>
00011 <span class="comment">* version 2.1 of the License, or (at your option) any later version.            *</span>
00012 <span class="comment">*                                                                               *</span>
00013 <span class="comment">* This library is distributed in the hope that it will be useful,               *</span>
00014 <span class="comment">* but WITHOUT ANY WARRANTY; without even the implied warranty of                *</span>
00015 <span class="comment">* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *</span>
00016 <span class="comment">* Lesser General Public License for more details.                               *</span>
00017 <span class="comment">*                                                                               *</span>
00018 <span class="comment">* You should have received a copy of the GNU Lesser General Public              *</span>
00019 <span class="comment">* License along with this library; if not, write to the Free Software           *</span>
00020 <span class="comment">* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *</span>
00021 <span class="comment">*********************************************************************************</span>
00022 <span class="comment">* $Id: FXImage.h,v 1.54 2004/01/14 06:26:10 fox Exp $                           *</span>
00023 <span class="comment">********************************************************************************/</span>
00024 <span class="preprocessor">#ifndef FXIMAGE_H</span>
00025 <span class="preprocessor"></span><span class="preprocessor">#define FXIMAGE_H</span>
00026 <span class="preprocessor"></span>
00027 <span class="preprocessor">#ifndef FXDRAWABLE_H</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#include "FXDrawable.h"</span>
00029 <span class="preprocessor">#endif</span>
00030 <span class="preprocessor"></span>
00031 <span class="keyword">namespace </span>FX {
00032 
00033 <span class="comment"></span>
00034 <span class="comment">/// Image rendering hints</span>
00035 <span class="comment"></span><span class="keyword">enum</span> {
00036   <a class="code" href="group__FXImage__0.html#a0a522">IMAGE_KEEP</a>       = 0x00000001,      <span class="comment">/// Keep pixel data in client</span>
00037 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a523">IMAGE_OWNED</a>      = 0x00000002,      <span class="comment">/// Pixel data is owned by image</span>
00038 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a524">IMAGE_DITHER</a>     = 0,               <span class="comment">/// Dither image to look better</span>
00039 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a525">IMAGE_NEAREST</a>    = 0x00000004,      <span class="comment">/// Turn off dithering and map to nearest color</span>
00040 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a526">IMAGE_OPAQUE</a>     = 0x00000008,      <span class="comment">/// Force opaque background</span>
00041 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a527">IMAGE_ALPHACOLOR</a> = 0x00000010,      <span class="comment">/// Override transparancy color</span>
00042 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a528">IMAGE_SHMI</a>       = 0x00000020,      <span class="comment">/// Using shared memory image</span>
00043 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a529">IMAGE_SHMP</a>       = 0x00000040,      <span class="comment">/// Using shared memory pixmap</span>
00044 <span class="comment"></span>  <a class="code" href="group__FXImage__0.html#a0a530">IMAGE_ALPHAGUESS</a> = 0x00000080       <span class="comment">/// Guess transparency color from corners</span>
00045 <span class="comment"></span>  };
00046 
00047 
00048 <span class="keyword">class </span>FXDC;
00049 <span class="keyword">class </span>FXDCWindow;
00050 <span class="keyword">class </span>FXDrawable;
00051 <span class="keyword">class </span>FXTopWindow;
00052 
00053 <span class="comment"></span>
00054 <span class="comment">/**</span>
00055 <span class="comment">* An Image is a rectangular array of pixels.  It supports two representations</span>
00056 <span class="comment">* of these pixels: a client-side pixel buffer which is stored as an array of</span>
00057 <span class="comment">* FXColor, and a server-side pixmap which is stored in an organization directly</span>
00058 <span class="comment">* compatible with the screen, for fast drawing onto the device.</span>
00059 <span class="comment">* The server-side representation is not directly accessible from the current</span>
00060 <span class="comment">* process as it lives in the process of the X Server or GDI.</span>
00061 <span class="comment">*/</span>
00062 <span class="keyword">class </span>FXAPI FXImage : <span class="keyword">public</span> FXDrawable {
00063   FXDECLARE(FXImage)
00064   <span class="keyword">friend</span> <span class="keyword">class </span>FXDC;
00065   <span class="keyword">friend</span> <span class="keyword">class </span>FXDCWindow;
00066   <span class="keyword">friend</span> <span class="keyword">class </span>FXDrawable;
00067   <span class="keyword">friend</span> <span class="keyword">class </span>FXTopWindow;
00068 <span class="keyword">protected</span>:
<a name="l00069"></a><a class="code" href="classFX_1_1FXImage.html">00069</a>   FXColor *data;                <span class="comment">// Pixel data</span>
00070   FXuint   options;             <span class="comment">// Options</span>
00071 <span class="keyword">private</span>:
00072 <span class="preprocessor">#ifdef WIN32</span>
00073 <span class="preprocessor"></span>  <span class="keyword">virtual</span> FXID GetDC() <span class="keyword">const</span>;
00074   <span class="keyword">virtual</span> <span class="keywordtype">int</span> ReleaseDC(FXID) <span class="keyword">const</span>;
00075 <span class="preprocessor">#endif</span>
00076 <span class="preprocessor"></span><span class="preprocessor">#ifndef WIN32</span>
00077 <span class="preprocessor"></span>  <span class="keywordtype">void</span> render_true_32(<span class="keywordtype">void</span> *xim,FXuchar *img);
00078   <span class="keywordtype">void</span> render_true_24(<span class="keywordtype">void</span> *xim,FXuchar *img);
00079   <span class="keywordtype">void</span> render_true_16_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00080   <span class="keywordtype">void</span> render_true_16_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00081   <span class="keywordtype">void</span> render_true_8_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00082   <span class="keywordtype">void</span> render_true_8_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00083   <span class="keywordtype">void</span> render_true_N_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00084   <span class="keywordtype">void</span> render_true_N_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00085   <span class="keywordtype">void</span> render_index_4_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00086   <span class="keywordtype">void</span> render_index_4_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00087   <span class="keywordtype">void</span> render_index_8_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00088   <span class="keywordtype">void</span> render_index_8_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
<a name="l00089"></a><a class="code" href="classFX_1_1FXImage.html#a1">00089</a>   <span class="keywordtype">void</span> render_index_N_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00090   <span class="keywordtype">void</span> render_index_N_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00091   <span class="keywordtype">void</span> render_gray_8_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
<a name="l00092"></a><a class="code" href="classFX_1_1FXImage.html#a2">00092</a>   <span class="keywordtype">void</span> render_gray_8_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00093   <span class="keywordtype">void</span> render_gray_N_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00094   <span class="keywordtype">void</span> render_gray_N_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00095   <span class="keywordtype">void</span> render_mono_1_fast(<span class="keywordtype">void</span> *xim,FXuchar *img);
00096   <span class="keywordtype">void</span> render_mono_1_dither(<span class="keywordtype">void</span> *xim,FXuchar *img);
00097 <span class="preprocessor">#endif</span>
<a name="l00098"></a><a class="code" href="classFX_1_1FXImage.html#a4">00098</a> <span class="preprocessor"></span><span class="keyword">protected</span>:
00099   FXImage();
00100 <span class="keyword">private</span>:
<a name="l00101"></a><a class="code" href="classFX_1_1FXImage.html#a5">00101</a>   FXImage(<span class="keyword">const</span> FXImage&amp;);
00102   FXImage &amp;operator=(<span class="keyword">const</span> FXImage&amp;);
00103 <span class="keyword">public</span>:
00104 <span class="comment"></span>
00105 <span class="comment">  /**</span>
00106 <span class="comment">  * Create an image.  If a client-side pixel buffer has been specified,</span>
00107 <span class="comment">  * the image does not own the pixel buffer unless the IMAGE_OWNED flag is</span>
00108 <span class="comment">  * set.  If the IMAGE_OWNED flag is set but a NULL pixel buffer is</span>
00109 <span class="comment">  * passed, a pixel buffer will be automatically created and will be owned</span>
00110 <span class="comment">  * by the image. The flags IMAGE_SHMI and IMAGE_SHMP may be specified for</span>
00111 <span class="comment">  * large images to instruct render() to use shared memory to communicate</span>
00112 <span class="comment">  * with the server.</span>
00113 <span class="comment">  */</span>
00114   FXImage(<a class="code" href="classFX_1_1FXApp.html">FXApp</a>* a,<span class="keyword">const</span> FXColor *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
00115 <span class="comment"></span>
00116 <span class="comment">  /// To get to the pixel data</span>
00117 <span class="comment"></span>  FXColor* getData()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data; }
00118 <span class="comment"></span>
00119 <span class="comment">  /// To get to the option flags</span>
00120 <span class="comment"></span>  FXuint getOptions()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> options; }
00121 <span class="comment"></span>
00122 <span class="comment">  /// Change options</span>
00123 <span class="comment"></span>  <span class="keywordtype">void</span> setOptions(FXuint opts);
00124 <span class="comment"></span>
00125 <span class="comment">  /// Get pixel at x,y</span>
00126 <span class="comment"></span>  FXColor getPixel(FXint x,FXint y)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data[y*width+x]; }
00127 <span class="comment"></span>
00128 <span class="comment">  /// Change pixel at x,y</span>
00129 <span class="comment"></span>  <span class="keywordtype">void</span> setPixel(FXint x,FXint y,FXColor color){ data[y*width+x]=color; }
00130 <span class="comment"></span>
00131 <span class="comment">  /**</span>
00132 <span class="comment">  * Create the server side pixmap, then call render() to fill it with the</span>
00133 <span class="comment">  * pixel data from the client-side buffer.  After the server-side image has</span>
00134 <span class="comment">  * been created, the client-side pixel buffer will be deleted unless</span>
00135 <span class="comment">  * IMAGE_KEEP has been specified.  If the pixel buffer is not owned, i.e.</span>
00136 <span class="comment">  * the flag IMAGE_OWNED is not set, the pixel buffer will not be deleted.</span>
00137 <span class="comment">  */</span>
00138   <span class="keyword">virtual</span> <span class="keywordtype">void</span> create();
00139 <span class="comment"></span>
00140 <span class="comment">  /**</span>
00141 <span class="comment">  * Detach the server side pixmap from the Image.</span>
00142 <span class="comment">  * Afterwards, the Image is left as if it never had a server-side resources.</span>
00143 <span class="comment">  */</span>
00144   <span class="keyword">virtual</span> <span class="keywordtype">void</span> detach();
00145 <span class="comment"></span>
00146 <span class="comment">  /**</span>
00147 <span class="comment">  * Destroy the server-side pixmap.</span>
00148 <span class="comment">  * The client-side pixel buffer is not affected.</span>
00149 <span class="comment">  */</span>
00150   <span class="keyword">virtual</span> <span class="keywordtype">void</span> destroy();
00151 <span class="comment"></span>
00152 <span class="comment">  /**</span>
00153 <span class="comment">  * Retrieves pixels from the server-side image.  For example, to make</span>
00154 <span class="comment">  * screen snapshots, or to retrieve an image after it has been drawin</span>
00155 <span class="comment">  * into by various means.</span>
00156 <span class="comment">  */</span>
00157   <span class="keyword">virtual</span> <span class="keywordtype">void</span> restore();
00158 <span class="comment"></span>
00159 <span class="comment">  /**</span>
00160 <span class="comment">  * Render the server-side representation of the image from client-side</span>
00161 <span class="comment">  * pixels.  Normally, IMAGE_DITHER is used which causes the server-side</span>
00162 <span class="comment">  * representation to be rendered using a 16x16 ordered dither if necessary;</span>
00163 <span class="comment">  * however if IMAGE_NEAREST is used a faster (but uglier-looking), nearest</span>
00164 <span class="comment">  * neighbor algorithm is used.</span>
00165 <span class="comment">  */</span>
00166   <span class="keyword">virtual</span> <span class="keywordtype">void</span> render();
00167 <span class="comment"></span>
00168 <span class="comment">  /**</span>
00169 <span class="comment">  * Release the client-side pixels buffer, free it if it was owned.</span>
00170 <span class="comment">  * If it is not owned, the image just forgets about the buffer.</span>
00171 <span class="comment">  */</span>
00172   <span class="keyword">virtual</span> <span class="keywordtype">void</span> release();
00173 <span class="comment"></span>
00174 <span class="comment">  /**</span>
00175 <span class="comment">  * Resize both client-side and server-side representations (if any) to the</span>
00176 <span class="comment">  * given width and height.  The new representations typically contain garbage</span>
00177 <span class="comment">  * after this operation and need to be re-filled.</span>
00178 <span class="comment">  */</span>
00179   <span class="keyword">virtual</span> <span class="keywordtype">void</span> resize(FXint w,FXint h);
00180 <span class="comment"></span>
00181 <span class="comment">  /**</span>
00182 <span class="comment">  * Rescale pixels image to the specified width and height; this calls</span>
00183 <span class="comment">  * resize() to adjust the client and server side representations.</span>
00184 <span class="comment">  */</span>
00185   <span class="keyword">virtual</span> <span class="keywordtype">void</span> scale(FXint w,FXint h,FXint quality=0);
00186 <span class="comment"></span>
00187 <span class="comment">  /// Mirror image horizontally and/or vertically</span>
00188 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> mirror(FXbool horizontal,FXbool vertical);
00189 <span class="comment"></span>
00190 <span class="comment">  /**</span>
00191 <span class="comment">  * Rotate image by degrees ccw; this calls resize() to adjust the client</span>
00192 <span class="comment">  * and server side representations if necessary.</span>
00193 <span class="comment">  */</span>
00194   <span class="keyword">virtual</span> <span class="keywordtype">void</span> rotate(FXint degrees);
00195 <span class="comment"></span>
00196 <span class="comment">  /**</span>
00197 <span class="comment">  * Crop image to given rectangle; this calls resize() to adjust the client</span>
00198 <span class="comment">  * and server side representations.</span>
00199 <span class="comment">  */</span>
00200   <span class="keyword">virtual</span> <span class="keywordtype">void</span> crop(FXint x,FXint y,FXint w,FXint h);
00201 <span class="comment"></span>
00202 <span class="comment">  /// Fill image with uniform color</span>
00203 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> fill(FXColor color);
00204 <span class="comment"></span>
00205 <span class="comment">  /// Fade image to uniform color</span>
00206 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> fade(FXColor color,FXint factor=255);
00207 <span class="comment"></span>
00208 <span class="comment">  /**</span>
00209 <span class="comment">  * Shear image horizontally; the number of pixels is equal to the</span>
00210 <span class="comment">  * shear parameter times 256.  The area outside the image is filled</span>
00211 <span class="comment">  * with transparent black, unless another color is specified.</span>
00212 <span class="comment">  */</span>
00213   <span class="keyword">virtual</span> <span class="keywordtype">void</span> xshear(FXint shear,FXColor clr=0);
00214 <span class="comment"></span>
00215 <span class="comment">  /**</span>
00216 <span class="comment">  * Shear image vertically; the number of pixels is equal to the</span>
00217 <span class="comment">  * shear parameter times 256.  The area outside the image is filled</span>
00218 <span class="comment">  * with transparent black, unless another color is specified.</span>
00219 <span class="comment">  */</span>
00220   <span class="keyword">virtual</span> <span class="keywordtype">void</span> yshear(FXint shear,FXColor clr=0);
00221 <span class="comment"></span>
00222 <span class="comment">  /// Fill horizontal gradient</span>
00223 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> hgradient(FXColor left,FXColor right);
00224 <span class="comment"></span>
00225 <span class="comment">  /// Fill vertical gradient</span>
00226 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> vgradient(FXColor top,FXColor bottom);
00227 <span class="comment"></span>
00228 <span class="comment">  /// Fill with gradient</span>
00229 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> gradient(FXColor topleft,FXColor topright,FXColor bottomleft,FXColor bottomright);
00230 <span class="comment"></span>
00231 <span class="comment">  /// Blend image over uniform color</span>
00232 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> blend(FXColor color);
00233 <span class="comment"></span>
00234 <span class="comment">  /// Save object to stream</span>
00235 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> save(FXStream&amp; store) <span class="keyword">const</span>;
00236 <span class="comment"></span>
00237 <span class="comment">  /// Load object from stream</span>
00238 <span class="comment"></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> load(FXStream&amp; store);
00239 <span class="comment"></span>
00240 <span class="comment">  /// Save pixel data only</span>
00241 <span class="comment"></span>  <span class="keyword">virtual</span> FXbool savePixels(FXStream&amp; store) <span class="keyword">const</span>;
00242 <span class="comment"></span>
00243 <span class="comment">  /// Load pixel data only</span>
00244 <span class="comment"></span>  <span class="keyword">virtual</span> FXbool loadPixels(FXStream&amp; store);
00245 <span class="comment"></span>
00246 <span class="comment">  /// Destructor</span>
00247 <span class="comment"></span>  <span class="keyword">virtual</span> ~FXImage();
00248   };
00249 
00250 }
00251 
00252 <span class="preprocessor">#endif</span>
</pre></div></font>

<!--- COPYRIGHT -->
<p>
<table width=100% cellpadding=0 cellspacing=0><tr><td width=100% valign=top id=HEADLINE align=right>
<img src='../art/line.gif' width=100% height=1><font size=-1>
Copyright &copy; 1997-2004 Jeroen van der Zijp</font>
</td></tr></table>
</p>
<!--- COPYRIGHT -->
</body>
</html>