Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > d67485fb8ce60f8952179bbde3b5d022 > files > 99

libgdal0-devel-1.1.7-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>gdalcolortable.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.3-20001105 on Thu Mar 28 09:47:30 2002 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</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> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>gdalcolortable.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * $Id: gdalcolortable_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Project:  GDAL Core</font>
00005 <font class="comment"> * Purpose:  Color table implementation.</font>
00006 <font class="comment"> * Author:   Frank Warmerdam, warmerda@home.com</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> **********************************************************************</font>
00009 <font class="comment"> * Copyright (c) 2000, Frank Warmerdam</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</font>
00012 <font class="comment"> * copy of this software and associated documentation files (the "Software"),</font>
00013 <font class="comment"> * to deal in the Software without restriction, including without limitation</font>
00014 <font class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</font>
00015 <font class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</font>
00016 <font class="comment"> * Software is furnished to do so, subject to the following conditions:</font>
00017 <font class="comment"> *</font>
00018 <font class="comment"> * The above copyright notice and this permission notice shall be included</font>
00019 <font class="comment"> * in all copies or substantial portions of the Software.</font>
00020 <font class="comment"> *</font>
00021 <font class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</font>
00022 <font class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</font>
00023 <font class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</font>
00024 <font class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</font>
00025 <font class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</font>
00026 <font class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</font>
00027 <font class="comment"> * DEALINGS IN THE SOFTWARE.</font>
00028 <font class="comment"> ******************************************************************************</font>
00029 <font class="comment"> * $Log: gdalcolortable_cpp-source.html,v $
00029 <font class="comment"> * Revision 1.10  2002/04/16 13:11:48  warmerda
00029 <font class="comment"> * updated
00029 <font class="comment"> *</font>
00030 <font class="comment"> * Revision 1.2  2001/07/18 04:04:30  warmerda</font>
00031 <font class="comment"> * added CPL_CVSID</font>
00032 <font class="comment"> *</font>
00033 <font class="comment"> * Revision 1.1  2000/03/06 02:26:00  warmerda</font>
00034 <font class="comment"> * New</font>
00035 <font class="comment"> *</font>
00036 <font class="comment"> */</font>
00037 
00038 <font class="preprocessor">#include "gdal_priv.h"</font>
00039 
00040 CPL_CVSID(<font class="stringliteral">"$Id: gdalcolortable_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $"</font>);
00041 
00042 <font class="comment">/************************************************************************/</font>
00043 <font class="comment">/*                           GDALColorTable()                           */</font>
00044 <font class="comment">/************************************************************************/</font>
00045 
00055 GDALColorTable::GDALColorTable( GDALPaletteInterp eInterpIn )<font class="keyword"></font>
00056 <font class="keyword"></font>
00057 <font class="keyword"></font>{
00058     eInterp = eInterpIn;
00059 
00060     nEntryCount = 0;
00061     paoEntries = NULL;
00062 }
00063 
00064 <font class="comment">/************************************************************************/</font>
00065 <font class="comment">/*                        GDALCreateColorTable()                        */</font>
00066 <font class="comment">/************************************************************************/</font>
00067 
00068 GDALColorTableH GDALCreateColorTable( GDALPaletteInterp eInterp )<font class="keyword"></font>
00069 <font class="keyword"></font>
00070 <font class="keyword"></font>{
00071     <font class="keywordflow">return</font> (GDALColorTableH) (<font class="keyword">new</font> GDALColorTable( eInterp ));
00072 }
00073 
00074 
00075 <font class="comment">/************************************************************************/</font>
00076 <font class="comment">/*                          ~GDALColorTable()                           */</font>
00077 <font class="comment">/************************************************************************/</font>
00078 
00085 GDALColorTable::~GDALColorTable()<font class="keyword"></font>
00086 <font class="keyword"></font>
00087 <font class="keyword"></font>{
00088     CPLFree( paoEntries );
00089     paoEntries = NULL;
00090 }
00091 
00092 <font class="comment">/************************************************************************/</font>
00093 <font class="comment">/*                       GDALDestroyColorTable()                        */</font>
00094 <font class="comment">/************************************************************************/</font>
00095 
00096 <font class="keywordtype">void</font> GDALDestroyColorTable( GDALColorTableH hTable )<font class="keyword"></font>
00097 <font class="keyword"></font>
00098 <font class="keyword"></font>{
00099     <font class="keyword">delete</font> (GDALColorTable *) hTable;
00100 }
00101 
00102 <font class="comment">/************************************************************************/</font>
00103 <font class="comment">/*                           GetColorEntry()                            */</font>
00104 <font class="comment">/************************************************************************/</font>
00105 
00116 <font class="keyword">const</font> <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *GDALColorTable::GetColorEntry( <font class="keywordtype">int</font> i )<font class="keyword"> const</font>
00117 <font class="keyword"></font>
00118 <font class="keyword"></font>{
00119     <font class="keywordflow">if</font>( i &lt; 0 || i &gt;= nEntryCount )
00120         <font class="keywordflow">return</font> NULL;
00121     <font class="keywordflow">else</font>
00122         <font class="keywordflow">return</font> paoEntries + i;
00123 }
00124 
00125 <font class="comment">/************************************************************************/</font>
00126 <font class="comment">/*                         GDALGetColorEntry()                          */</font>
00127 <font class="comment">/************************************************************************/</font>
00128 
00129 <font class="keyword">const</font> <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *GDALGetColorEntry( GDALColorTableH hTable, <font class="keywordtype">int</font> i )<font class="keyword"></font>
00130 <font class="keyword"></font>
00131 <font class="keyword"></font>{
00132     <font class="keywordflow">return</font> ((GDALColorTable *) hTable)-&gt;GetColorEntry( i );
00133 }
00134 
00135 
00136 <font class="comment">/************************************************************************/</font>
00137 <font class="comment">/*                         GetColorEntryAsRGB()                         */</font>
00138 <font class="comment">/************************************************************************/</font>
00139 
00157 <font class="keywordtype">int</font> GDALColorTable::GetColorEntryAsRGB( <font class="keywordtype">int</font> i, <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *poEntry )<font class="keyword"> const</font>
00158 <font class="keyword"></font>
00159 <font class="keyword"></font>{
00160     <font class="keywordflow">if</font>( eInterp != GPI_RGB || i &lt; 0 || i &gt;= nEntryCount )
00161         <font class="keywordflow">return</font> FALSE;
00162     
00163     *poEntry = paoEntries[i];
00164     <font class="keywordflow">return</font> TRUE;
00165 }
00166 
00167 <font class="comment">/************************************************************************/</font>
00168 <font class="comment">/*                       GDALGetColorEntryAsRGB()                       */</font>
00169 <font class="comment">/************************************************************************/</font>
00170 
00171 <font class="keywordtype">int</font> GDALGetColorEntryAsRGB( GDALColorTableH hTable, <font class="keywordtype">int</font> i, 
00172                             <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *poEntry )<font class="keyword"></font>
00173 <font class="keyword"></font>
00174 <font class="keyword"></font>{
00175     <font class="keywordflow">return</font> ((GDALColorTable *) hTable)-&gt;GetColorEntryAsRGB( i, poEntry );
00176 }
00177 
00178 <font class="comment">/************************************************************************/</font>
00179 <font class="comment">/*                           SetColorEntry()                            */</font>
00180 <font class="comment">/************************************************************************/</font>
00181 
00197 <font class="keywordtype">void</font> GDALColorTable::SetColorEntry( <font class="keywordtype">int</font> i, <font class="keyword">const</font> <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> * poEntry )<font class="keyword"></font>
00198 <font class="keyword"></font>
00199 <font class="keyword"></font>{
00200     <font class="keywordflow">if</font>( i &lt; 0 )
00201         <font class="keywordflow">return</font>;
00202     
00203     <font class="keywordflow">if</font>( i &gt;= nEntryCount )
00204     {
00205         paoEntries = (<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *) 
00206             <a class="code" href="cpl_conv_h.html#a5">CPLRealloc</a>(paoEntries, <font class="keyword">sizeof</font>(<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a>) * (i+1));
00207         memset( paoEntries + nEntryCount, 0, 
00208                 <font class="keyword">sizeof</font>(<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a>) * (i + 1 - nEntryCount) );
00209         
00210         nEntryCount = i+1;
00211     }
00212 
00213     paoEntries[i] = *poEntry;
00214 }
00215 
00216 <font class="comment">/************************************************************************/</font>
00217 <font class="comment">/*                         GDALSetColorEntry()                          */</font>
00218 <font class="comment">/************************************************************************/</font>
00219 
00220 <font class="keywordtype">void</font> GDALSetColorEntry( GDALColorTableH hTable, <font class="keywordtype">int</font> i, 
00221                         <font class="keyword">const</font> <a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> * poEntry )<font class="keyword"></font>
00222 <font class="keyword"></font>
00223 <font class="keyword"></font>{
00224     ((GDALColorTable *) hTable)-&gt;SetColorEntry( i, poEntry );
00225 }
00226 
00227 
00228 <font class="comment">/************************************************************************/</font>
00229 <font class="comment">/*                               Clone()                                */</font>
00230 <font class="comment">/************************************************************************/</font>
00231 
00238 GDALColorTable *GDALColorTable::Clone()<font class="keyword"> const</font>
00239 <font class="keyword"></font>
00240 <font class="keyword"></font>{
00241     GDALColorTable *poNew;
00242 
00243     poNew = <font class="keyword">new</font> GDALColorTable(eInterp);
00244     poNew-&gt;nEntryCount = nEntryCount;
00245     poNew-&gt;paoEntries = (<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a> *) 
00246         <a class="code" href="cpl_conv_h.html#a3">CPLMalloc</a>(<font class="keyword">sizeof</font>(<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a>)*nEntryCount);
00247     memcpy( poNew-&gt;paoEntries, paoEntries, <font class="keyword">sizeof</font>(<a class="code" href="struct_GDALColorEntry.html">GDALColorEntry</a>)*nEntryCount);
00248 
00249     <font class="keywordflow">return</font> poNew;
00250 }
00251 
00252 <font class="comment">/************************************************************************/</font>
00253 <font class="comment">/*                        GDALCloneColorTable()                         */</font>
00254 <font class="comment">/************************************************************************/</font>
00255 
00256 GDALColorTableH GDALCloneColorTable( GDALColorTableH hTable )<font class="keyword"></font>
00257 <font class="keyword"></font>
00258 <font class="keyword"></font>{
00259     <font class="keywordflow">return</font> (GDALColorTableH) ((GDALColorTable *) hTable)-&gt;Clone();
00260 }
00261 
00262 <font class="comment">/************************************************************************/</font>
00263 <font class="comment">/*                         GetColorEntryCount()                         */</font>
00264 <font class="comment">/************************************************************************/</font>
00265 
00274 <font class="keywordtype">int</font> GDALColorTable::GetColorEntryCount()<font class="keyword"> const</font>
00275 <font class="keyword"></font>
00276 <font class="keyword"></font>{
00277     <font class="keywordflow">return</font> nEntryCount;
00278 }
00279 
00280 <font class="comment">/************************************************************************/</font>
00281 <font class="comment">/*                       GDALGetColorEntryCount()                       */</font>
00282 <font class="comment">/************************************************************************/</font>
00283 
00284 <font class="keywordtype">int</font> GDALGetColorEntryCount( GDALColorTableH hTable )<font class="keyword"></font>
00285 <font class="keyword"></font>
00286 <font class="keyword"></font>{
00287     <font class="keywordflow">return</font> ((GDALColorTable *) hTable)-&gt;GetColorEntryCount();
00288 }
00289 
00290 <font class="comment">/************************************************************************/</font>
00291 <font class="comment">/*                      GetPaletteInterpretation()                      */</font>
00292 <font class="comment">/************************************************************************/</font>
00293 
00304 GDALPaletteInterp GDALColorTable::GetPaletteInterpretation()<font class="keyword"> const</font>
00305 <font class="keyword"></font>
00306 <font class="keyword"></font>{
00307     <font class="keywordflow">return</font> eInterp;
00308 }
00309 
00310 <font class="comment">/************************************************************************/</font>
00311 <font class="comment">/*                    GDALGetPaltteInterpretation()                     */</font>
00312 <font class="comment">/************************************************************************/</font>
00313 
00314 GDALPaletteInterp GDALGetPaletteInterpretation( GDALColorTableH hTable )<font class="keyword"></font>
00315 <font class="keyword"></font>
00316 <font class="keyword"></font>{
00317     <font class="keywordflow">return</font> ((GDALColorTable *) hTable)-&gt;GetPaletteInterpretation();
00318 }
</div></pre><hr><address><small>Generated at Thu Mar 28 09:47:30 2002 for GDAL by
<a href="http://www.stack.nl/~dimitri/doxygen/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.3-20001105 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2000</small></address>
</body>
</html>