source: SMSSender/src/ui/UIHelper.cpp @ 67:578192d6fe64

3.0
Last change on this file since 67:578192d6fe64 was 23:0568f64da6a9, checked in by Sämy Zehnder <saemy.zehnder@…>, 13 years ago
  • Renamed SMSSender into smssender
  • Added blank image ressource
  • UIUtils returns now a QImage with no content instead of NULL.
  • typeconvert has now a new function called isChildOf (But I'm not sure, if this realy works... ;) )
  • VCMain handles now properly the recipients (add / remove contacts or whole groups)
File size: 832 bytes
Line 
1/*
2 * UIHelper.cpp
3 *
4 *  Created on: Jun 16, 2009
5 *      Author: saemy
6 */
7
8#include "UIHelper.h"
9
10#include "../business/BCBinary.h"
11
12#include <QBuffer>
13#include <QByteArray>
14#include <QIODevice>
15
16
17IBinary* UIHelper::QImageToBinary(const QImage& image) {
18    if (image.isNull()){
19        return new BCBinary();
20    }
21
22    QByteArray ba;
23    QBuffer buffer(&ba);
24    buffer.open(QIODevice::WriteOnly);
25    image.save(&buffer, "PNG"); // writes image into ba in PNG format
26
27    IBinary* binary = new BCBinary(ba.data(), ba.size());
28    return binary;
29}
30
31QImage* UIHelper::BinaryToQImage(const IBinary& binary) {
32    if ((&binary == NULL) || (binary.size() == 0)) {
33        return new QImage();
34    }
35    QByteArray ba(binary.data(), binary.size());
36    QImage* image = new QImage();
37    image->loadFromData(ba);
38    return image;
39}
Note: See TracBrowser for help on using the repository browser.