code_app/app/scanner/dialog_wrong_img.cpp

75 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "dialog_wrong_img.h"
#include "ui_dialog_wrong_img.h"
#include "sane/sane_ex.h"
#include "imgfmt/HGImgFmt.h"
dialog_wrong_img::dialog_wrong_img(QWidget *parent, QString img_file, int index, int statu)
: QDialog(parent)
, ui(new Ui::Dialog_wrong_img)
, save_(false), img_file_(img_file), index_(index), statu_(statu)
{
ui->setupUi(this);
// connect(pbtn_stop, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_stop_clicked()));
if(statu == SANE_Image_Statu_Double) // 双张图片,请确认是否要保留
setWindowTitle(QString::fromStdString("\345\217\214\345\274\240\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231"));
else if(statu == SANE_Image_Statu_Jammed) // 卡纸图片,请确认是否要保留
setWindowTitle(QString::fromStdString("\345\215\241\347\272\270\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231"));
else {
// 异常(%d图片请确认是否要保留
char msg[256] = {0};
sprintf(msg, "\345\274\202\345\270\270\357\274\210%d\357\274\211\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231", statu);
setWindowTitle(QString::fromStdString(msg));
}
view_ = new HGImgView(this);
view_->setFixedSize(300, 200);
HGImage img = nullptr;
HGImgFmtReader imgFmtReader = nullptr;
HGImgFmt_OpenImageReader(img_file.toStdString().c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)0, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_CloseImageReader(imgFmtReader);
view_->addImage(img);
HGBase_DestroyImage(img);
}
}
dialog_wrong_img::~dialog_wrong_img()
{
delete ui;
}
QString dialog_wrong_img::image_file(void)
{
return img_file_;
}
int dialog_wrong_img::index(void)
{
return index_;
}
int dialog_wrong_img::increase_index(void)
{
return ++index_;
}
void dialog_wrong_img::closeEvent(QCloseEvent *event)
{
emit handle_wrong_img(this, save_);
}
void dialog_wrong_img::on_buttonBox_accepted()
{
save_ = true;
close();
}
void dialog_wrong_img::on_buttonBox_rejected()
{
save_ = false;
close();
}