Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShImage.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHIMAGE_HPP
00021 #define SHIMAGE_HPP
00022 
00023 #include <string>
00024 #include "ShDllExport.hpp"
00025 #include "ShRefCount.hpp"
00026 #include "ShMemory.hpp"
00027 
00028 namespace SH {
00029 
00035 class
00036 SH_DLLEXPORT ShImage : public ShRefCountable {
00037 public:
00038   ShImage(); 
00039   ShImage(int width, int height, int depth); 
00040 
00041   ShImage(const ShImage& other); 
00042 
00043   ~ShImage();
00044 
00045   ShImage& operator=(const ShImage& other); 
00046 
00047 
00048   int width() const; 
00049   int height() const; 
00050   int elements() const; 
00051 
00052 
00053   float operator()(int x, int y, int i) const; 
00054 
00055 
00056   float& operator()(int x, int y, int i);  
00057 
00058 
00059 
00065   void load_PNG(const std::string& filename) { loadPng(filename); }
00066   void loadPng(const std::string& filename); 
00067 
00068   
00069   void savePng(const std::string& filename, int inverse_alpha=0);
00070 
00071   
00072   void savePng16(const std::string& filename, int inverse_alpha=0);
00073  
00074   ShImage getNormalImage();
00075 
00076   const float* data() const;
00077   float* data();
00078   
00079   void dirty();
00080   ShMemoryPtr memory();
00081   ShPointer<const ShMemory> memory() const;
00082   
00083 private:
00084   int m_width, m_height;
00085   int m_elements;
00086   ShHostMemoryPtr m_memory;
00087 };
00088 
00089 }
00090 
00091 #endif

Generated on Thu Jul 28 17:33:02 2005 for Sh by  doxygen 1.4.3-20050530