diff options
Diffstat (limited to 'utils/wpseditor/gui/src/qwpsdrawer_static.cpp')
-rw-r--r-- | utils/wpseditor/gui/src/qwpsdrawer_static.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp new file mode 100644 index 0000000000..bf94d28a5a --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp | |||
@@ -0,0 +1,77 @@ | |||
1 | #include "qwpsdrawer.h" | ||
2 | #include <QPainter> | ||
3 | #include <QFile> | ||
4 | #include <QFileInfo> | ||
5 | #include "utils.h" | ||
6 | |||
7 | void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { | ||
8 | QPainter p(pix); | ||
9 | viewport_api avp; | ||
10 | api.get_current_vp(&avp); | ||
11 | p.setPen(Qt::gray); | ||
12 | |||
13 | |||
14 | QFont font("times",avp.fontheight,QFont::Bold); | ||
15 | p.setFont(font); | ||
16 | p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); | ||
17 | } | ||
18 | void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
19 | int stride, int x, int y, int width, int height) { | ||
20 | QImage img; | ||
21 | img.load((char*)src); | ||
22 | DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d,int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y,stride, x, y, width, height); | ||
23 | QPainter p(pix); | ||
24 | QPoint target(x,y); | ||
25 | QRectF source(src_x, src_y, width, height); | ||
26 | |||
27 | QImage pink = img.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); | ||
28 | img.setAlphaChannel(pink); | ||
29 | |||
30 | p.drawImage(target, img, source); | ||
31 | } | ||
32 | void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, | ||
33 | int stride, int x, int y, int width, int height) { | ||
34 | transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); | ||
35 | } | ||
36 | void QWpsDrawer::drawpixel(int x, int y) { | ||
37 | QPainter p(pix); | ||
38 | p.setPen(Qt::blue); | ||
39 | p.drawPoint(x,y); | ||
40 | } | ||
41 | void QWpsDrawer::fillrect(int x, int y, int width, int height) { | ||
42 | QPainter p(pix); | ||
43 | DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); | ||
44 | p.setPen(Qt::green); | ||
45 | } | ||
46 | void QWpsDrawer::hline(int x1, int x2, int y) { | ||
47 | QPainter p(pix); | ||
48 | p.setPen(Qt::black); | ||
49 | p.drawLine(x1,y,x2,y); | ||
50 | } | ||
51 | void QWpsDrawer::vline(int x, int y1, int y2) { | ||
52 | QPainter p(pix); | ||
53 | p.setPen(Qt::black); | ||
54 | p.drawLine(x,y1,x,y2); | ||
55 | } | ||
56 | bool QWpsDrawer::load_wps_backdrop(char* filename) { | ||
57 | DEBUGF2("load backdrop: %s", filename); | ||
58 | QFile file(filename); | ||
59 | QFileInfo info(file); | ||
60 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
61 | backdrop.load(filename); | ||
62 | return true; | ||
63 | } | ||
64 | |||
65 | int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { | ||
66 | QImage img; | ||
67 | |||
68 | QFile file(filename); | ||
69 | QFileInfo info(file); | ||
70 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
71 | |||
72 | img.load(filename); | ||
73 | //qDebug()<<"QWpsDrawer::read_bmp_file"<<img.width()<<img.height(); | ||
74 | *width = img.width(); | ||
75 | *height = img.height(); | ||
76 | return 1; | ||
77 | } | ||