Skip to content

Commit 8381d3a

Browse files
committed
core:opt code
Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn>
1 parent d670ede commit 8381d3a

12 files changed

+41
-50
lines changed

build_deb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ QT_DIR=/opt/Qt5.12.8/5.12.8/gcc_64
77
# 定义版本号
88
YVYVIEWER_MAJARVERSION="0"
99
YVYVIEWER_SUBVERSION="0"
10-
YVYVIEWER_REVISION="1"
10+
YVYVIEWER_REVISION="2"
1111
###############################################################################
1212

1313

build_dmg.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ QT_DIR=/opt/Qt5.12.2/5.12.2/gcc_64
66

77
# 定义版本号
88
YVYVIEWER_MAJARVERSION="0"
9-
YVYVIEWER_SUBVERSION="4"
10-
YVYVIEWER_REVISION="9"
9+
YVYVIEWER_SUBVERSION="0"
10+
YVYVIEWER_REVISION="2"
1111
###############################################################################
1212

1313

build_setup.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set "QT_TOOLS_DIR=C:/Qt/Qt5.12.8/Tools/mingw730_32/bin"
77
:: 定义Inno Setup目录
88
set "INNO_SETUP_DIR=C:/Program Files (x86)/Inno Setup 6"
99
:: 定义版本号
10-
set "YVYVIEWER_VERSION=0.4.9"
10+
set "YVYVIEWER_VERSION=0.0.2"
1111
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1212

1313

partform_unix.pri

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# 定义freetype2 lib路径
33
FREETPE2_DIR=/home/qqm/Desktop/ttfviewer/depend/freetype
44
# 定义版本号路径
5-
TTFVIEWER_VERSION=0.0.1
5+
TTFVIEWER_VERSION=0.0.2
66
###############################################################################

partform_win32.pri

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# 定义freetype2 lib路径
33
FREETPE2_DIR=D:\ttfviewer\depend\freetype
44
# 定义版本号路径
5-
TTFVIEWER_VERSION=0.0.1
5+
TTFVIEWER_VERSION=0.0.2
66
###############################################################################

src/ImgViewer.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TTFDecodeThread::TTFDecodeThread(QWidget *parent,QString ttffilename,QString TTF
3232

3333
void TTFDecodeThread::run()
3434
{
35-
QList<QPixmap> frame_RGB_list;
35+
QList<QPixmap *> frame_RGB_list;
3636
if(this->decoder == nullptr)
3737
{
3838
// 未能成功获取则返回无法解码
@@ -57,7 +57,7 @@ ImgViewer::ImgViewer(QWidget *parent,QWidget *parentWindow) :
5757
ui(new Ui::ImgViewerWindow)
5858
{
5959
ui->setupUi(this);
60-
qRegisterMetaType<QList<QPixmap>>("QList<QPixmap>");
60+
qRegisterMetaType<QList<QPixmap *>>("QList<QPixmap *>");
6161
this->parentWindow = parentWindow;
6262
setWindowTitle("loading file, please wait ....");
6363
ui->left_PushButton->setFlat(true);
@@ -88,7 +88,7 @@ bool ImgViewer::setFileList(QStringList filenamelist,QString TTFFormat, int W, i
8888
// 遍历文件列表
8989
foreach( QString filename, filenamelist)
9090
{
91-
QList<QPixmap> frame_RGB_list;
91+
QList<QPixmap *> frame_RGB_list;
9292

9393
// 使用获取的解码函数进行解码得到RGB的原始帧列表
9494
frame_RGB_list = decoder(filename, W, H, codepoint);
@@ -107,13 +107,13 @@ bool ImgViewer::setFileList(QStringList filenamelist,QString TTFFormat, int W, i
107107
this->currentImg_RGB_list = this->img_list.at(0);
108108
this->currentImg = this->currentImg_RGB_list.at(0);
109109
this->setWindowTitle(this->filelist.at(0)+"-0");
110-
this->scaled_img = this->currentImg.scaled(this->size());
110+
this->scaled_img = this->currentImg->scaled(this->size());
111111
this->point = QPoint(0, 0);
112112
return true;
113113
}
114114
}
115115

116-
void ImgViewer::reciveimgdata(QList<QPixmap> img_RGB_list,QString filename)
116+
void ImgViewer::reciveimgdata(QList<QPixmap *> img_RGB_list,QString filename)
117117
{
118118
if (!img_RGB_list.empty())
119119
{
@@ -128,7 +128,7 @@ void ImgViewer::reciveimgdata(QList<QPixmap> img_RGB_list,QString filename)
128128
this->currentImg_RGB_list = this->img_list.at(0);
129129
this->currentImg = this->currentImg_RGB_list.at(0);
130130
this->setWindowTitle(this->filelist.at(0)+"-0");
131-
this->scaled_img = this->currentImg.scaled(this->size());
131+
this->scaled_img = this->currentImg->scaled(this->size());
132132
this->point = QPoint(0, 0);
133133
this->repaint();
134134
}
@@ -162,7 +162,7 @@ bool ImgViewer::setFileList_multithreading(QStringList filenamelist,QString TTFF
162162
foreach( QString filename, filenamelist)
163163
{
164164
TTFDecodeThread *decodeThread = new TTFDecodeThread(this, filename, TTFFormat, W, H, codepoint);
165-
QObject::connect(decodeThread, SIGNAL(finsh_signal(QList<QPixmap>, QString)), this, SLOT(reciveimgdata(QList<QPixmap>, QString)));
165+
QObject::connect(decodeThread, SIGNAL(finsh_signal(QList<QPixmap *>, QString)), this, SLOT(reciveimgdata(QList<QPixmap *>, QString)));
166166
this->decode_thread.insert(this->decode_thread.end(),decodeThread);
167167
}
168168
this->decode_thread[0]->start();
@@ -175,13 +175,13 @@ void ImgViewer::closeEvent(QCloseEvent *event)
175175
event->accept();
176176
if(!this->img_list.empty())
177177
{
178-
foreach(QList<QPixmap> list,this->img_list)
178+
foreach(QList<QPixmap *> list,this->img_list)
179179
{
180180
if(!list.empty())
181181
{
182-
foreach(QPixmap img,list)
182+
foreach(QPixmap *img,list)
183183
{
184-
//delete img;
184+
delete img;
185185
}
186186
}
187187
}
@@ -243,12 +243,12 @@ void ImgViewer::mouseReleaseEvent(QMouseEvent *event)
243243
else if(event->button() == Qt::RightButton)
244244
{
245245
this->point = QPoint(0, 0);
246-
this->scaled_img = this->currentImg.scaled(this->size());
246+
this->scaled_img = this->currentImg->scaled(this->size());
247247
this->repaint();
248248
}
249249
else if(event->button() == Qt::MiddleButton)
250250
{
251-
this->scaled_img = this->currentImg.scaled(this->currentImg.size().width(),this->currentImg.size().height());
251+
this->scaled_img = this->currentImg->scaled(this->currentImg->size().width(),this->currentImg->size().height());
252252
this->point = QPoint(0, 0);
253253
this->repaint();
254254
}
@@ -262,19 +262,19 @@ void ImgViewer::mouseDoubleClickEvent(QMouseEvent *event)
262262
if( event->button() == Qt::LeftButton)
263263
{
264264
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
265-
QList<QPixmap> img_RGB_list = this->img_list[list_index];
265+
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
266266
int img_index = img_RGB_list.indexOf(this->currentImg);
267267
QString savefile_name = QFileDialog::getSaveFileName(this, "保存文件", this->filelist[list_index].replace(".ttf","-") + QString::number(img_index) + ".png", "Image files(*.png)");
268268
if(savefile_name != nullptr)
269269
{
270-
this->currentImg.save(savefile_name);
270+
this->currentImg->save(savefile_name);
271271
}
272272
}
273273
else if(event->button() == Qt::RightButton)
274274
{
275275
this->flipRGB = this->flipRGB ? false : true;
276276
this->point = QPoint(0, 0);
277-
this->scaled_img = this->currentImg.scaled(this->size());
277+
this->scaled_img = this->currentImg->scaled(this->size());
278278
this->repaint();
279279
}
280280
}
@@ -292,7 +292,7 @@ void ImgViewer::wheelEvent(QWheelEvent *event)
292292
float setpsize_x = ((float)this->scaled_img.width())/16.0f;
293293
float setpsize_y = ((float)this->scaled_img.height())/16.0f; //缩放可能导致比例不精确
294294

295-
this->scaled_img = this->currentImg.scaled(this->scaled_img.width() + setpsize_x,this->scaled_img.height() + setpsize_y);
295+
this->scaled_img = this->currentImg->scaled(this->scaled_img.width() + setpsize_x,this->scaled_img.height() + setpsize_y);
296296
float new_w = event->x() - (this->scaled_img.width() * (event->x() - this->point.x())) / (this->scaled_img.width() - setpsize_x);
297297
float new_h = event->y() - (this->scaled_img.height() * (event->y() - this->point.y())) / (this->scaled_img.height() - setpsize_y);
298298
this->point = QPoint(new_w, new_h);
@@ -307,7 +307,7 @@ void ImgViewer::wheelEvent(QWheelEvent *event)
307307
float setpsize_x = ((float)this->scaled_img.width())/16.0f;
308308
float setpsize_y = ((float)this->scaled_img.height())/16.0f; //缩放可能导致比例不精确
309309

310-
this->scaled_img = this->currentImg.scaled(this->scaled_img.width() - setpsize_x,this->scaled_img.height() - setpsize_y);
310+
this->scaled_img = this->currentImg->scaled(this->scaled_img.width() - setpsize_x,this->scaled_img.height() - setpsize_y);
311311
float new_w = event->x() - (this->scaled_img.width() * (event->x() - this->point.x())) / (this->scaled_img.width() + setpsize_x);
312312
float new_h = event->y() - (this->scaled_img.height() * (event->y() - this->point.y())) / (this->scaled_img.height() + setpsize_y);
313313
this->point = QPoint(new_w, new_h);
@@ -321,7 +321,7 @@ void ImgViewer::resizeEvent(QResizeEvent *event)
321321
{
322322
if (!this->img_list.empty())
323323
{
324-
this->scaled_img = this->currentImg.scaled(this->size());
324+
this->scaled_img = this->currentImg->scaled(this->size());
325325
this->point = QPoint(0, 0);
326326
this->update();
327327
}
@@ -334,7 +334,7 @@ void ImgViewer::previousImg()
334334
{
335335
//得到当前显示的文件序号
336336
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
337-
QList<QPixmap> img_RGB_list = this->img_list[list_index];
337+
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
338338
//得到当前显示的图像是文件的帧序号
339339
int img_index = img_RGB_list.indexOf(this->currentImg);
340340

@@ -366,7 +366,7 @@ void ImgViewer::previousImg()
366366
this->currentImg_RGB_list = this->img_list[list_index];
367367
this->currentImg = this->currentImg_RGB_list[img_index];
368368
this->point = QPoint(0, 0);
369-
this->scaled_img = this->currentImg.scaled(this->size());
369+
this->scaled_img = this->currentImg->scaled(this->size());
370370
this->repaint();
371371
}
372372
}
@@ -377,7 +377,7 @@ void ImgViewer::nextImg()
377377
{
378378
//得到当前显示的文件序号
379379
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
380-
QList<QPixmap> img_RGB_list = this->img_list[list_index];
380+
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
381381
//得到当前显示的图像是文件的帧序号
382382
int img_index = img_RGB_list.indexOf(this->currentImg);
383383

@@ -409,7 +409,7 @@ void ImgViewer::nextImg()
409409
this->currentImg_RGB_list = this->img_list[list_index];
410410
this->currentImg = this->currentImg_RGB_list[img_index];
411411
this->point = QPoint(0, 0);
412-
this->scaled_img = this->currentImg.scaled(this->size());
412+
this->scaled_img = this->currentImg->scaled(this->size());
413413
this->repaint();
414414
}
415415
}

src/ImgViewer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TTFDecodeThread : public QThread
3737
void run();
3838

3939
signals:
40-
void finsh_signal(QList<QPixmap> frame_RGB_list,QString str);
40+
void finsh_signal(QList<QPixmap *> frame_RGB_list,QString str);
4141

4242
private:
4343
QWidget *window;
@@ -59,7 +59,7 @@ class ImgViewer : public QWidget
5959
bool setFileList_multithreading(QStringList filenamelist, QString TTFFormat, int W, int H, int codepoint);
6060

6161
private slots:
62-
void reciveimgdata(QList<QPixmap> img_RGB_list, QString filename);
62+
void reciveimgdata(QList<QPixmap*> img_RGB_list, QString filename);
6363
void previousImg();
6464
void nextImg();
6565

@@ -79,14 +79,14 @@ private slots:
7979
QWidget *parentWindow;
8080
bool left_click;
8181

82-
QList<QList<QPixmap>> img_list;
82+
QList<QList<QPixmap *>> img_list;
8383
QStringList filelist;
8484

8585
QList<TTFDecodeThread*> decode_thread;
8686
QList<TTFDecodeThread*> decode_thread_finsh;
8787

88-
QList<QPixmap> currentImg_RGB_list;
89-
QPixmap currentImg;
88+
QList<QPixmap *> currentImg_RGB_list;
89+
QPixmap *currentImg;
9090
QPixmap scaled_img;
9191
QPoint point;
9292
QPoint startPos;

src/TTFdecoder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ QMap<QString, ttfdecoder_t> TTF2RGB::ttfdecoder_map =
2121
{"ttf", TTF2RGB::ttf},
2222
};
2323

24-
QList<QPixmap> TTF2RGB::ttf(QString ttffilename,int W, int H, int codepoint)
24+
QList<QPixmap *> TTF2RGB::ttf(QString ttffilename,int W, int H, int codepoint)
2525
{
26-
QList<QPixmap> rgbImglist;
26+
QList<QPixmap *> rgbImglist;
2727
QString svgImg;
2828
QByteArray naBA = ttffilename.toLatin1();
2929

@@ -43,9 +43,9 @@ QList<QPixmap> TTF2RGB::ttf(QString ttffilename,int W, int H, int codepoint)
4343
QXmlStreamReader svgXmlStreamReader(svgImg);
4444
QSvgRenderer svgRender;
4545
svgRender.load(&svgXmlStreamReader);
46-
QPixmap svgPixmap(W,H);
47-
svgPixmap.fill(Qt::transparent);
48-
QPainter svgPainter(&svgPixmap);
46+
QPixmap *svgPixmap = new QPixmap(W,H);
47+
svgPixmap->fill(Qt::transparent);
48+
QPainter svgPainter(svgPixmap);
4949
svgRender.render(&svgPainter);
5050

5151
rgbImglist.append(svgPixmap);

src/TTFdecoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include <QList>
1212
#include <QMap>
1313

14-
typedef QList<QPixmap> (* ttfdecoder_t)(QString ttffilename,int W, int H, int codepoint);
14+
typedef QList<QPixmap *> (* ttfdecoder_t)(QString ttffilename,int W, int H, int codepoint);
1515

1616
class TTF2RGB
1717
{
1818
public:
19-
static QList<QPixmap> ttf(QString ttffilename,int W, int H, int codepoint);
19+
static QList<QPixmap *> ttf(QString ttffilename,int W, int H, int codepoint);
2020
static QMap<QString, ttfdecoder_t> ttfdecoder_map;
2121
};
2222

src/TTFviewer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ TTFviewer::TTFviewer(QWidget *parent) :
6262
QMainWindow(parent),
6363
ui(new Ui::TTFviewer)
6464
{
65-
int currentIndex;
66-
6765
ui->setupUi(this);
6866

6967
this->setWindowTitle("TTFviewer " + VERSION);
@@ -119,11 +117,9 @@ TTFviewer::TTFviewer(QWidget *parent) :
119117
}
120118

121119

122-
currentIndex = 0;
123120
QList<uint64_t> color_list;
124121

125122

126-
QObject::connect(ui->TTFFormat_ComboBox, SIGNAL(currentTextChanged(const QString &)), this, SLOT(changeFormat(const QString &)));
127123
QObject::connect(ui->frameSizeType_Combo_RadioButton, SIGNAL(clicked()), this, SLOT(configComboBox()));
128124
QObject::connect(ui->frameSizeType_Other_RadioButton, SIGNAL(clicked()), this, SLOT(configOther()));
129125
QObject::connect(ui->frameSizeType_ComboBox, SIGNAL(currentTextChanged(const QString &)), this,SLOT(changeFrameSizeType(const QString &)));
@@ -151,10 +147,6 @@ TTFviewer::~TTFviewer()
151147
delete ui;
152148
}
153149

154-
void TTFviewer::changeFormat(const QString &text)
155-
{
156-
}
157-
158150
void TTFviewer::configComboBox()
159151
{
160152
ui->frameSizeType_ComboBox->setEnabled(true);

0 commit comments

Comments
 (0)