source: SMSSender/src/ui/UIHelper.cpp @ 18:f92b83afa152

3.0
Last change on this file since 18:f92b83afa152 was 18:f92b83afa152, checked in by Sämy Zehnder <saemy.zehnder@…>, 13 years ago
  • Implemented UIHelper
  • Implemented IBinary
  • Image saving is finally working!! :D Wheeehee!!
  • Fixed not working alias removing.
  • Blobs can now be saved and loaded from the data-ressource. (db)
File size: 921 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
17UIHelper * UIHelper::instance_=0;
18UIHelper* UIHelper::instance(){
19    if (instance_ == 0)
20        instance_ = new UIHelper;
21    return instance_;
22}
23
24IBinary* UIHelper::QImageToBinary(const QImage& image) const {
25    QByteArray ba;
26    QBuffer buffer(&ba);
27    buffer.open(QIODevice::WriteOnly);
28    image.save(&buffer, "PNG"); // writes image into ba in PNG format
29
30    IBinary* binary = new BCBinary(ba.data(), ba.size());
31    return binary;
32}
33
34QImage* UIHelper::BinaryToQImage(const IBinary& data) const {
35    if ((&data == NULL) || (data.getSize() == 0)) {
36        return NULL;
37    }
38    QByteArray ba(data.getData(), data.getSize());
39    QImage* image = new QImage();
40    image->loadFromData(ba);
41    return image;
42}
Note: See TracBrowser for help on using the repository browser.