~ubuntu-branches/ubuntu/wily/kid3/wily-proposed

« back to all changes in this revision

Viewing changes to kid3/pictureframe.cpp

  • Committer: Package Import Robot
  • Author(s): Ana Beatriz Guerrero Lopez, Patrick Matthäi, Ana Beatriz Guerrero Lopez
  • Date: 2011-11-13 16:34:13 UTC
  • mfrom: (1.1.13) (2.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20111113163413-5y0anlc4dqf511uh
Tags: 2.0.1-1
* New upstream release.

[ Patrick Matthäi ]
* Adjust build system.
* Add build dependency xsltproc.

[ Ana Beatriz Guerrero Lopez ]
* Some more adjustments to the build system taken from upstream's deb/
* directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \file pictureframe.cpp
3
 
 * Frame containing picture.
4
 
 *
5
 
 * \b Project: Kid3
6
 
 * \author Urs Fleisch
7
 
 * \date 03 Mar 2008
8
 
 *
9
 
 * Copyright (C) 2008-2009  Urs Fleisch
10
 
 *
11
 
 * This file is part of Kid3.
12
 
 *
13
 
 * Kid3 is free software; you can redistribute it and/or modify
14
 
 * it under the terms of the GNU General Public License as published by
15
 
 * the Free Software Foundation; either version 2 of the License, or
16
 
 * (at your option) any later version.
17
 
 *
18
 
 * Kid3 is distributed in the hope that it will be useful,
19
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
 * GNU General Public License for more details.
22
 
 *
23
 
 * You should have received a copy of the GNU General Public License
24
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
 */
26
 
 
27
 
#include "pictureframe.h"
28
 
#include <qfile.h>
29
 
#include <qimage.h>
30
 
#include <qbuffer.h>
31
 
#if QT_VERSION < 0x040000 && defined CONFIG_USE_KDE
32
 
#include <kmdcodec.h>
33
 
#endif
34
 
#include "qtcompatmac.h"
35
 
 
36
 
/**
37
 
 * Constructor.
38
 
 *
39
 
 * @param data        binary picture data
40
 
 * @param description description
41
 
 * @param pictureType picture type
42
 
 * @param mimeType    MIME type
43
 
 * @param enc         text encoding
44
 
 * @param imgFormat   image format
45
 
 */
46
 
PictureFrame::PictureFrame(
47
 
        const QByteArray& data,
48
 
        const QString& description,
49
 
        PictureType pictureType,
50
 
        const QString& mimeType,
51
 
        Field::TextEncoding enc,
52
 
        const QString& imgFormat)
53
 
{
54
 
        setType(FT_Picture);
55
 
        setFields(*this, enc, imgFormat, mimeType, pictureType, description, data);
56
 
}
57
 
 
58
 
/**
59
 
 * Constructor.
60
 
 *
61
 
 * @param frame general frame
62
 
 */
63
 
PictureFrame::PictureFrame(const Frame& frame)
64
 
{
65
 
        *(static_cast<Frame*>(this)) = frame;
66
 
        setType(FT_Picture);
67
 
 
68
 
        // Make sure all fields are available in the correct order
69
 
        Field::TextEncoding enc = Field::TE_ISO8859_1;
70
 
        PictureType pictureType = PT_CoverFront;
71
 
        QString imgFormat("JPG"), mimeType("image/jpeg"), description;
72
 
        QByteArray data;
73
 
        getFields(*this, enc, imgFormat, mimeType, pictureType, description, data);
74
 
        setFields(*this, enc, imgFormat, mimeType, pictureType, description, data);
75
 
}
76
 
 
77
 
/**
78
 
 * Destructor.
79
 
 */
80
 
PictureFrame::~PictureFrame()
81
 
{
82
 
}
83
 
 
84
 
/**
85
 
 * Set all properties.
86
 
 *
87
 
 * @param frame       frame to set
88
 
 * @param enc         text encoding
89
 
 * @param imgFormat   image format
90
 
 * @param mimeType    MIME type
91
 
 * @param pictureType picture type
92
 
 * @param description description
93
 
 * @param data        binary picture data
94
 
 */
95
 
void PictureFrame::setFields(Frame& frame,
96
 
                                                                                                                 Field::TextEncoding enc, const QString& imgFormat,
97
 
                                                                                                                 const QString& mimeType, PictureType pictureType,
98
 
                                                                                                                 const QString& description, const QByteArray& data)
99
 
{
100
 
        Field field;
101
 
        FieldList& fields = frame.fieldList();
102
 
        fields.clear();
103
 
 
104
 
        field.m_id = Field::ID_TextEnc;
105
 
        field.m_value = enc;
106
 
        fields.push_back(field);
107
 
 
108
 
        field.m_id = Field::ID_ImageFormat;
109
 
        field.m_value = imgFormat;
110
 
        fields.push_back(field);
111
 
 
112
 
        field.m_id = Field::ID_MimeType;
113
 
        field.m_value = mimeType;
114
 
        fields.push_back(field);
115
 
 
116
 
        field.m_id = Field::ID_PictureType;
117
 
        field.m_value = pictureType;
118
 
        fields.push_back(field);
119
 
 
120
 
        field.m_id = Field::ID_Description;
121
 
        field.m_value = description;
122
 
        fields.push_back(field);
123
 
 
124
 
        field.m_id = Field::ID_Data;
125
 
        field.m_value = data;
126
 
        fields.push_back(field);
127
 
 
128
 
        frame.setValue(description);
129
 
}
130
 
 
131
 
/**
132
 
 * Get all properties.
133
 
 * Unavailable fields are not set.
134
 
 *
135
 
 * @param frame       frame to get
136
 
 * @param enc         text encoding
137
 
 * @param imgFormat   image format
138
 
 * @param mimeType    MIME type
139
 
 * @param pictureType picture type
140
 
 * @param description description
141
 
 * @param data        binary picture data
142
 
 */
143
 
void PictureFrame::getFields(const Frame& frame,
144
 
                                                                                                                 Field::TextEncoding& enc, QString& imgFormat,
145
 
                                                                                                                 QString& mimeType, PictureType& pictureType,
146
 
                                                                                                                 QString& description, QByteArray& data)
147
 
{
148
 
        for (Frame::FieldList::const_iterator it = frame.getFieldList().begin();
149
 
                         it != frame.getFieldList().end();
150
 
                         ++it) {
151
 
                switch ((*it).m_id) {
152
 
                        case Field::ID_TextEnc:
153
 
                                enc = static_cast<Field::TextEncoding>((*it).m_value.toInt());
154
 
                                break;
155
 
                        case Field::ID_ImageFormat:
156
 
                                imgFormat = (*it).m_value.toString();
157
 
                                break;
158
 
                        case Field::ID_MimeType:
159
 
                                mimeType = (*it).m_value.toString();
160
 
                                break;
161
 
                        case Field::ID_PictureType:
162
 
                                pictureType = static_cast<PictureType>((*it).m_value.toInt());
163
 
                                break;
164
 
                        case Field::ID_Description:
165
 
                                description = (*it).m_value.toString();
166
 
                                break;
167
 
                        case Field::ID_Data:
168
 
                                data = (*it).m_value.toByteArray();
169
 
                                break;
170
 
                        default:
171
 
                                qDebug("Unknown picture field ID");
172
 
                }
173
 
        }
174
 
}
175
 
 
176
 
/**
177
 
 * Set value of a field.
178
 
 *
179
 
 * @param frame frame to set
180
 
 * @param id    field ID
181
 
 * @param value field value
182
 
 *
183
 
 * @return true if field found and set.
184
 
 */
185
 
bool PictureFrame::setField(Frame& frame, Field::Id id, const QVariant& value)
186
 
{
187
 
        for (Frame::FieldList::iterator it = frame.fieldList().begin();
188
 
                         it != frame.fieldList().end();
189
 
                         ++it) {
190
 
                if ((*it).m_id == id) {
191
 
                        (*it).m_value = value;
192
 
                        if (id == Field::ID_Description) frame.setValue(value.toString());
193
 
                        return true;
194
 
                }
195
 
        }
196
 
        return false;
197
 
}
198
 
 
199
 
/**
200
 
 * Get value of a field.
201
 
 *
202
 
 * @param frame frame to get
203
 
 * @param id    field ID
204
 
 *
205
 
 * @return field value, invalid if not found.
206
 
 */
207
 
QVariant PictureFrame::getField(const Frame& frame, Field::Id id)
208
 
{
209
 
        QVariant result;
210
 
        if (!frame.getFieldList().empty()) {
211
 
                for (Frame::FieldList::const_iterator it = frame.getFieldList().begin();
212
 
                                 it != frame.getFieldList().end();
213
 
                                 ++it) {
214
 
                        if ((*it).m_id == id) {
215
 
                                result = (*it).m_value;
216
 
                                break;
217
 
                        }
218
 
                }
219
 
        }
220
 
        return result;
221
 
}
222
 
 
223
 
/**
224
 
 * Set text encoding.
225
 
 *
226
 
 * @param frame frame to set
227
 
 * @param enc   text encoding
228
 
 *
229
 
 * @return true if field found and set.
230
 
 */
231
 
bool PictureFrame::setTextEncoding(Frame& frame, Field::TextEncoding enc)
232
 
{
233
 
        return setField(frame, Field::ID_TextEnc, enc);
234
 
}
235
 
 
236
 
/**
237
 
 * Get text encoding.
238
 
 *
239
 
 * @param frame frame to get
240
 
 * @param enc   the text encoding is returned here
241
 
 *
242
 
 * @return true if field found.
243
 
 */
244
 
bool PictureFrame::getTextEncoding(const Frame& frame, Field::TextEncoding& enc)
245
 
{
246
 
        QVariant var(getField(frame, Field::ID_TextEnc));
247
 
        if (var.isValid()) {
248
 
                enc = static_cast<Field::TextEncoding>(var.toInt());
249
 
                return true;
250
 
        }
251
 
        return false;
252
 
}
253
 
 
254
 
/**
255
 
 * Set image format.
256
 
 *
257
 
 * @param frame     frame to set
258
 
 * @param imgFormat image format
259
 
 *
260
 
 * @return true if field found and set.
261
 
 */
262
 
bool PictureFrame::setImageFormat(Frame& frame, const QString& imgFormat)
263
 
{
264
 
        return setField(frame, Field::ID_ImageFormat, imgFormat);
265
 
}
266
 
 
267
 
/**
268
 
 * Get image format.
269
 
 *
270
 
 * @param frame     frame to get
271
 
 * @param imgFormat the image format is returned here
272
 
 *
273
 
 * @return true if field found.
274
 
 */
275
 
bool PictureFrame::getImageFormat(const Frame& frame, QString& imgFormat)
276
 
{
277
 
        QVariant var(getField(frame, Field::ID_ImageFormat));
278
 
        if (var.isValid()) {
279
 
                imgFormat = var.toString();
280
 
                return true;
281
 
        }
282
 
        return false;
283
 
}
284
 
 
285
 
/**
286
 
 * Set MIME type.
287
 
 *
288
 
 * @param frame   frame to set
289
 
 * @param mimeType MIME type
290
 
 *
291
 
 * @return true if field found and set.
292
 
 */
293
 
bool PictureFrame::setMimeType(Frame& frame, const QString& mimeType)
294
 
{
295
 
        return setField(frame, Field::ID_MimeType, mimeType);
296
 
}
297
 
 
298
 
/**
299
 
 * Get MIME type.
300
 
 *
301
 
 * @param frame    frame to get
302
 
 * @param mimeType the MIME type is returned here
303
 
 *
304
 
 * @return true if field found.
305
 
 */
306
 
bool PictureFrame::getMimeType(const Frame& frame, QString& mimeType)
307
 
{
308
 
        QVariant var(getField(frame, Field::ID_MimeType));
309
 
        if (var.isValid()) {
310
 
                mimeType = var.toString();
311
 
                return true;
312
 
        }
313
 
        return false;
314
 
}
315
 
 
316
 
/**
317
 
 * Set picture type.
318
 
 *
319
 
 * @param frame       frame to set
320
 
 * @param pictureType picture type
321
 
 *
322
 
 * @return true if field found and set.
323
 
 */
324
 
bool PictureFrame::setPictureType(Frame& frame, PictureType pictureType)
325
 
{
326
 
        return setField(frame, Field::ID_PictureType, pictureType);
327
 
}
328
 
 
329
 
/**
330
 
 * Get picture type.
331
 
 *
332
 
 * @param frame       frame to get
333
 
 * @param pictureType the picture type is returned here
334
 
 *
335
 
 * @return true if field found.
336
 
 */
337
 
bool PictureFrame::getPictureType(const Frame& frame, PictureType& pictureType)
338
 
{
339
 
        QVariant var(getField(frame, Field::ID_PictureType));
340
 
        if (var.isValid()) {
341
 
                pictureType = static_cast<PictureType>(var.toInt());
342
 
                return true;
343
 
        }
344
 
        return false;
345
 
}
346
 
 
347
 
/**
348
 
 * Set description.
349
 
 *
350
 
 * @param frame       frame to set
351
 
 * @param description description
352
 
 *
353
 
 * @return true if field found and set.
354
 
 */
355
 
bool PictureFrame::setDescription(Frame& frame, const QString& description)
356
 
{
357
 
        return setField(frame, Field::ID_Description, description);
358
 
}
359
 
 
360
 
/**
361
 
 * Get description.
362
 
 *
363
 
 * @param frame       frame to get
364
 
 * @param description the description is returned here
365
 
 *
366
 
 * @return true if field found.
367
 
 */
368
 
bool PictureFrame::getDescription(const Frame& frame, QString& description)
369
 
{
370
 
        QVariant var(getField(frame, Field::ID_Description));
371
 
        if (var.isValid()) {
372
 
                description = var.toString();
373
 
                return true;
374
 
        }
375
 
        return false;
376
 
}
377
 
 
378
 
/**
379
 
 * Set binary data.
380
 
 *
381
 
 * @param frame frame to set
382
 
 * @param data  binary data
383
 
 *
384
 
 * @return true if field found and set.
385
 
 */
386
 
bool PictureFrame::setData(Frame& frame, const QByteArray& data)
387
 
{
388
 
        return setField(frame, Field::ID_Data, data);
389
 
}
390
 
 
391
 
/**
392
 
 * Get binary data.
393
 
 *
394
 
 * @param frame frame to get
395
 
 * @param data  the binary data is returned here
396
 
 *
397
 
 * @return true if field found.
398
 
 */
399
 
bool PictureFrame::getData(const Frame& frame, QByteArray& data)
400
 
{
401
 
        QVariant var(getField(frame, Field::ID_Data));
402
 
        if (var.isValid()) {
403
 
                data = var.toByteArray();
404
 
                return true;
405
 
        }
406
 
        return false;
407
 
}
408
 
 
409
 
/**
410
 
 * Read binary data from file.
411
 
 *
412
 
 * @param frame frame to set
413
 
 * @param fileName name of data file
414
 
 *
415
 
 * @return true if file read, field found and set.
416
 
 */
417
 
bool PictureFrame::setDataFromFile(Frame& frame, const QString& fileName)
418
 
{
419
 
        bool result = false;
420
 
        if (!fileName.isEmpty()) {
421
 
                QFile file(fileName);
422
 
                if (file.open(QCM_ReadOnly)) {
423
 
                        size_t size = file.size();
424
 
                        char* data = new char[size];
425
 
                        if (data) {
426
 
                                QDataStream stream(&file);
427
 
                                stream.QCM_readRawData(data, size);
428
 
                                QByteArray ba;
429
 
                                QCM_duplicate(ba, data, size);
430
 
                                result = setData(frame, ba);
431
 
                                delete [] data;
432
 
                        }
433
 
                        file.close();
434
 
                }
435
 
        }
436
 
        return result;
437
 
}
438
 
 
439
 
/**
440
 
 * Get binary data from image.
441
 
 *
442
 
 * @param frame frame to set
443
 
 * @param image image
444
 
 *
445
 
 * @return true if field found and set.
446
 
 */
447
 
bool PictureFrame::setDataFromImage(Frame& frame, const QImage& image)
448
 
{
449
 
        QByteArray ba;
450
 
#if QT_VERSION >= 0x040000
451
 
        QBuffer buffer(&ba);
452
 
#else
453
 
        QBuffer buffer(ba);
454
 
#endif
455
 
        buffer.open(QCM_WriteOnly);
456
 
        image.save(&buffer, "JPG");
457
 
        return setData(frame, ba);
458
 
}
459
 
 
460
 
/**
461
 
 * Save binary data to a file.
462
 
 *
463
 
 * @param frame    frame
464
 
 * @param fileName name of data file to save
465
 
 *
466
 
 * @return true if field found and saved.
467
 
 */
468
 
bool PictureFrame::writeDataToFile(const Frame& frame, const QString& fileName)
469
 
{
470
 
        QByteArray ba;
471
 
        if (getData(frame, ba)) {
472
 
                QFile file(fileName);
473
 
                if (file.open(QCM_WriteOnly)) {
474
 
                        QDataStream stream(&file);
475
 
                        stream.QCM_writeRawData(ba.data(), ba.size());
476
 
                        file.close();
477
 
                        return true;
478
 
                }
479
 
        }
480
 
        return false;
481
 
}
482
 
 
483
 
/**
484
 
 * Set the MIME type and image format from the file name extension.
485
 
 *
486
 
 * @param frame frame to set
487
 
 * @param fileName name of data file
488
 
 *
489
 
 * @return true if field found and set.
490
 
 */
491
 
bool PictureFrame::setMimeTypeFromFileName(Frame& frame, const QString& fileName)
492
 
{
493
 
        if (fileName.endsWith(".jpg", QCM_CaseInsensitive) ||
494
 
                        fileName.endsWith(".jpeg", QCM_CaseInsensitive)) {
495
 
                return setMimeType(frame, "image/jpeg") && setImageFormat(frame, "JPG");
496
 
        } else if (fileName.endsWith(".png", QCM_CaseInsensitive)) {
497
 
                return setMimeType(frame, "image/png") && setImageFormat(frame, "PNG");
498
 
        }
499
 
        return false;
500
 
}
501
 
 
502
 
#ifdef HAVE_BASE64_ENCODING
503
 
/**
504
 
 * Get a 32-bit number from a byte array stored in big-endian order.
505
 
 *
506
 
 * @param data byte array
507
 
 * @param index index of first byte in data
508
 
 *
509
 
 * @return big endian 32-bit value.
510
 
 */
511
 
static unsigned long getBigEndianULongFromByteArray(const QByteArray& data,
512
 
                                                    int index)
513
 
{
514
 
        return
515
 
                 ((unsigned char)data[index + 3] & 0xff)        |
516
 
                (((unsigned char)data[index + 2] & 0xff) << 8)  |
517
 
                (((unsigned char)data[index + 1] & 0xff) << 16) |
518
 
                (((unsigned char)data[index + 0] & 0xff) << 24);
519
 
}
520
 
 
521
 
/**
522
 
 * Render a 32-bit number to a byte array in big-endian order.
523
 
 *
524
 
 * @param value 32-bit value
525
 
 * @param data  byte array
526
 
 * @param index index of first byte in data
527
 
 */
528
 
static void renderBigEndianULongToByteArray(unsigned long value,
529
 
                                            QByteArray& data, int index)
530
 
{
531
 
        data[index + 3] = value & 0xff;
532
 
        value >>= 8;
533
 
        data[index + 2] = value & 0xff;
534
 
        value >>= 8;
535
 
        data[index + 1] = value & 0xff;
536
 
        value >>= 8;
537
 
        data[index + 0] = value & 0xff;
538
 
}
539
 
 
540
 
/**
541
 
 * Copy characters into a byte array.
542
 
 *
543
 
 * @param str   source string
544
 
 * @param data  destination byte array
545
 
 * @param index index of first byte in data
546
 
 * @param len   number of bytes to copy
547
 
 */
548
 
static void renderCharsToByteArray(const char* str, QByteArray& data,
549
 
                                   int index, int len)
550
 
{
551
 
        for (int i = 0; i < len; ++i) {
552
 
                data[index++] = *str++;
553
 
        }
554
 
}
555
 
 
556
 
/**
557
 
 * Set picture from a base64 string.
558
 
 *
559
 
 * @param frame       frame to set
560
 
 * @param base64Value base64 string
561
 
 */
562
 
void PictureFrame::setFieldsFromBase64(Frame& frame, const QString& base64Value)
563
 
{
564
 
#if QT_VERSION >= 0x040000
565
 
        QByteArray ba = QByteArray::fromBase64(base64Value.toAscii());
566
 
#elif defined CONFIG_USE_KDE
567
 
        QByteArray ba;
568
 
        QCString baBase64(base64Value.ascii());
569
 
        KCodecs::base64Decode(baBase64, ba);
570
 
#endif
571
 
        PictureFrame::PictureType pictureType = PictureFrame::PT_CoverFront;
572
 
        QString mimeType("image/jpeg");
573
 
        QString description("");
574
 
        if (frame.getName(true) == "METADATA_BLOCK_PICTURE") {
575
 
                unsigned long baSize = static_cast<unsigned long>(ba.size());
576
 
                if (baSize < 32) return;
577
 
                int index = 0;
578
 
                pictureType = static_cast<PictureFrame::PictureType>(
579
 
                        getBigEndianULongFromByteArray(ba, index));
580
 
                index += 4;
581
 
                unsigned long mimeLen = getBigEndianULongFromByteArray(ba, index);
582
 
                index += 4;
583
 
                if (baSize < index + mimeLen + 24) return;
584
 
                mimeType = QString::fromAscii(ba.data() + index, mimeLen);
585
 
                index += mimeLen;
586
 
                unsigned long descLen = getBigEndianULongFromByteArray(ba, index);
587
 
                index += 4;
588
 
                if (baSize < index + descLen + 20) return;
589
 
                description = QString::fromUtf8(ba.data() + index, descLen);
590
 
                index += descLen;
591
 
                index += 16; // width, height, depth, number of colors
592
 
                unsigned long picLen = getBigEndianULongFromByteArray(ba, index);
593
 
                index += 4;
594
 
                if (baSize < index + picLen) return;
595
 
#if QT_VERSION >= 0x040000
596
 
                ba = ba.mid(index);
597
 
#else
598
 
                ba.duplicate(ba.data() + index, picLen);
599
 
#endif
600
 
        }
601
 
        PictureFrame::setFields(
602
 
                frame, Frame::Field::TE_UTF8,   "", mimeType,
603
 
                pictureType, description, ba);
604
 
}
605
 
 
606
 
/**
607
 
 * Get picture to a base64 string.
608
 
 *
609
 
 * @param frame       frame to get
610
 
 * @param base64Value base64 string to set
611
 
 */
612
 
void PictureFrame::getFieldsToBase64(const Frame& frame, QString& base64Value)
613
 
{
614
 
        Frame::Field::TextEncoding enc;
615
 
        PictureFrame::PictureType pictureType = PictureFrame::PT_CoverFront;
616
 
        QString imgFormat, mimeType, description;
617
 
        QByteArray pic;
618
 
        PictureFrame::getFields(frame, enc, imgFormat, mimeType,
619
 
                                pictureType, description, pic);
620
 
        if (frame.getName(true) == "METADATA_BLOCK_PICTURE") {
621
 
                QCM_QCString mimeStr = mimeType.QCM_toAscii();
622
 
                QCM_QCString descStr = description.QCM_toUtf8();
623
 
                int mimeLen = mimeStr.length();
624
 
                int descLen = descStr.length();
625
 
                int picLen = pic.size();
626
 
                QByteArray ba(32 + mimeLen + descLen + picLen
627
 
#if QT_VERSION >= 0x040000
628
 
                               , '\0'
629
 
#endif
630
 
                               );
631
 
                int index = 0;
632
 
                renderBigEndianULongToByteArray(pictureType, ba, index);
633
 
                index += 4;
634
 
                renderBigEndianULongToByteArray(mimeLen, ba, index);
635
 
                index += 4;
636
 
                renderCharsToByteArray(mimeStr, ba, index, mimeLen);
637
 
                index += mimeLen;
638
 
                renderBigEndianULongToByteArray(descLen, ba, index);
639
 
                index += 4;
640
 
                renderCharsToByteArray(descStr, ba, index, descLen);
641
 
                index += descLen;
642
 
 
643
 
                int width = 0, height = 0, depth = 0, numColors = 0;
644
 
                QImage image;
645
 
                if (image.loadFromData(pic)) {
646
 
                        width = image.width();
647
 
                        height = image.height();
648
 
                        depth = image.depth();
649
 
                        numColors = image.numColors();
650
 
                }
651
 
                renderBigEndianULongToByteArray(width, ba, index);
652
 
                index += 4;
653
 
                renderBigEndianULongToByteArray(height, ba, index);
654
 
                index += 4;
655
 
                renderBigEndianULongToByteArray(depth, ba, index);
656
 
                index += 4;
657
 
                renderBigEndianULongToByteArray(numColors, ba, index);
658
 
                index += 4;
659
 
 
660
 
                renderBigEndianULongToByteArray(picLen, ba, index);
661
 
                index += 4;
662
 
                renderCharsToByteArray(pic.data(), ba, index, picLen);
663
 
                pic = ba;
664
 
        }
665
 
#if QT_VERSION >= 0x040000
666
 
        base64Value = pic.toBase64();
667
 
#elif defined CONFIG_USE_KDE
668
 
        QByteArray picBase64;
669
 
        KCodecs::base64Encode(pic, picBase64);
670
 
        base64Value = QString(picBase64);
671
 
#endif
672
 
}
673
 
#endif // HAVE_BASE64_ENCODING