ImageHandle.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 <image/ImageHandle.h>
00022 
00023 ImageHandle::ImageHandle() :
00024         owner_(true),
00025         width_(0), height_(0),
00026         alignment_(0), components_(0),
00027         bits_(0)
00028 {
00029 }
00030 
00031 ImageHandle::ImageHandle(const Image &other) :
00032         owner_(true),
00033         width_(((Image &)other).getWidth()), 
00034         height_(((Image &)other).getHeight()),
00035         alignment_(((Image &)other).getAlignment()),
00036         components_(((Image &)other).getComponents()),
00037         bits_(((Image &)other).getBits())
00038 {
00039         ((Image &)other).removeOwnership();
00040 }
00041 
00042 ImageHandle::ImageHandle(const ImageHandle &other) :
00043         owner_(true),
00044         width_(((ImageHandle&)other).getWidth()), 
00045         height_(((ImageHandle&)other).getHeight()),
00046         alignment_(((ImageHandle&)other).getAlignment()),
00047         components_(((ImageHandle&)other).getComponents()),
00048         bits_(((ImageHandle&)other).getBits())
00049 {
00050         ((ImageHandle&)other).removeOwnership();
00051 }
00052 
00053 ImageHandle::~ImageHandle()
00054 {
00055         if (owner_) delete [] bits_;
00056 }
00057 
00058 ImageHandle &ImageHandle::operator=(const ImageHandle &other)
00059 {
00060         if (owner_) delete [] bits_;
00061 
00062         owner_ = true;
00063         width_ = ((ImageHandle &) other).getWidth();
00064         height_ = ((ImageHandle &) other).getHeight();
00065         alignment_ = ((ImageHandle &) other).getAlignment();
00066         components_ = ((ImageHandle &) other).getComponents();
00067         bits_ = ((ImageHandle &) other).getBits();
00068 
00069         ((ImageHandle &) other).removeOwnership();
00070 
00071         return *this;
00072 }
00073 
00074 ImageHandle &ImageHandle::operator=(const Image &other)
00075 {
00076         if (owner_) delete [] bits_;
00077 
00078         owner_ = true;
00079         width_ = ((ImageHandle &) other).getWidth();
00080         height_ = ((ImageHandle &) other).getHeight();
00081         alignment_ = ((ImageHandle &) other).getAlignment();
00082         components_ = ((ImageHandle &) other).getComponents();
00083         bits_ = ((ImageHandle &) other).getBits();
00084 
00085         ((ImageHandle &) other).removeOwnership();
00086 
00087         return *this;
00088 }

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