forked from spygg/QBaiduFm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
getcirclescaledpixmap.cpp
53 lines (37 loc) · 1.31 KB
/
getcirclescaledpixmap.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "getcirclescaledpixmap.h"
#include <QDebug>
GetCircleScaledPixmap::GetCircleScaledPixmap(QObject *parent) : QObject(parent)
{
}
QPixmap GetCircleScaledPixmap::getCirclePictureAtCenter(QPixmap srcPic, QPixmap backPic, int width, int height)
{
int iCenterX = 0;
int iCenterY = 0;
// width = srcPic.width() - 10;
// height = srcPic.height() - 10 ;
iCenterX = (srcPic.width() - width) / 2.0 - 39;
iCenterY = (srcPic.height() - height) / 2.0 - 39;
//在backPic上画源图片
QPainter paint(&backPic);
QRegion region(iCenterX, iCenterY, width, height, QRegion::Ellipse);
paint.setClipRegion(region);
paint.drawPixmap(iCenterX, iCenterY, width, height, srcPic);
return backPic;
}
QPixmap GetCircleScaledPixmap::getCirclePictureAtCenter(QPixmap srcPic, QPixmap backPic)
{
int iCenterX = 0;
int iCenterY = 0;
int width = 0;
int height = 0;
width = srcPic.width() - 10;
height = srcPic.height() - 10 ;
iCenterX = (srcPic.width() - width) / 2.0;
iCenterY = (srcPic.height() - height) / 2.0;
//在backPic上画源图片
QPainter paint(&backPic);
QRegion region(iCenterX, iCenterY, width, height, QRegion::Ellipse);
paint.setClipRegion(region);
paint.drawPixmap(iCenterX, iCenterY, width, height, srcPic);
return backPic;
}