Skip to content

Commit

Permalink
core:opt code
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Jul 3, 2022
1 parent d670ede commit 8381d3a
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ QT_DIR=/opt/Qt5.12.8/5.12.8/gcc_64
# 定义版本号
YVYVIEWER_MAJARVERSION="0"
YVYVIEWER_SUBVERSION="0"
YVYVIEWER_REVISION="1"
YVYVIEWER_REVISION="2"
###############################################################################


Expand Down
4 changes: 2 additions & 2 deletions build_dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ QT_DIR=/opt/Qt5.12.2/5.12.2/gcc_64

# 定义版本号
YVYVIEWER_MAJARVERSION="0"
YVYVIEWER_SUBVERSION="4"
YVYVIEWER_REVISION="9"
YVYVIEWER_SUBVERSION="0"
YVYVIEWER_REVISION="2"
###############################################################################


Expand Down
2 changes: 1 addition & 1 deletion build_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set "QT_TOOLS_DIR=C:/Qt/Qt5.12.8/Tools/mingw730_32/bin"
:: 定义Inno Setup目录
set "INNO_SETUP_DIR=C:/Program Files (x86)/Inno Setup 6"
:: 定义版本号
set "YVYVIEWER_VERSION=0.4.9"
set "YVYVIEWER_VERSION=0.0.2"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Expand Down
2 changes: 1 addition & 1 deletion partform_unix.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# 定义freetype2 lib路径
FREETPE2_DIR=/home/qqm/Desktop/ttfviewer/depend/freetype
# 定义版本号路径
TTFVIEWER_VERSION=0.0.1
TTFVIEWER_VERSION=0.0.2
###############################################################################
2 changes: 1 addition & 1 deletion partform_win32.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# 定义freetype2 lib路径
FREETPE2_DIR=D:\ttfviewer\depend\freetype
# 定义版本号路径
TTFVIEWER_VERSION=0.0.1
TTFVIEWER_VERSION=0.0.2
###############################################################################
44 changes: 22 additions & 22 deletions src/ImgViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TTFDecodeThread::TTFDecodeThread(QWidget *parent,QString ttffilename,QString TTF

void TTFDecodeThread::run()
{
QList<QPixmap> frame_RGB_list;
QList<QPixmap *> frame_RGB_list;
if(this->decoder == nullptr)
{
// 未能成功获取则返回无法解码
Expand All @@ -57,7 +57,7 @@ ImgViewer::ImgViewer(QWidget *parent,QWidget *parentWindow) :
ui(new Ui::ImgViewerWindow)
{
ui->setupUi(this);
qRegisterMetaType<QList<QPixmap>>("QList<QPixmap>");
qRegisterMetaType<QList<QPixmap *>>("QList<QPixmap *>");
this->parentWindow = parentWindow;
setWindowTitle("loading file, please wait ....");
ui->left_PushButton->setFlat(true);
Expand Down Expand Up @@ -88,7 +88,7 @@ bool ImgViewer::setFileList(QStringList filenamelist,QString TTFFormat, int W, i
// 遍历文件列表
foreach( QString filename, filenamelist)
{
QList<QPixmap> frame_RGB_list;
QList<QPixmap *> frame_RGB_list;

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

void ImgViewer::reciveimgdata(QList<QPixmap> img_RGB_list,QString filename)
void ImgViewer::reciveimgdata(QList<QPixmap *> img_RGB_list,QString filename)
{
if (!img_RGB_list.empty())
{
Expand All @@ -128,7 +128,7 @@ void ImgViewer::reciveimgdata(QList<QPixmap> img_RGB_list,QString filename)
this->currentImg_RGB_list = this->img_list.at(0);
this->currentImg = this->currentImg_RGB_list.at(0);
this->setWindowTitle(this->filelist.at(0)+"-0");
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->point = QPoint(0, 0);
this->repaint();
}
Expand Down Expand Up @@ -162,7 +162,7 @@ bool ImgViewer::setFileList_multithreading(QStringList filenamelist,QString TTFF
foreach( QString filename, filenamelist)
{
TTFDecodeThread *decodeThread = new TTFDecodeThread(this, filename, TTFFormat, W, H, codepoint);
QObject::connect(decodeThread, SIGNAL(finsh_signal(QList<QPixmap>, QString)), this, SLOT(reciveimgdata(QList<QPixmap>, QString)));
QObject::connect(decodeThread, SIGNAL(finsh_signal(QList<QPixmap *>, QString)), this, SLOT(reciveimgdata(QList<QPixmap *>, QString)));
this->decode_thread.insert(this->decode_thread.end(),decodeThread);
}
this->decode_thread[0]->start();
Expand All @@ -175,13 +175,13 @@ void ImgViewer::closeEvent(QCloseEvent *event)
event->accept();
if(!this->img_list.empty())
{
foreach(QList<QPixmap> list,this->img_list)
foreach(QList<QPixmap *> list,this->img_list)
{
if(!list.empty())
{
foreach(QPixmap img,list)
foreach(QPixmap *img,list)
{
//delete img;
delete img;
}
}
}
Expand Down Expand Up @@ -243,12 +243,12 @@ void ImgViewer::mouseReleaseEvent(QMouseEvent *event)
else if(event->button() == Qt::RightButton)
{
this->point = QPoint(0, 0);
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->repaint();
}
else if(event->button() == Qt::MiddleButton)
{
this->scaled_img = this->currentImg.scaled(this->currentImg.size().width(),this->currentImg.size().height());
this->scaled_img = this->currentImg->scaled(this->currentImg->size().width(),this->currentImg->size().height());
this->point = QPoint(0, 0);
this->repaint();
}
Expand All @@ -262,19 +262,19 @@ void ImgViewer::mouseDoubleClickEvent(QMouseEvent *event)
if( event->button() == Qt::LeftButton)
{
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
QList<QPixmap> img_RGB_list = this->img_list[list_index];
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
int img_index = img_RGB_list.indexOf(this->currentImg);
QString savefile_name = QFileDialog::getSaveFileName(this, "保存文件", this->filelist[list_index].replace(".ttf","-") + QString::number(img_index) + ".png", "Image files(*.png)");
if(savefile_name != nullptr)
{
this->currentImg.save(savefile_name);
this->currentImg->save(savefile_name);
}
}
else if(event->button() == Qt::RightButton)
{
this->flipRGB = this->flipRGB ? false : true;
this->point = QPoint(0, 0);
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->repaint();
}
}
Expand All @@ -292,7 +292,7 @@ void ImgViewer::wheelEvent(QWheelEvent *event)
float setpsize_x = ((float)this->scaled_img.width())/16.0f;
float setpsize_y = ((float)this->scaled_img.height())/16.0f; //缩放可能导致比例不精确

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

this->scaled_img = this->currentImg.scaled(this->scaled_img.width() - setpsize_x,this->scaled_img.height() - setpsize_y);
this->scaled_img = this->currentImg->scaled(this->scaled_img.width() - setpsize_x,this->scaled_img.height() - setpsize_y);
float new_w = event->x() - (this->scaled_img.width() * (event->x() - this->point.x())) / (this->scaled_img.width() + setpsize_x);
float new_h = event->y() - (this->scaled_img.height() * (event->y() - this->point.y())) / (this->scaled_img.height() + setpsize_y);
this->point = QPoint(new_w, new_h);
Expand All @@ -321,7 +321,7 @@ void ImgViewer::resizeEvent(QResizeEvent *event)
{
if (!this->img_list.empty())
{
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->point = QPoint(0, 0);
this->update();
}
Expand All @@ -334,7 +334,7 @@ void ImgViewer::previousImg()
{
//得到当前显示的文件序号
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
QList<QPixmap> img_RGB_list = this->img_list[list_index];
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
//得到当前显示的图像是文件的帧序号
int img_index = img_RGB_list.indexOf(this->currentImg);

Expand Down Expand Up @@ -366,7 +366,7 @@ void ImgViewer::previousImg()
this->currentImg_RGB_list = this->img_list[list_index];
this->currentImg = this->currentImg_RGB_list[img_index];
this->point = QPoint(0, 0);
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->repaint();
}
}
Expand All @@ -377,7 +377,7 @@ void ImgViewer::nextImg()
{
//得到当前显示的文件序号
int list_index = this->img_list.indexOf(this->currentImg_RGB_list);
QList<QPixmap> img_RGB_list = this->img_list[list_index];
QList<QPixmap *> img_RGB_list = this->img_list[list_index];
//得到当前显示的图像是文件的帧序号
int img_index = img_RGB_list.indexOf(this->currentImg);

Expand Down Expand Up @@ -409,7 +409,7 @@ void ImgViewer::nextImg()
this->currentImg_RGB_list = this->img_list[list_index];
this->currentImg = this->currentImg_RGB_list[img_index];
this->point = QPoint(0, 0);
this->scaled_img = this->currentImg.scaled(this->size());
this->scaled_img = this->currentImg->scaled(this->size());
this->repaint();
}
}
10 changes: 5 additions & 5 deletions src/ImgViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TTFDecodeThread : public QThread
void run();

signals:
void finsh_signal(QList<QPixmap> frame_RGB_list,QString str);
void finsh_signal(QList<QPixmap *> frame_RGB_list,QString str);

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

private slots:
void reciveimgdata(QList<QPixmap> img_RGB_list, QString filename);
void reciveimgdata(QList<QPixmap*> img_RGB_list, QString filename);
void previousImg();
void nextImg();

Expand All @@ -79,14 +79,14 @@ private slots:
QWidget *parentWindow;
bool left_click;

QList<QList<QPixmap>> img_list;
QList<QList<QPixmap *>> img_list;
QStringList filelist;

QList<TTFDecodeThread*> decode_thread;
QList<TTFDecodeThread*> decode_thread_finsh;

QList<QPixmap> currentImg_RGB_list;
QPixmap currentImg;
QList<QPixmap *> currentImg_RGB_list;
QPixmap *currentImg;
QPixmap scaled_img;
QPoint point;
QPoint startPos;
Expand Down
10 changes: 5 additions & 5 deletions src/TTFdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ QMap<QString, ttfdecoder_t> TTF2RGB::ttfdecoder_map =
{"ttf", TTF2RGB::ttf},
};

QList<QPixmap> TTF2RGB::ttf(QString ttffilename,int W, int H, int codepoint)
QList<QPixmap *> TTF2RGB::ttf(QString ttffilename,int W, int H, int codepoint)
{
QList<QPixmap> rgbImglist;
QList<QPixmap *> rgbImglist;
QString svgImg;
QByteArray naBA = ttffilename.toLatin1();

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

rgbImglist.append(svgPixmap);
Expand Down
4 changes: 2 additions & 2 deletions src/TTFdecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include <QList>
#include <QMap>

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

class TTF2RGB
{
public:
static QList<QPixmap> ttf(QString ttffilename,int W, int H, int codepoint);
static QList<QPixmap *> ttf(QString ttffilename,int W, int H, int codepoint);
static QMap<QString, ttfdecoder_t> ttfdecoder_map;
};

Expand Down
8 changes: 0 additions & 8 deletions src/TTFviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ TTFviewer::TTFviewer(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TTFviewer)
{
int currentIndex;

ui->setupUi(this);

this->setWindowTitle("TTFviewer " + VERSION);
Expand Down Expand Up @@ -119,11 +117,9 @@ TTFviewer::TTFviewer(QWidget *parent) :
}


currentIndex = 0;
QList<uint64_t> color_list;


QObject::connect(ui->TTFFormat_ComboBox, SIGNAL(currentTextChanged(const QString &)), this, SLOT(changeFormat(const QString &)));
QObject::connect(ui->frameSizeType_Combo_RadioButton, SIGNAL(clicked()), this, SLOT(configComboBox()));
QObject::connect(ui->frameSizeType_Other_RadioButton, SIGNAL(clicked()), this, SLOT(configOther()));
QObject::connect(ui->frameSizeType_ComboBox, SIGNAL(currentTextChanged(const QString &)), this,SLOT(changeFrameSizeType(const QString &)));
Expand Down Expand Up @@ -151,10 +147,6 @@ TTFviewer::~TTFviewer()
delete ui;
}

void TTFviewer::changeFormat(const QString &text)
{
}

void TTFviewer::configComboBox()
{
ui->frameSizeType_ComboBox->setEnabled(true);
Expand Down
1 change: 0 additions & 1 deletion src/TTFviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class TTFviewer : public QMainWindow
void closeEvent(QCloseEvent *event);

private slots:
void changeFormat(const QString &text);
void configComboBox();
void configOther();
void changeFrameSizeType(const QString &text);
Expand Down
2 changes: 1 addition & 1 deletion src/font_to_svg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ std::string do_outline(std::vector<FT_Vector> points, std::vector<char> tags, st

int contour_starti = 0;
int contour_endi = 0;
for ( int i = 0 ; i < contours.size() ; i++ ) {
for ( size_t i = 0 ; i < contours.size() ; i++ ) {
contour_endi = contours.at(i);
debug << "new contour starting. startpt index, endpt index:";
debug << contour_starti << "," << contour_endi << "\n";
Expand Down

0 comments on commit 8381d3a

Please sign in to comment.