1/**************************************************************************
2 copyright : (C) 2010 by Anton Sergunov
3 email : setosha@gmail.com
4 **************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef ASFPICTURE_H
27#define ASFPICTURE_H
28
29#include "tstring.h"
30#include "tbytevector.h"
31#include "taglib_export.h"
32#include "attachedpictureframe.h"
33
34namespace TagLib
35{
36 namespace ASF
37 {
38
39 //! An ASF attached picture interface implementation
40
41 /*!
42 * This is an implementation of ASF attached pictures interface. Pictures may be
43 * included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture
44 * attribute in a single tag). These pictures are usually in either JPEG or
45 * PNG format.
46 * \see Attribute::toPicture()
47 * \see Attribute::Attribute(const Picture& picture)
48 */
49 class TAGLIB_EXPORT Picture {
50 public:
51
52 /*!
53 * This describes the function or content of the picture.
54 */
55 enum Type {
56 //! A type not enumerated below
57 Other = 0x00,
58 //! 32x32 PNG image that should be used as the file icon
59 FileIcon = 0x01,
60 //! File icon of a different size or format
61 OtherFileIcon = 0x02,
62 //! Front cover image of the album
63 FrontCover = 0x03,
64 //! Back cover image of the album
65 BackCover = 0x04,
66 //! Inside leaflet page of the album
67 LeafletPage = 0x05,
68 //! Image from the album itself
69 Media = 0x06,
70 //! Picture of the lead artist or soloist
71 LeadArtist = 0x07,
72 //! Picture of the artist or performer
73 Artist = 0x08,
74 //! Picture of the conductor
75 Conductor = 0x09,
76 //! Picture of the band or orchestra
77 Band = 0x0A,
78 //! Picture of the composer
79 Composer = 0x0B,
80 //! Picture of the lyricist or text writer
81 Lyricist = 0x0C,
82 //! Picture of the recording location or studio
83 RecordingLocation = 0x0D,
84 //! Picture of the artists during recording
85 DuringRecording = 0x0E,
86 //! Picture of the artists during performance
87 DuringPerformance = 0x0F,
88 //! Picture from a movie or video related to the track
89 MovieScreenCapture = 0x10,
90 //! Picture of a large, coloured fish
91 ColouredFish = 0x11,
92 //! Illustration related to the track
93 Illustration = 0x12,
94 //! Logo of the band or performer
95 = 0x13,
96 //! Logo of the publisher (record company)
97 = 0x14
98 };
99
100 /*!
101 * Constructs an empty picture.
102 */
103 Picture();
104
105 /*!
106 * Construct an picture as a copy of \a other.
107 */
108 Picture(const Picture& other);
109
110 /*!
111 * Destroys the picture.
112 */
113 virtual ~Picture();
114
115 /*!
116 * Copies the contents of \a other into this picture.
117 */
118 Picture& operator=(const Picture& other);
119
120 /*!
121 * Returns true if Picture stores valid picture
122 */
123 bool isValid() const;
124
125 /*!
126 * Returns the mime type of the image. This should in most cases be
127 * "image/png" or "image/jpeg".
128 * \see setMimeType(const String &)
129 * \see picture()
130 * \see setPicture(const ByteArray&)
131 */
132 String mimeType() const;
133
134 /*!
135 * Sets the mime type of the image. This should in most cases be
136 * "image/png" or "image/jpeg".
137 * \see setMimeType(const String &)
138 * \see picture()
139 * \see setPicture(const ByteArray&)
140 */
141 void setMimeType(const String &value);
142
143 /*!
144 * Returns the type of the image.
145 *
146 * \see Type
147 * \see setType()
148 */
149 Type type() const;
150
151 /*!
152 * Sets the type for the image.
153 *
154 * \see Type
155 * \see type()
156 */
157 void setType(const ASF::Picture::Type& t);
158
159 /*!
160 * Returns a text description of the image.
161 *
162 * \see setDescription()
163 */
164 String description() const;
165
166 /*!
167 * Sets a textual description of the image to \a desc.
168 *
169 * \see description()
170 */
171 void setDescription(const String &desc);
172
173 /*!
174 * Returns the image data as a ByteVector.
175 *
176 * \note ByteVector has a data() method that returns a const char * which
177 * should make it easy to export this data to external programs.
178 *
179 * \see setPicture()
180 * \see mimeType()
181 */
182 ByteVector picture() const;
183
184 /*!
185 * Sets the image data to \a p. \a p should be of the type specified in
186 * this frame's mime-type specification.
187 *
188 * \see picture()
189 * \see mimeType()
190 * \see setMimeType()
191 */
192 void setPicture(const ByteVector &p);
193
194 /*!
195 * Returns picture as binary raw data \a value
196 */
197 ByteVector render() const;
198
199 /*!
200 * Returns picture as binary raw data \a value
201 */
202 int dataSize() const;
203
204#ifndef DO_NOT_DOCUMENT
205 /* THIS IS PRIVATE, DON'T TOUCH IT! */
206 void parse(const ByteVector& );
207 static Picture fromInvalid();
208 friend class Attribute;
209#endif
210 private:
211 class PicturePrivate;
212 PicturePrivate *d;
213 };
214 }
215}
216
217#endif // ASFPICTURE_H
218