GLImageItterator.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <GLEXT/GLImageItterator.h>
00022 
00023 ImageItterator::ImageItterator(Image &bitmap,
00024                                                                         int destX,
00025                                                                         int destY,
00026                                                                         Type type)
00027         : bitmap_(bitmap), type_(type)
00028 {
00029         if (type == stretch)
00030         {
00031                 dx_ = (float) bitmap.getWidth() / (float) destX;
00032                 dy_ = (float) bitmap.getHeight() / (float) destY;
00033         }
00034         else
00035         {
00036                 dx_ = 1;
00037                 dy_ = 1;
00038         }
00039         width_ = 3 * bitmap.getWidth();
00040         width_   = (width_ + 3) & ~3;   
00041 
00042         reset();
00043 }
00044 
00045 ImageItterator::~ImageItterator()
00046 {
00047 
00048 }
00049 
00050 void ImageItterator::reset()
00051 {
00052         posX_ = posY_ = 0.0f;
00053         pos_ = bitmap_.getBits();
00054 }
00055 
00056 void ImageItterator::incX()
00057 {
00058         posX_ += dx_;
00059         if (posX_ >= bitmap_.getWidth()) posX_ = 0.0f;
00060 }
00061 
00062 void ImageItterator::incY()
00063 {
00064         posX_ = 0.0f;
00065         posY_ += dy_;
00066         if (posY_ >= bitmap_.getHeight()) posY_ = 0.0f;
00067         pos_ = (unsigned char *) (bitmap_.getBits() + ((int) posY_  * width_));
00068 }
00069 
00070 unsigned char *ImageItterator::getPos()
00071 {
00072         return pos_ + (int) posX_ * 3;
00073 }

Generated on Mon Feb 16 15:14:44 2009 for Scorched3D by  doxygen 1.5.3