started feature to show bigger profile images
[situare] / src / ui / avatarimage.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
6        Jussi Laitinen - jussi.laitinen@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #include "avatarimage.h"
24 #include <QPainter>
25 #include <QDebug>
26
27 const int IMAGE_WIDTH = 64;     ///< Created image width
28 const int IMAGE_HEIGHT = 64;    ///< Created image height
29 const int ORIGINAL_IMAGE_X = 7; ///< Original image x position
30 const int ORIGINAL_IMAGE_Y = 7; ///< Original image y position
31 const int ROUNDNESS = 9;        ///< Image roundness
32 const int CLIP_X_OFFSET = 1;    ///< Clip
33
34 QPixmap AvatarImage::create(const QPixmap &image)
35 {
36 //    QPixmap avatarImage = QPixmap(IMAGE_WIDTH, IMAGE_HEIGHT);
37 //    avatarImage.fill(Qt::transparent);
38 //    QPainter painter(&avatarImage);
39 //
40 //    QRect imageRect = QRect(0, 0, image.width(), image.height());
41 //
42 //    QPainterPath roundedRect;
43 //    roundedRect.addRoundedRect(ORIGINAL_IMAGE_X-1, ORIGINAL_IMAGE_Y-1, imageRect.width()+1,
44 //                               imageRect.height()+1,ROUNDNESS,ROUNDNESS);
45 //    painter.save();
46 //    painter.setClipPath(roundedRect);
47 //    painter.drawPixmap(QPointF(ORIGINAL_IMAGE_X, ORIGINAL_IMAGE_Y), image);
48 //    painter.restore();
49 //    painter.drawPixmap(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
50 //                       QPixmap(":/res/images/profile_pic_border.png"));
51 //
52 //    return avatarImage;
53
54
55
56     //addroundedRect taitaa olla aika turhaa koodia
57
58
59     QPixmap avatarImage = QPixmap(image.width(), image.height());
60     avatarImage.fill(Qt::transparent);
61     QPainter painter(&avatarImage);
62     painter.setPen(Qt::red);
63     painter.drawPixmap(QPointF(0,0),image);
64     //painter.eraseRect(QRect(QPoint(0,0),QPoint(100,100)));
65     //painter.setWindow(QRect(0, 0, avatarImage.width()/2, avatarImage.height()/2)); ei vaikuta
66     //painter.setViewport(QRect(0, 0, avatarImage.width()/2, avatarImage.height()/2)); ei vaikuta
67     painter.drawRect(QRect(0,0,30,40));
68     painter.drawRoundedRect(QRect(10,10,30,30),3,3,Qt::AbsoluteSize);
69     QPixmap valo(":res/images/gps_position_accurate.png");
70     painter.drawPixmap(QPointF(20,30), valo);
71
72
73
74     return avatarImage;
75 }