2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
6 Jussi Laitinen - jussi.laitinen@ixonos.com
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.
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.
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,
23 #include "avatarimage.h"
27 const int IMAGE_WIDTH = 60; ///< Created image width
28 const int IMAGE_HEIGHT = 60; ///< Created image height
29 const int ORIGINAL_IMAGE_X = 5; ///< Original image x position
30 const int ORIGINAL_IMAGE_Y = 5; ///< Original image y position
31 const int ROUNDNESS = 9; ///< Image roundness
32 const int CLIP_X_OFFSET = 1; ///< Clip
34 QPixmap AvatarImage::create(const QPixmap &image)
36 QPixmap avatarImage = QPixmap(IMAGE_WIDTH, IMAGE_HEIGHT);
37 avatarImage.fill(Qt::transparent);
38 QPainter painter(&avatarImage);
40 QRect imageRect = QRect(0, 0, image.width(), image.height());
42 QPainterPath roundedRect;
43 roundedRect.addRoundedRect(ORIGINAL_IMAGE_X-1, ORIGINAL_IMAGE_Y-1, imageRect.width()+1,
44 imageRect.height()+1,ROUNDNESS,ROUNDNESS);
46 painter.setClipPath(roundedRect);
47 painter.drawPixmap(QPointF(ORIGINAL_IMAGE_X, ORIGINAL_IMAGE_Y), image);
49 painter.drawPixmap(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
50 QPixmap(":/res/images/profile_pic_border.png"));