1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
//
// libavg - Media Playback Engine.
// Copyright (C) 2003-2014 Ulrich von Zadow
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Current versions can be found at www.libavg.de
//
#ifndef _Image_H_
#define _Image_H_
#include "../api.h"
#include "MaterialInfo.h"
#include "../base/GLMHelper.h"
#include "../graphics/Bitmap.h"
#include <boost/shared_ptr.hpp>
#include <string>
namespace avg {
class OGLSurface;
class OffscreenCanvas;
typedef boost::shared_ptr<OffscreenCanvas> OffscreenCanvasPtr;
class AVG_API Image
{
public:
enum State {CPU, GPU};
enum Source {NONE, FILE, BITMAP, SCENE};
enum TextureCompression {
TEXTURECOMPRESSION_NONE,
TEXTURECOMPRESSION_B5G6R5
};
Image(OGLSurface * pSurface, const MaterialInfo& material);
virtual ~Image();
virtual void moveToGPU();
virtual void moveToCPU();
void discard();
void setEmpty();
void setFilename(const std::string& sFilename,
TextureCompression comp = TEXTURECOMPRESSION_NONE);
void setBitmap(BitmapPtr pBmp,
TextureCompression comp = TEXTURECOMPRESSION_NONE);
void setCanvas(OffscreenCanvasPtr pCanvas);
OffscreenCanvasPtr getCanvas() const;
const std::string& getFilename() const;
BitmapPtr getBitmap();
IntPoint getSize();
PixelFormat getPixelFormat();
OGLSurface* getSurface();
State getState();
Source getSource();
static TextureCompression string2compression(const std::string& s);
static std::string compression2String(TextureCompression compression);
private:
void setupSurface();
bool changeSource(Source newSource);
void assertValid() const;
std::string m_sFilename;
BitmapPtr m_pBmp;
OGLSurface * m_pSurface;
OffscreenCanvasPtr m_pCanvas;
State m_State;
Source m_Source;
MaterialInfo m_Material;
};
typedef boost::shared_ptr<Image> ImagePtr;
}
#endif
|