| <!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: FTPixmapGlyph.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 Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div> |
| <h1>FTPixmapGlyph.cpp</h1><a href="FTPixmapGlyph_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#include "<a class="code" href="FTPixmapGlyph_8h.html">FTPixmapGlyph.h</a>"</span> |
| 00002 |
| <a name="l00003"></a><a class="code" href="classFTPixmapGlyph.html#a0">00003</a> <a class="code" href="classFTPixmapGlyph.html#a0">FTPixmapGlyph::FTPixmapGlyph</a>( FT_GlyphSlot glyph) |
| 00004 : <a class="code" href="classFTGlyph.html">FTGlyph</a>( glyph), |
| 00005 destWidth(0), |
| 00006 destHeight(0), |
| 00007 data(0) |
| 00008 { |
| 00009 err = FT_Render_Glyph( glyph, <a class="code" href="FTGL_8h.html#a2">FT_RENDER_MODE_NORMAL</a>); |
| 00010 <span class="keywordflow">if</span>( err || ft_glyph_format_bitmap != glyph->format) |
| 00011 { |
| 00012 <span class="keywordflow">return</span>; |
| 00013 } |
| 00014 |
| 00015 FT_Bitmap bitmap = glyph->bitmap; |
| 00016 |
| 00017 <span class="comment">//check the pixel mode</span> |
| 00018 <span class="comment">//ft_pixel_mode_grays</span> |
| 00019 |
| 00020 <span class="keywordtype">int</span> srcWidth = bitmap.width; |
| 00021 <span class="keywordtype">int</span> srcHeight = bitmap.rows; |
| 00022 |
| 00023 <span class="comment">// FIXME What about dest alignment?</span> |
| 00024 destWidth = srcWidth; |
| 00025 destHeight = srcHeight; |
| 00026 |
| 00027 <span class="keywordflow">if</span>( destWidth && destHeight) |
| 00028 { |
| 00029 data = <span class="keyword">new</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>[destWidth * destHeight * 4]; |
| 00030 |
| 00031 <span class="comment">// Get the current glColor.</span> |
| 00032 <span class="keywordtype">float</span> ftglColour[4]; |
| 00033 glGetFloatv( GL_CURRENT_COLOR, ftglColour); |
| 00034 |
| 00035 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> redComponent = static_cast<unsigned char>( ftglColour[0] * 255.0f); |
| 00036 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> greenComponent = static_cast<unsigned char>( ftglColour[1] * 255.0f); |
| 00037 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> blueComponent = static_cast<unsigned char>( ftglColour[2] * 255.0f); |
| 00038 |
| 00039 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* src = bitmap.buffer; |
| 00040 |
| 00041 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* dest = data + ((destHeight - 1) * destWidth) * 4; |
| 00042 size_t destStep = destWidth * 4 * 2; |
| 00043 |
| 00044 <span class="keywordflow">if</span>( ftglColour[3] == 1.0f) |
| 00045 { |
| 00046 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> y = 0; y < srcHeight; ++y) |
| 00047 { |
| 00048 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> x = 0; x < srcWidth; ++x) |
| 00049 { |
| 00050 *dest++ = redComponent; |
| 00051 *dest++ = greenComponent; |
| 00052 *dest++ = blueComponent; |
| 00053 *dest++ = *src++; |
| 00054 } |
| 00055 dest -= destStep; |
| 00056 } |
| 00057 } |
| 00058 <span class="keywordflow">else</span> |
| 00059 { |
| 00060 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> y = 0; y < srcHeight; ++y) |
| 00061 { |
| 00062 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> x = 0; x < srcWidth; ++x) |
| 00063 { |
| 00064 *dest++ = redComponent; |
| 00065 *dest++ = greenComponent; |
| 00066 *dest++ = blueComponent; |
| 00067 *dest++ = static_cast<unsigned char>(ftglColour[3] * *src++); |
| 00068 } |
| 00069 dest -= destStep; |
| 00070 } |
| 00071 } |
| 00072 destHeight = srcHeight; |
| 00073 } |
| 00074 |
| 00075 pos.<a class="code" href="classFTPoint.html#a7">X</a>( glyph->bitmap_left); |
| 00076 pos.<a class="code" href="classFTPoint.html#a8">Y</a>( srcHeight - glyph->bitmap_top); |
| 00077 } |
| 00078 |
| 00079 |
| <a name="l00080"></a><a class="code" href="classFTPixmapGlyph.html#a1">00080</a> <a class="code" href="classFTPixmapGlyph.html#a1">FTPixmapGlyph::~FTPixmapGlyph</a>() |
| 00081 { |
| 00082 <span class="keyword">delete</span> [] data; |
| 00083 } |
| 00084 |
| 00085 |
| <a name="l00086"></a><a class="code" href="classFTPixmapGlyph.html#a2">00086</a> <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>& <a class="code" href="classFTPixmapGlyph.html#a2">FTPixmapGlyph::Render</a>( <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>& pen) |
| 00087 { |
| 00088 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); |
| 00089 |
| 00090 <span class="keywordflow">if</span>( data) |
| 00091 { |
| 00092 glPixelStorei( GL_UNPACK_ROW_LENGTH, 0); |
| 00093 glDrawPixels( destWidth, destHeight, GL_RGBA, GL_UNSIGNED_BYTE, (<span class="keyword">const</span> GLvoid*)data); |
| 00094 } |
| 00095 |
| 00096 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); |
| 00097 |
| 00098 <span class="keywordflow">return</span> advance; |
| 00099 } |
| </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Dec 5 22:24:06 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> |