root/OpenSceneGraph/trunk/examples/osgphotoalbum/PhotoArchive.h @ 5328

Revision 5328, 2.7 kB (checked in by robert, 8 years ago)

Updated copyright years.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This application is open source and may be redistributed and/or modified under 
4 * the terms of the GNU Public License (GPL) version 1.0 or
5 * (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * OpenSceneGraph Public License for more details.
11*/
12
13#ifndef PHOTOARCHIVE_H
14#define PHOTOARCHIVE_H
15
16#include <osg/Image>
17
18class PhotoArchive : public osg::Referenced
19{
20public:
21
22    static PhotoArchive* open(const std::string& filename)
23    {
24        osg::ref_ptr<PhotoArchive> archive = new PhotoArchive(filename);
25        if (!archive->empty()) return archive.release();
26        else return 0;
27    }
28
29    typedef std::vector<std::string> FileNameList;
30   
31    bool empty() { return _photoIndex.empty(); }
32
33    void getImageFileNameList(FileNameList& filenameList);
34   
35    static void buildArchive(const std::string& filename, const FileNameList& imageList, unsigned int thumbnailSize=256, unsigned int maximumSize=1024, bool compressed=true);
36
37    osg::Image* readImage(const std::string& filename,
38                          unsigned int target_s, unsigned target_t,
39                          float& original_s, float& original_t);
40                         
41   
42   
43protected:
44
45    PhotoArchive(const std::string& filename);
46
47    virtual ~PhotoArchive() {}
48
49    bool readPhotoIndex(const std::string& filename);
50   
51    struct PhotoHeader
52    {
53        PhotoHeader():
54            original_s(0),
55            original_t(0),
56            thumbnail_s(0),
57            thumbnail_t(0),
58            thumbnail_position(0),
59            fullsize_s(0),
60            fullsize_t(0),
61            fullsize_position(0)
62        {
63            filename[0]='\0';
64        }
65   
66        char filename[256];
67        unsigned int original_s;
68        unsigned int original_t;
69
70        unsigned int thumbnail_s;
71        unsigned int thumbnail_t;
72        unsigned int thumbnail_position;
73
74        unsigned int fullsize_s;
75        unsigned int fullsize_t;
76        unsigned int fullsize_position;
77    };
78
79   
80    struct ImageHeader
81    {
82        ImageHeader():
83            s(0),
84            t(0),
85            internalTextureformat(0),
86            pixelFormat(0),
87            type(0),
88            size(0) {}
89   
90        unsigned int s;
91        unsigned int t;
92        GLint internalTextureformat;
93        GLenum pixelFormat;
94        GLenum type;
95        unsigned int size;
96    };
97
98
99    typedef std::vector<PhotoHeader> PhotoIndexList;
100
101    std::string     _archiveFileName;
102    PhotoIndexList  _photoIndex;   
103
104};
105
106#endif
Note: See TracBrowser for help on using the browser.