00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "OSGTextPixmapGlyph.h"
00040
00041
00042 using namespace std;
00043
00044
00045 OSG_BEGIN_NAMESPACE
00046
00047
00048
00049
00050
00051
00052 TextPixmapGlyph::~TextPixmapGlyph()
00053 { delete [] _pixmap; }
00054
00055
00056
00057
00058
00059
00060 Real32 TextPixmapGlyph::getWidth() const
00061 { return static_cast<Real32>(_width); }
00062
00063
00064
00065
00066
00067
00068 Real32 TextPixmapGlyph::getHeight() const
00069 { return static_cast<Real32>(_height); }
00070
00071
00072
00073
00074
00075
00076 Real32 TextPixmapGlyph::getHoriBearingX() const
00077 { return static_cast<Real32>(_horiBearingX); }
00078
00079
00080
00081
00082
00083
00084 Real32 TextPixmapGlyph::getHoriBearingY() const
00085 { return static_cast<Real32>(_horiBearingY); }
00086
00087
00088
00089
00090
00091
00092 Real32 TextPixmapGlyph::getVertBearingX() const
00093 { return static_cast<Real32>(_vertBearingX); }
00094
00095
00096
00097
00098
00099
00100 Real32 TextPixmapGlyph::getVertBearingY() const
00101 { return static_cast<Real32>(_vertBearingY); }
00102
00103
00104
00105
00106
00107
00108 void TextPixmapGlyph::putPixmap(Int32 x, Int32 y, UInt8 *tex,
00109 UInt32 width, UInt32 height) const
00110 {
00111 if (_pixmap != 0)
00112 {
00113
00114 int left = 0;
00115 int glyphWidth = _width;
00116 int src = 0;
00117 int dst = 0;
00118 int delta = x;
00119 if (delta < left)
00120 {
00121 delta = left - delta;
00122 src += delta;
00123 glyphWidth -= delta;
00124 delta = left;
00125 }
00126 dst += delta;
00127
00128
00129 int right = width;
00130 delta = right - dst;
00131 if (delta < glyphWidth)
00132 glyphWidth = delta;
00133
00134
00135 int bottom = 0;
00136 int glyphHeight = _height;
00137 delta = y - _height;
00138 if (delta < bottom)
00139 {
00140 delta = bottom - delta;
00141 src += delta * _pitch;
00142 glyphHeight -= delta;
00143 delta = bottom;
00144 }
00145 dst += delta * width;
00146
00147
00148 int top = height;
00149 delta = top - y ;
00150 if (delta < 0)
00151 glyphHeight += delta;
00152
00153 int xi, yi;
00154 for (yi = glyphHeight; yi > 0; --yi)
00155 {
00156 unsigned char *srcPtr = &(_pixmap[src]);
00157 unsigned char *dstPtr = &(tex[dst]);
00158 for (xi = glyphWidth; xi > 0; --xi)
00159 {
00160 unsigned char p = 255 - ((255 - *dstPtr) * (255 - *srcPtr) / 255);
00161 *dstPtr++ = p;
00162 srcPtr++;
00163 }
00164 src += _pitch;
00165 dst += width;
00166 }
00167 }
00168 }
00169
00170
00171
00172
00173
00174
00175 void TextPixmapGlyph::flipPixmap()
00176 {
00177 if (_pixmap == 0)
00178 return;
00179 unsigned char *ptr1 = _pixmap;
00180 unsigned char *ptr2 = _pixmap + _pitch * (_height - 1);
00181 unsigned int x, y;
00182 for (y = _height >> 1; y > 0; --y)
00183 {
00184 for (x = 0; x < _width; ++x)
00185 {
00186 unsigned char h = ptr1[x];
00187 ptr1[x] = ptr2[x];
00188 ptr2[x] = h;
00189 }
00190 ptr1 += _pitch;
00191 ptr2 -= _pitch;
00192 }
00193 }
00194
00195
00196 OSG_END_NAMESPACE
00197
00198
00199
00200
00201
00202 #ifdef OSG_SGI_CC
00203 #pragma set woff 1174
00204 #endif
00205
00206 #ifdef OSG_LINUX_ICC
00207 #pragma warning( disable : 177 )
00208 #endif
00209
00210 namespace
00211 {
00212 static OSG::Char8 cvsid_cpp[] = "@(#)$Id: OSGTextPixmapGlyph.cpp,v 1.1 2005/03/03 13:43:07 a-m-z Exp $";
00213 static OSG::Char8 cvsid_hpp[] = OSGTEXTPIXMAPGLYPH_HEADER_CVSID;
00214 static OSG::Char8 cvsid_inl[] = OSGTEXTPIXMAPGLYPH_INLINE_CVSID;
00215 }
00216
00217 #ifdef __sgi
00218 #pragma reset woff 1174
00219 #endif