blob: 7d61ba014986e69a784f4e0acf225a6d33eb4561 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>FTGL: FTBitmapGlyph.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>FTBitmapGlyph.cpp</h1><a href="FTBitmapGlyph_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#include &lt;string&gt;</span>
00002
00003 <span class="preprocessor">#include "<a class="code" href="FTBitmapGlyph_8h.html">FTBitmapGlyph.h</a>"</span>
00004
<a name="l00005"></a><a class="code" href="classFTBitmapGlyph.html#a0">00005</a> <a class="code" href="classFTBitmapGlyph.html#a0">FTBitmapGlyph::FTBitmapGlyph</a>( FT_GlyphSlot glyph)
00006 : <a class="code" href="classFTGlyph.html">FTGlyph</a>( glyph),
00007 destWidth(0),
00008 destHeight(0),
00009 data(0)
00010 {
00011 err = FT_Render_Glyph( glyph, <a class="code" href="FTGL_8h.html#a1">FT_RENDER_MODE_MONO</a>);
00012 <span class="keywordflow">if</span>( err || ft_glyph_format_bitmap != glyph-&gt;format)
00013 {
00014 <span class="keywordflow">return</span>;
00015 }
00016
00017 FT_Bitmap bitmap = glyph-&gt;bitmap;
00018
00019 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> srcWidth = bitmap.width;
00020 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> srcHeight = bitmap.rows;
00021 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> srcPitch = bitmap.pitch;
00022
00023 destWidth = srcWidth;
00024 destHeight = srcHeight;
00025 destPitch = srcPitch;
00026
00027 <span class="keywordflow">if</span>( destWidth &amp;&amp; destHeight)
00028 {
00029 data = <span class="keyword">new</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>[destPitch * destHeight];
00030 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* dest = data + (( destHeight - 1) * destPitch);
00031
00032 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* src = bitmap.buffer;
00033
00034 <span class="keywordflow">for</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> y = 0; y &lt; srcHeight; ++y)
00035 {
00036 memcpy( dest, src, srcPitch);
00037 dest -= destPitch;
00038 src += srcPitch;
00039 }
00040 }
00041
00042 pos = <a class="code" href="classFTPoint.html">FTPoint</a>(glyph-&gt;bitmap_left, static_cast&lt;int&gt;(srcHeight) - glyph-&gt;bitmap_top, 0.0);
00043 }
00044
00045
<a name="l00046"></a><a class="code" href="classFTBitmapGlyph.html#a1">00046</a> <a class="code" href="classFTBitmapGlyph.html#a1">FTBitmapGlyph::~FTBitmapGlyph</a>()
00047 {
00048 <span class="keyword">delete</span> [] data;
00049 }
00050
00051
<a name="l00052"></a><a class="code" href="classFTBitmapGlyph.html#a2">00052</a> <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>&amp; <a class="code" href="classFTBitmapGlyph.html#a2">FTBitmapGlyph::Render</a>( <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>&amp; pen)
00053 {
00054 glBitmap( 0, 0, 0.0f, 0.0f, pen.<a class="code" href="classFTPoint.html#a7">X</a>() + pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pen.<a class="code" href="classFTPoint.html#a8">Y</a>() - pos.<a class="code" href="classFTPoint.html#a8">Y</a>(), (<span class="keyword">const</span> GLubyte*)0 );
00055
00056 <span class="keywordflow">if</span>( data)
00057 {
00058 glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
00059 glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (<span class="keyword">const</span> GLubyte*)data);
00060 }
00061
00062 glBitmap( 0, 0, 0.0f, 0.0f, -pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pos.<a class="code" href="classFTPoint.html#a8">Y</a>(), (<span class="keyword">const</span> GLubyte*)0 );
00063
00064 <span class="keywordflow">return</span> advance;
00065 }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Dec 5 22:24:05 2004 for FTGL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.6 </small></address>
</body>
</html>