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 * Exchanges the content of the Picture by the content of \a other.
122 */
123 void swap(Picture &other);
124
125 /*!
126 * Returns true if Picture stores valid picture
127 */
128 bool isValid() const;
129
130 /*!
131 * Returns the mime type of the image. This should in most cases be
132 * "image/png" or "image/jpeg".
133 * \see setMimeType(const String &)
134 * \see picture()
135 * \see setPicture(const ByteArray&)
136 */
137 String mimeType() const;
138
139 /*!
140 * Sets the mime type of the image. This should in most cases be
141 * "image/png" or "image/jpeg".
142 * \see setMimeType(const String &)
143 * \see picture()
144 * \see setPicture(const ByteArray&)
145 */
146 void setMimeType(const String &value);
147
148 /*!
149 * Returns the type of the image.
150 *
151 * \see Type
152 * \see setType()
153 */
154 Type type() const;
155
156 /*!
157 * Sets the type for the image.
158 *
159 * \see Type
160 * \see type()
161 */
162 void setType(const ASF::Picture::Type& t);
163
164 /*!
165 * Returns a text description of the image.
166 *
167 * \see setDescription()
168 */
169 String description() const;
170
171 /*!
172 * Sets a textual description of the image to \a desc.
173 *
174 * \see description()
175 */
176 void setDescription(const String &desc);
177
178 /*!
179 * Returns the image data as a ByteVector.
180 *
181 * \note ByteVector has a data() method that returns a const char * which
182 * should make it easy to export this data to external programs.
183 *
184 * \see setPicture()
185 * \see mimeType()
186 */
187 ByteVector picture() const;
188
189 /*!
190 * Sets the image data to \a p. \a p should be of the type specified in
191 * this frame's mime-type specification.
192 *
193 * \see picture()
194 * \see mimeType()
195 * \see setMimeType()
196 */
197 void setPicture(const ByteVector &p);
198
199 /*!
200 * Returns picture as binary raw data \a value
201 */
202 ByteVector render() const;
203
204 /*!
205 * Returns picture as binary raw data \a value
206 */
207 int dataSize() const;
208
209#ifndef DO_NOT_DOCUMENT
210 /* THIS IS PRIVATE, DON'T TOUCH IT! */
211 void parse(const ByteVector& );
212 static Picture fromInvalid();
213#endif
214
215 private:
216 class PicturePrivate;
217 PicturePrivate *d;
218 };
219 }
220}
221
222#endif // ASFPICTURE_H
223