~ubuntu-branches/debian/lenny/exiv2/lenny

« back to all changes in this revision

Viewing changes to src/jp2image.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-06-21 08:23:53 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080621082353-b1n4w08trwfwbfl4
Tags: 0.17.1-1
* New upstream release
  - Library transition cleared on debian-release/ d-d-a
* Version 0.17 also fixes:
  - CVE-2008-2696: DoS via metadata in images (Closes: #486328)
  - crashes when fed with wrong file (Closes: #485670)
* Urgency medium for CVE fix
* debian/patches/gcc4.3.diff unecessary for gcc-4.3
* Add /usr/share/bug/exiv2/presubj message for reportbug(1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ***************************************************************** -*- C++ -*-
 
2
/*
 
3
 * Copyright (C) 2004-2008 Andreas Huggel <ahuggel@gmx.net>
 
4
 *
 
5
 * This program is part of the Exiv2 distribution.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
 
20
 */
 
21
/*!
 
22
  @file    jp2image.hpp
 
23
  @brief   JPEG-2000 image, implemented using the following references:
 
24
           <a href="http://jpeg.org/public/fcd15444-6.pdf">ISO/IEC JTC 1/SC 29/WG1 N2401: JPEG 2000 Part 6 FCD 15444-6</a><br>
 
25
  @version $Rev: 1422 $
 
26
  @author  Marco Piovanelli, Ovolab (marco)
 
27
           <a href="mailto:marco.piovanelli@pobox.com">marco.piovanelli@pobox.com</a>
 
28
  @date    12-Mar-2007, marco: created
 
29
 */
 
30
#ifndef JP2IMAGE_HPP_
 
31
#define JP2IMAGE_HPP_
 
32
 
 
33
// *****************************************************************************
 
34
// included header files
 
35
#include "exif.hpp"
 
36
#include "iptc.hpp"
 
37
#include "image.hpp"
 
38
 
 
39
// + standard includes
 
40
#include <string>
 
41
 
 
42
// *****************************************************************************
 
43
// namespace extensions
 
44
namespace Exiv2 {
 
45
 
 
46
// *****************************************************************************
 
47
// class definitions
 
48
 
 
49
    // Add JPEG-2000 to the supported image formats
 
50
    namespace ImageType {
 
51
        const int jp2 = 15;                     //!< JPEG-2000 image type
 
52
    }
 
53
 
 
54
    /*!
 
55
      @brief Class to access JPEG-2000 images.
 
56
     */
 
57
    class Jp2Image : public Image {
 
58
        //! @name NOT Implemented
 
59
        //@{
 
60
        //! Copy constructor
 
61
        Jp2Image(const Jp2Image& rhs);
 
62
        //! Assignment operator
 
63
        Jp2Image& operator=(const Jp2Image& rhs);
 
64
        //@}
 
65
 
 
66
    public:
 
67
        //! @name Creators
 
68
        //@{
 
69
        /*!
 
70
          @brief Constructor to open a JPEG-2000 image. Since the
 
71
              constructor can not return a result, callers should check the
 
72
              good() method after object construction to determine success
 
73
              or failure.
 
74
          @param io An auto-pointer that owns a BasicIo instance used for
 
75
              reading and writing image metadata. \b Important: The constructor
 
76
              takes ownership of the passed in BasicIo instance through the
 
77
              auto-pointer. Callers should not continue to use the BasicIo
 
78
              instance after it is passed to this method.  Use the Image::io()
 
79
              method to get a temporary reference.
 
80
         */
 
81
        Jp2Image(BasicIo::AutoPtr io);
 
82
        //@}
 
83
 
 
84
        //! @name Manipulators
 
85
        //@{
 
86
        void readMetadata();
 
87
        /*!
 
88
          @brief Todo: Write metadata back to the image. This method is not
 
89
              yet implemented. Calling it will throw an Error(31).
 
90
         */
 
91
        void writeMetadata();
 
92
        /*!
 
93
          @brief Todo: Not supported yet. Calling this function will throw
 
94
              an instance of Error(32).
 
95
         */
 
96
        void setExifData(const ExifData& exifData);
 
97
        /*!
 
98
          @brief Todo: Not supported yet. Calling this function will throw
 
99
              an instance of Error(32).
 
100
         */
 
101
        void setIptcData(const IptcData& iptcData);
 
102
        /*!
 
103
          @brief Todo: Not supported yet(?). Calling this function will throw
 
104
              an instance of Error(32).
 
105
         */
 
106
        void setComment(const std::string& comment);
 
107
        //@}
 
108
 
 
109
        //! @name Accessors
 
110
        //@{
 
111
        std::string mimeType() const { return "image/jp2"; }
 
112
        //@}
 
113
 
 
114
    }; // class Jp2Image
 
115
 
 
116
// *****************************************************************************
 
117
// template, inline and free functions
 
118
 
 
119
    // These could be static private functions on Image subclasses but then
 
120
    // ImageFactory needs to be made a friend.
 
121
    /*!
 
122
      @brief Create a new Jp2Image instance and return an auto-pointer to it.
 
123
             Caller owns the returned object and the auto-pointer ensures that
 
124
             it will be deleted.
 
125
     */
 
126
    Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create);
 
127
 
 
128
    //! Check if the file iIo is a JPEG-2000 image.
 
129
    bool isJp2Type(BasicIo& iIo, bool advance);
 
130
 
 
131
}                                       // namespace Exiv2
 
132
 
 
133
#endif                                  // #ifndef JP2IMAGE_HPP_