OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimGdBitmapFont Class Reference

#include <ossimGdBitmapFont.h>

Inheritance diagram for ossimGdBitmapFont:
ossimFont ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

 ossimGdBitmapFont (const ossimString &familyName, const ossimString &styleName, const ossimGdFont *gdFontPtr)
 
 ossimGdBitmapFont (const ossimGdBitmapFont &rhs)
 
virtual ~ossimGdBitmapFont ()
 
virtual ossimObjectdup () const
 
virtual const ossim_uint8getBuf () const
 
virtual const ossim_uint8rasterize ()
 
virtual void getBoundingBox (ossimIrect &box)
 
bool isFixed () const
 
virtual void getFixedSizes (vector< ossimIpt > &sizes) const
 
- Public Member Functions inherited from ossimFont
 ossimFont ()
 
 ossimFont (const ossimString &familyName, const ossimString &styleName, int horizontalPixelSize, int verticalPixelSize, int horizontalDeviceUnits=72, int verticalDeviceUnits=72)
 
 ossimFont (const ossimFont &rhs)
 
virtual const ossim_uint8rasterize (const ossimString &s)
 
virtual void setString (const ossimString &s)
 
virtual ossimString getFamilyName () const
 
virtual ossimString getStyleName () const
 
virtual void setRotation (double rotationInDegrees)
 
virtual double getRotation () const
 
virtual void getRotation (double &rotation) const
 
virtual void setHorizontalVerticalShear (double horizontalShear, double verticalShear)
 
virtual void setVerticalShear (double verticalShear)
 
virtual void setHorizontalShear (double horizontalShear)
 
virtual double getVerticalShear () const
 
virtual double getHorizontalShear () const
 
virtual void setScale (double horizontal, double vertical)
 
virtual void getScale (double &horizontal, double &vertical)
 
virtual void setPixelSize (int horizontalPixelSize, int verticalPixelSize)
 
virtual void setPixelSize (int pixelSize)
 
virtual void getPixelSize (int &horizontal, int &vertical)
 
virtual long getHorizontalPixelSize () const
 
virtual ossimIpt getPixelSize () const
 
virtual long getVerticalPixelSize () const
 
virtual void setDeviceDpi (int horizontalDeviceUnits, int verticalDeviceUnits)
 
virtual void getBufferRect (ossimIrect &bufRect)
 
virtual ossimIrect getBufferRect ()
 
virtual void getBoundingClipBox (ossimIrect &clippedBox)
 
virtual ossimIrect getBoundingClipBox ()
 
virtual void setClippingBox (const ossimIrect &clipBox=ossimIrect(0, 0, 0, 0))
 
virtual ossimIrect getClippingBox () const
 
bool isIdentityTransform () const
 
virtual void getFontInformation (vector< ossimFontInformation > &fontInformationList) const
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 

Protected Member Functions

void getActualScale (ossimDpt &scales) const
 
void rasterizeNormal ()
 
void allocateBuffer ()
 
- Protected Member Functions inherited from ossimFont
virtual ~ossimFont ()
 
void computeMatrix ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

const ossimGdFonttheGdFontPtr
 
long theBufferSize
 
ossim_uint8theOutputBuffer
 
- Protected Attributes inherited from ossimFont
ossimString theStringToRasterize
 
ossimString theFamilyName
 
ossimString theStyleName
 
double theRotation
 
double theHorizontalShear
 
double theVerticalShear
 
double theHorizontalScale
 
double theVerticalScale
 
int theHorizontalPixelSize
 
int theVerticalPixelSize
 
int theHorizontalDeviceUnits
 
int theVerticalDeviceUnits
 
ossimIrect theClippingBox
 
ossimIpt theLocalOrigin
 
NEWMAT::Matrix theAffineTransform
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

This is a wrapper for the gd library fonts. Note that this class will currently only support scaling. It will not support any other affine operation.

Definition at line 35 of file ossimGdBitmapFont.h.

Constructor & Destructor Documentation

◆ ossimGdBitmapFont() [1/2]

ossimGdBitmapFont::ossimGdBitmapFont ( const ossimString familyName,
const ossimString styleName,
const ossimGdFont gdFontPtr 
)

Definition at line 15 of file ossimGdBitmapFont.cpp.

Referenced by dup().

18  :ossimFont(familyName,
19  styleName,
20  (int)gdFontPtr->w,
21  (int)gdFontPtr->h),
22  theGdFontPtr(gdFontPtr),
23  theBufferSize(0),
24  theOutputBuffer(NULL)
25 {
26 }
ossimFont()
Definition: ossimFont.h:28
ossim_uint8 * theOutputBuffer
const ossimGdFont * theGdFontPtr

◆ ossimGdBitmapFont() [2/2]

ossimGdBitmapFont::ossimGdBitmapFont ( const ossimGdBitmapFont rhs)

Definition at line 28 of file ossimGdBitmapFont.cpp.

References theBufferSize, and theOutputBuffer.

29  :ossimFont(rhs),
32  theOutputBuffer(NULL)
33 {
34  if(theBufferSize)
35  {
38  }
39 }
ossimFont()
Definition: ossimFont.h:28
ossim_uint8 * theOutputBuffer
const ossimGdFont * theGdFontPtr
unsigned char ossim_uint8

◆ ~ossimGdBitmapFont()

ossimGdBitmapFont::~ossimGdBitmapFont ( )
virtual

Definition at line 41 of file ossimGdBitmapFont.cpp.

References theOutputBuffer.

42 {
43  if(theOutputBuffer)
44  {
45  delete [] theOutputBuffer;
46  theOutputBuffer = NULL;
47  }
48 }
ossim_uint8 * theOutputBuffer

Member Function Documentation

◆ allocateBuffer()

void ossimGdBitmapFont::allocateBuffer ( )
protected

Definition at line 222 of file ossimGdBitmapFont.cpp.

References getBoundingBox(), ossimIrect::height(), theBufferSize, theOutputBuffer, and ossimIrect::width().

Referenced by rasterize().

223 {
224  ossimIrect box;
225 
226  getBoundingBox(box);
227  long bufferSize = box.width()*box.height();
228  if(bufferSize != theBufferSize)
229  {
230  theBufferSize = bufferSize;
231 
232  if(theOutputBuffer)
233  {
234  delete theOutputBuffer;
235  theOutputBuffer = NULL;
236  }
238  {
240 
241  }
242  }
243 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossim_uint8 * theOutputBuffer
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual void getBoundingBox(ossimIrect &box)
unsigned char ossim_uint8

◆ dup()

virtual ossimObject* ossimGdBitmapFont::dup ( ) const
inlinevirtual

Implements ossimFont.

Definition at line 46 of file ossimGdBitmapFont.h.

References ossimGdBitmapFont().

47  {
48  return new ossimGdBitmapFont(*this);
49  }
ossimGdBitmapFont(const ossimString &familyName, const ossimString &styleName, const ossimGdFont *gdFontPtr)

◆ getActualScale()

void ossimGdBitmapFont::getActualScale ( ossimDpt scales) const
protected

This will take into consideration the point size along the horizontal and vertical and also the scale values. So the actual scale will be:

Scale*(pointSize/fixedSize);

◆ getBoundingBox()

void ossimGdBitmapFont::getBoundingBox ( ossimIrect box)
virtual

Will return the bounding box of the last string that was set to be rasterized in pixel space

Implements ossimFont.

Definition at line 50 of file ossimGdBitmapFont.cpp.

References ossimGdFont::h, ossimIrect::ll(), ossimIrect::lr(), max, min, ossimString::size(), ossimFont::theAffineTransform, theGdFontPtr, ossimFont::theHorizontalPixelSize, ossimFont::theHorizontalScale, ossimFont::theRotation, ossimFont::theStringToRasterize, ossimFont::theVerticalPixelSize, ossimFont::theVerticalScale, ossimIrect::ur(), ossimGdFont::w, ossimIpt::x, and ossimIpt::y.

Referenced by allocateBuffer(), and rasterizeNormal().

51 {
53  {
54  box = ossimIrect(0,0,
57  }
58  else
59  {
60  box = ossimIrect(0,
61  0,
62  0,
63  0);
64  }
65 
66  // I currently don't support rotations and other affine operations so I will comment this
67  // bounding box test out and use the above.
68  //
69 #if 0
70  if(theGdFontPtr)
71  {
72  if((theRotation == 0.0)&&
73  (theHorizontalScale == 1.0)&&
74  (theVerticalScale == 1.0))
75  {
76  box = ossimIrect(0,0, theGdFontPtr->w-1, theGdFontPtr->h-1);
77  }
78  else
79  {
80  ossimIrect localBox(0,0, theGdFontPtr->w-1, theGdFontPtr->h-1);
81  double ulx, uly;
82  double llx, lly;
83  double lrx, lry;
84  double urx, ury;
85 
86  double min_x, min_y, max_x, max_y;
87 
88  ulx = 0.0;
89  uly = 0.0;
90 
91  llx = (theAffineTransform[0][0]*localBox.ll().x +
92  theAffineTransform[0][1]*localBox.ll().y);
93  lly = theAffineTransform[1][0]*localBox.ll().x +
94  theAffineTransform[1][1]*localBox.ll().y;
95 
96  lrx = (theAffineTransform[0][0]*localBox.lr().x +
97  theAffineTransform[0][1]*localBox.lr().y);
98  lry = theAffineTransform[1][0]*localBox.lr().x +
99  theAffineTransform[1][1]*localBox.lr().y;
100  urx = (theAffineTransform[0][0]*localBox.ur().x +
101  theAffineTransform[0][1]*localBox.ur().y);
102  ury = theAffineTransform[1][0]*localBox.ur().x +
103  theAffineTransform[1][1]*localBox.ur().y;
104 
105 
106  min_x = std::min(ulx, std::min(llx, (std::min(lrx, urx))));
107  max_x = std::max(ulx, std::max(llx, (std::max(lrx, urx))));
108 
109  min_y = std::min(uly, std::min(lly, (std::min(lry, ury))));
110  max_y = std::max(uly, std::max(lly, (std::max(lry, ury))));
111 
112 
113 
114  box = ossimIrect((int)floor(min_x), (int)floor(min_y),
115  (int)ceil(max_x), (int)ceil(max_y));
116  }
117  }
118 #endif
119 }
ossimString theStringToRasterize
Definition: ossimFont.h:292
double theRotation
Definition: ossimFont.h:295
NEWMAT::Matrix theAffineTransform
Definition: ossimFont.h:314
double theVerticalScale
Definition: ossimFont.h:299
std::string::size_type size() const
Definition: ossimString.h:405
const ossimGdFont * theGdFontPtr
#define max(a, b)
Definition: auxiliary.h:76
int theHorizontalPixelSize
Definition: ossimFont.h:300
#define min(a, b)
Definition: auxiliary.h:75
int theVerticalPixelSize
Definition: ossimFont.h:301
double theHorizontalScale
Definition: ossimFont.h:298

◆ getBuf()

virtual const ossim_uint8* ossimGdBitmapFont::getBuf ( ) const
inlinevirtual

Will return the previously rasterized buffer.

Implements ossimFont.

Definition at line 50 of file ossimGdBitmapFont.h.

References theOutputBuffer.

51  {
52  return theOutputBuffer;
53  }
ossim_uint8 * theOutputBuffer

◆ getFixedSizes()

void ossimGdBitmapFont::getFixedSizes ( vector< ossimIpt > &  sizes) const
virtual

You can get a list of fixed sizes supported by this font.

Implements ossimFont.

Definition at line 245 of file ossimGdBitmapFont.cpp.

References ossimFont::theHorizontalPixelSize, and ossimFont::theVerticalPixelSize.

246 {
247  sizes.push_back(ossimIpt(theHorizontalPixelSize,
249 }
int theHorizontalPixelSize
Definition: ossimFont.h:300
int theVerticalPixelSize
Definition: ossimFont.h:301

◆ isFixed()

bool ossimGdBitmapFont::isFixed ( ) const
inlinevirtual

Returns true if this font is a fixed size font

Implements ossimFont.

Definition at line 59 of file ossimGdBitmapFont.h.

60  {
61  return true;
62  }

◆ rasterize()

const ossim_uint8 * ossimGdBitmapFont::rasterize ( )
virtual

Will return an internal buffer for rasterizing and will

Implements ossimFont.

Definition at line 121 of file ossimGdBitmapFont.cpp.

References allocateBuffer(), rasterizeNormal(), theBufferSize, and theOutputBuffer.

122 {
123  // make sure the buffer is allocated for the output string
124  allocateBuffer();
125 
126  if(theOutputBuffer)
127  {
128  memset(theOutputBuffer, 0, theBufferSize);
129  rasterizeNormal();
130  }
131 
132  return theOutputBuffer;
133 }
ossim_uint8 * theOutputBuffer

◆ rasterizeNormal()

void ossimGdBitmapFont::rasterizeNormal ( )
protected

Definition at line 135 of file ossimGdBitmapFont.cpp.

References ossimGdFont::data, getBoundingBox(), ossimGdFont::h, ossimIrect::height(), ossimString::length(), ossimString::size(), theGdFontPtr, theOutputBuffer, ossimFont::theStringToRasterize, ossimGdFont::w, and ossimIrect::width().

Referenced by rasterize().

136 {
137  ossimIrect outBox;
138  ossimIrect inBox(0,0,
140  theGdFontPtr->h-1);
141 
142  getBoundingBox(outBox);
143 
144 
145  long charOffset = 0;
146  long bufOffset = 0;
147  long inW = inBox.width();
148  long inH = inBox.height();
149  long outW = outBox.width();
150  long outH = outBox.height();
151  ossim_uint8* inBuf = new ossim_uint8[inBox.width()*inBox.height()];
152 
153  for(std::string::size_type character = 0;
154  character < theStringToRasterize.size();
155  ++character)
156  {
157  charOffset = theStringToRasterize[character];
158 
159  // we need to shift the offset to a positive value.
160  // if it goes negative we just add 256 to the value.
161  if(charOffset < 0)
162  {
163  charOffset += 256;
164  }
165 
166  // which col do we start on
167  bufOffset = (long)character*theGdFontPtr->w;
168 
169  // get the starting offset to the bitmap
170  charOffset = charOffset*theGdFontPtr->w*theGdFontPtr->h;
171 
172  for(long row = 0; row < (theGdFontPtr->h); ++row)
173  {
174  for(long col = 0; col < theGdFontPtr->w; ++col)
175  {
176  if(theGdFontPtr->data[charOffset])
177  {
178  inBuf[bufOffset+col] = 255;
179  }
180  ++charOffset;
181  }
182  bufOffset += inW;
183  }
184  }
185 
186  if((inW == outW)&&(inH==outH))
187  {
188  memcpy(theOutputBuffer, inBuf, inW*inH);
189  }
190  else
191  {
192  // now lets expand or contract the input buf to the output buf.
193  long *xLut = new long[outW];
194  long *yLut = new long[outH];
195  long i = 0;
196  for(i = 0; i < outW; ++i)
197  {
198  xLut[i] = (int)(i*((double)inW/(double)outW));
199  }
200  for(i = 0; i < outH; ++i)
201  {
202  yLut[i] = (int)(i*((double)inH/(double)outH));
203  }
204 
205  ossim_uint8* outBuf = theOutputBuffer;
206  for(long row= 0; row < outH; ++row)
207  {
208  long inYOffset = yLut[row]*inW;
209  for(long col=0; col < outW; ++col)
210  {
211  *outBuf = inBuf[inYOffset + xLut[col]];
212  ++outBuf;
213  }
214  }
215  delete [] xLut;
216  delete [] yLut;
217  }
218 
219  delete [] inBuf;
220 }
ossimString theStringToRasterize
Definition: ossimFont.h:292
ossim_uint32 height() const
Definition: ossimIrect.h:487
std::string::size_type length() const
Definition: ossimString.h:408
std::string::size_type size() const
Definition: ossimString.h:405
ossim_uint8 * theOutputBuffer
ossim_uint32 width() const
Definition: ossimIrect.h:500
const ossimGdFont * theGdFontPtr
virtual void getBoundingBox(ossimIrect &box)
unsigned char ossim_uint8
int ossim_int32

Member Data Documentation

◆ theBufferSize

long ossimGdBitmapFont::theBufferSize
protected

Definition at line 69 of file ossimGdBitmapFont.h.

Referenced by allocateBuffer(), ossimGdBitmapFont(), and rasterize().

◆ theGdFontPtr

const ossimGdFont* ossimGdBitmapFont::theGdFontPtr
protected

Definition at line 67 of file ossimGdBitmapFont.h.

Referenced by getBoundingBox(), and rasterizeNormal().

◆ theOutputBuffer

ossim_uint8* ossimGdBitmapFont::theOutputBuffer
protected

The documentation for this class was generated from the following files: