Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/egg-mkfont/charBitmap.cxx

Go to the documentation of this file.
00001 // Filename: charBitmap.cxx
00002 // Created by:  drose (16Feb01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "charBitmap.h"
00020 
00021 #include <notify.h>
00022 
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: CharBitmap::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 CharBitmap::
00030 CharBitmap(int character, int width, int height,
00031            int hoff, int voff, double dx, double dy) {
00032   _character = character;
00033   _hoff = hoff;
00034   _voff = voff;
00035   _dx = dx;
00036   _dy = dy;
00037 
00038   for (int y = 0; y < height; y++) {
00039     _block.push_back(Row(width));
00040   }
00041 
00042   _x = 0;
00043   _y = 0;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: CharBitmap::paint
00048 //       Access: Public
00049 //  Description: Paints a string of same-color pixels into the bitmap.
00050 //               This is called repeatedly by the rle decoder.
00051 //               Returns true when the last pixel has been painted,
00052 //               false if there is more to go.
00053 ////////////////////////////////////////////////////////////////////
00054 bool CharBitmap::
00055 paint(bool black, int num_pixels, int &repeat) {
00056   if (_y < _block.size()) {
00057     while (num_pixels > 0 && _y < _block.size()) {
00058       nassertr(_x < _block[_y].size(), true);
00059       _block[_y][_x] = black;
00060       _x++;
00061       if (_x >= _block[_y].size()) {
00062         // End of a row.
00063         _x = 0;
00064         _y++;
00065         while (repeat > 0 && _y < _block.size()) {
00066           _block[_y] = _block[_y-1];
00067           _y++;
00068           repeat--;
00069         }
00070       }
00071       num_pixels--;
00072     }
00073   }
00074 
00075   return (_y < _block.size());
00076 }

Generated on Fri May 2 03:17:05 2003 for Panda-Tool by doxygen1.3