diff options
Diffstat (limited to 'docs/doxygen/nel/Pic_BMP_c-source.html')
-rw-r--r-- | docs/doxygen/nel/Pic_BMP_c-source.html | 289 |
1 files changed, 289 insertions, 0 deletions
diff --git a/docs/doxygen/nel/Pic_BMP_c-source.html b/docs/doxygen/nel/Pic_BMP_c-source.html new file mode 100644 index 00000000..34405fcc --- /dev/null +++ b/docs/doxygen/nel/Pic_BMP_c-source.html @@ -0,0 +1,289 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.2 on Thu May 31 22:01:21 2001 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>Pic_BMP.c</h1><a href="Pic_BMP_c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="preprocessor">#include <stdio.h></font> +00002 <font class="preprocessor">#include <stdlib.h></font> +00003 <font class="preprocessor">#include <string.h></font> +00004 +00005 <font class="preprocessor">#include "<a class="code" href="pic_private_h.html">pic_private.h</a>"</font> +00006 <font class="preprocessor">#include "<a class="code" href="pic_h.html">pic.h</a>"</font> +00007 +00008 <font class="comment">// ----------------------------------------------------------------------------------------------------------------------------------</font> +00009 +00010 <font class="preprocessor">#pragma pack(1) +</font><a name="l00011"></a><a class="code" href="class_BMP_HEADER.html">00011</a> <font class="preprocessor"></font><font class="keyword">typedef</font> <font class="keyword">struct </font><a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a> +00012 { +<a name="l00013"></a><a class="code" href="class_BMP_HEADER.html#m0">00013</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> bfType; +<a name="l00014"></a><a class="code" href="class_BMP_HEADER.html#m1">00014</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> bfSize; +<a name="l00015"></a><a class="code" href="class_BMP_HEADER.html#m2">00015</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> Res1; +<a name="l00016"></a><a class="code" href="class_BMP_HEADER.html#m3">00016</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> Res2; +<a name="l00017"></a><a class="code" href="class_BMP_HEADER.html#m4">00017</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> bfOffBits; +<a name="l00018"></a><a class="code" href="class_BMP_HEADER.html#m5">00018</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biSize; +<a name="l00019"></a><a class="code" href="class_BMP_HEADER.html#m6">00019</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biWidth; +<a name="l00020"></a><a class="code" href="class_BMP_HEADER.html#m7">00020</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biHeight; +<a name="l00021"></a><a class="code" href="class_BMP_HEADER.html#m8">00021</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> biPlanes; +<a name="l00022"></a><a class="code" href="class_BMP_HEADER.html#m9">00022</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> biBitCount; +<a name="l00023"></a><a class="code" href="class_BMP_HEADER.html#m10">00023</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biCompression; +<a name="l00024"></a><a class="code" href="class_BMP_HEADER.html#m11">00024</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biSizeImage; +<a name="l00025"></a><a class="code" href="class_BMP_HEADER.html#m12">00025</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biXPelsPerMeter; +<a name="l00026"></a><a class="code" href="class_BMP_HEADER.html#m13">00026</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biYPelsPerMeter; +<a name="l00027"></a><a class="code" href="class_BMP_HEADER.html#m14">00027</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biClrUsed; +<a name="l00028"></a><a class="code" href="class_BMP_HEADER.html#m15">00028</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> biClrImportant; +00029 } <a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>; +00030 <font class="preprocessor">#pragma pack() +</font>00031 <font class="preprocessor"></font> +00032 <font class="comment">// ----------------------------------------------------------------------------------------------------------------------------------</font> +00033 +<a name="l00034"></a><a class="code" href="Pic_BMP_c.html#a1">00034</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <a class="code" href="Pic_BMP_c.html#a1">Pic_BMP_Write</a>( <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *FileName, +00035 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *pPal,<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *pDatas, +00036 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> w, <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> h, <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> d)<font class="keyword"> +</font>00037 <font class="keyword"> +</font>00038 <font class="keyword"></font>{ +00039 FILE *file; +00040 <a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a> bmph; +00041 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> slsize; +00042 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *scanline; +00043 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> i; +00044 <font class="keywordtype">long</font> x,y,rest; +00045 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> r,g,b; +00046 +00047 file=fopen(FileName,<font class="stringliteral">"wb"</font>); +00048 <font class="keywordflow">if</font> (!file) +00049 { +00050 <font class="keywordflow">return</font>(0); +00051 } +00052 memset(&bmph,0,<font class="keyword">sizeof</font>(<a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>)); +00053 bmph.bfType=19778; +00054 bmph.bfSize=<font class="keyword">sizeof</font>(<a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>); +00055 bmph.bfSize+=w*h*d/8; +00056 <font class="keywordflow">if</font> (pPal) +00057 { +00058 bmph.bfSize+=(256*4); +00059 } +00060 bmph.bfOffBits=<font class="keyword">sizeof</font>(<a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>); +00061 <font class="keywordflow">if</font> (pPal) +00062 { +00063 bmph.bfOffBits+=(256*4); +00064 } +00065 bmph.biSize=40;<font class="comment">//sizeof(BMP_HEADER);</font> +00066 bmph.biWidth=w; +00067 bmph.biHeight=h; +00068 bmph.biPlanes=1; +00069 bmph.biBitCount=(<font class="keywordtype">unsigned</font> <font class="keywordtype">short</font>)d; +00070 bmph.biCompression=0; +00071 bmph.biSizeImage=w*h*d/8; +00072 +00073 fwrite(&bmph,1,<font class="keyword">sizeof</font>(<a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>),file); +00074 <font class="keywordflow">if</font> (pPal) +00075 { +00076 <font class="keywordflow">for</font>(i=0 ; i<256 ; i++) +00077 { +00078 fwrite(&pPal[i*3+0],1,1,file); +00079 fwrite(&pPal[i*3+1],1,1,file); +00080 fwrite(&pPal[i*3+2],1,1,file); +00081 fwrite(&pPal[i*3+2],1,1,file); +00082 } +00083 } +00084 slsize=w*d/8; +00085 scanline=<a class="code" href="pic_private_h.html#a4">Pic_calloc</a>(1,slsize); +00086 <font class="keywordflow">if</font> (!scanline) +00087 { +00088 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Write, not enough memory for scanline"</font>); +00089 <font class="keywordflow">return</font>(0); +00090 } +00091 <font class="keywordflow">for</font>(rest=0 ; ((w*d/8)+rest)%4!=0 ; rest++); +00092 <font class="keywordflow">for</font>(y=0 ; y<(<font class="keywordtype">long</font>)h ; y++) +00093 { +00094 memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize); +00095 <font class="keywordflow">if</font> (d==24) +00096 { +00097 <font class="keywordflow">for</font>(x=0 ; x<(<font class="keywordtype">long</font>)w ; x++) +00098 { +00099 b=scanline[x*3+0]; +00100 g=scanline[x*3+1]; +00101 r=scanline[x*3+2]; +00102 scanline[x*3+0]=b; +00103 scanline[x*3+1]=g; +00104 scanline[x*3+2]=r; +00105 } +00106 } +00107 fwrite(scanline,1,slsize,file); +00108 <font class="keywordflow">if</font> (rest) +00109 { +00110 fwrite(scanline,1,rest,file); +00111 } +00112 } +00113 <a class="code" href="pic_private_h.html#a5">Pic_free</a>(scanline); +00114 fclose(file); +00115 <font class="keywordflow">return</font>(1); +00116 } +00117 +00118 <font class="comment">// ----------------------------------------------------------------------------------------------------------------------------------</font> +00119 +<a name="l00120"></a><a class="code" href="Pic_BMP_c.html#a2">00120</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <a class="code" href="Pic_BMP_c.html#a2">Pic_BMP_Read</a>( <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *FileName, +00121 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> **ppPal, <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> **ppDatas, +00122 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> *pWidth, <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> *pHeight, +00123 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> *pDepth)<font class="keyword"> +</font>00124 <font class="keyword"></font>{ +00125 FILE *file; +00126 <a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a> bmph; +00127 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *pPal; +00128 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *pDatas; +00129 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *scanline; +00130 <font class="keywordtype">long</font> w,h,d; +00131 <font class="keywordtype">long</font> i,x,y,rest; +00132 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> r,g,b; +00133 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> pad[4]; +00134 +00135 pPal=NULL; +00136 pDatas=NULL; +00137 file=fopen(FileName,<font class="stringliteral">"rb"</font>); +00138 <font class="keywordflow">if</font> (!file) +00139 { +00140 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Read, unable to open %s"</font>,FileName); +00141 <font class="keywordflow">return</font>(0); +00142 } +00143 fread(&bmph,1,<font class="keyword">sizeof</font>(<a class="code" href="class_BMP_HEADER.html">BMP_HEADER</a>),file); +00144 *pWidth=w=bmph.biWidth; +00145 *pHeight=h=bmph.biHeight; +00146 *pDepth=d=bmph.biBitCount; +00147 <font class="keywordflow">if</font> (d!=8 && d!=24) +00148 { +00149 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Read, number of bits per pixel unsupported"</font>); +00150 <font class="keywordflow">return</font>(0); +00151 } +00152 <font class="keywordflow">if</font> (*pDepth==8) +00153 { +00154 pPal=<a class="code" href="pic_private_h.html#a4">Pic_calloc</a>(1,256*3); +00155 <font class="keywordflow">if</font> (!pPal) +00156 { +00157 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Read, not enough memory for palette"</font>); +00158 <font class="keywordflow">return</font>(0); +00159 } +00160 <font class="keywordflow">for</font>(i=0 ; i<256 ; i++) +00161 { +00162 fread(&pPal[i*3+2],1,1,file); +00163 fread(&pPal[i*3+1],1,1,file); +00164 fread(&pPal[i*3+0],1,1,file); +00165 fread(&pad[0],1,1,file); +00166 } +00167 } +00168 pDatas=<a class="code" href="pic_private_h.html#a4">Pic_calloc</a>(1,w*h*d/8); +00169 <font class="keywordflow">if</font> (!pDatas) +00170 { +00171 <font class="keywordflow">if</font> (pPal) +00172 { +00173 <a class="code" href="pic_private_h.html#a5">Pic_free</a>(pPal); +00174 } +00175 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Read, not enough memory for datas"</font>); +00176 <font class="keywordflow">return</font>(0); +00177 } +00178 scanline=<a class="code" href="pic_private_h.html#a4">Pic_calloc</a>(1,w*h*d/8); +00179 <font class="keywordflow">if</font> (!scanline) +00180 { +00181 <font class="keywordflow">if</font> (pPal) +00182 { +00183 <a class="code" href="pic_private_h.html#a5">Pic_free</a>(pPal); +00184 } +00185 <a class="code" href="pic_private_h.html#a5">Pic_free</a>(pDatas); +00186 <a class="code" href="pic_private_h.html#a7">Pic_SetError</a>(<font class="stringliteral">"BMP_Read, not enough memory for scanline"</font>); +00187 <font class="keywordflow">return</font>(0); +00188 } +00189 <font class="keywordflow">for</font>(rest=0 ; (w+rest)%4!=0 ; rest++); +00190 <font class="keywordflow">for</font>(y=0 ; y<h ; y++) +00191 { +00192 fread(scanline,w,d/8,file); +00193 <font class="keywordflow">if</font> (d==24) +00194 { +00195 <font class="keywordflow">for</font>(x=0 ; x<w ; x++) +00196 { +00197 r=scanline[x*3+0]; +00198 g=scanline[x*3+1]; +00199 b=scanline[x*3+2]; +00200 scanline[x*3+0]=b; +00201 scanline[x*3+1]=g; +00202 scanline[x*3+2]=r; +00203 } +00204 } +00205 memcpy(&pDatas[(h-y-1)*w*d/8],scanline,w*d/8); +00206 fread(pad,rest,d/8,file); +00207 } +00208 fclose(file); +00209 <a class="code" href="pic_private_h.html#a5">Pic_free</a>(scanline); +00210 *ppPal=pPal; +00211 *ppDatas=pDatas; +00212 <font class="keywordflow">return</font>(1); +00213 } +00214 +00215 <font class="comment">// ----------------------------------------------------------------------------------------------------------------------------------</font> +</div></pre> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |