123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- #include "ImageconvertTool.h"
- imageconverttool::imageconverttool(QWidget *parent) : ToolInterface(parent), ui(new Ui::imageconverttool)
- {
- ui->setupUi(this);
- ui->label2->setVisible(false);
- ui->comboBox_port->setVisible(false);
- ui->comboBox->setView(new QListView());
- ui->comboBox_port->setView(new QListView());
- }
- imageconverttool::~imageconverttool()
- {
- delete ui;
- }
- bool imageconverttool::Serialized(QDataStream& ar, bool bIsOut)
- {
- int paranum;//参数数量
- if (bIsOut)//保存参数流程
- {
- paranum = 1;
- ar << paranum;//先保存参数数量
- ar << (int)1 << ui->comboBox->currentIndex();
- }
- else//加载参数流程,参数加载顺序一定要跟保存顺序一致
- {
- int nCurrentIndex = 0;
- int para;
- ar >> paranum;//读取参数数量
- for (int i = 0; i < paranum; i++)
- {
- ar >> para;
- switch (para)
- {
- case 1: ar >> nCurrentIndex; break;
- default:
- {
- qWarning() << "Serialized(In) Error";
- return false;
- }
- break;
- }
- }
- {
- ui->comboBox->setCurrentIndex(nCurrentIndex);
-
- emit updateParameter(ShowParameter());
- }
- }
- return true;
- }
- QString imageconverttool::ShowParameter()
- {
- QString str;
- str += ui->comboBox->currentText();
- if(ui->comboBox_port->currentIndex() >= 0)
- {
- str += ",";
- str += ui->comboBox_port->currentText();
- }
- return str;
- }
- int imageconverttool::Execute()
- {
- int result = 1;
- try
- {
- if(ui->comboBox->currentIndex() == 0)
- {
- Rgb1ToGray(m_InImage, &m_OutImage);
- }
- if(ui->comboBox->currentIndex() == 1)
- {
- HObject result1, result2;
- if(ui->comboBox_port->currentIndex() == 0)
- {
- Decompose3(m_InImage, &m_OutImage, &result1, &result2);
- }
- if(ui->comboBox_port->currentIndex() == 1)
- {
- Decompose3(m_InImage, &result1, &m_OutImage, &result2);
- }
- if(ui->comboBox_port->currentIndex() == 2)
- {
- Decompose3(m_InImage, &result1, &result2, &m_OutImage);
- }
- }
- if(ui->comboBox->currentIndex() == 2)
- {
- HObject result1, result2;
- if(ui->comboBox_port->currentIndex() == 0)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &m_OutImage, &result1, &result2, "hsv");
- }
- if(ui->comboBox_port->currentIndex() == 1)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &m_OutImage, &result2, "hsv");
- }
- if(ui->comboBox_port->currentIndex() == 2)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &result2, &m_OutImage, "hsv");
- }
- }
- if(ui->comboBox->currentIndex() == 3)
- {
- HObject result1, result2;
- if(ui->comboBox_port->currentIndex() == 0)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &m_OutImage, &result1, &result2, "hsi");
- }
- if(ui->comboBox_port->currentIndex() == 1)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &m_OutImage, &result2, "hsi");
- }
- if(ui->comboBox_port->currentIndex() == 2)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &result2, &m_OutImage, "hsi");
- }
- }
- if(ui->comboBox->currentIndex() == 4)
- {
- HObject result1, result2;
- if(ui->comboBox_port->currentIndex() == 0)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &m_OutImage, &result1, &result2, "yuv");
- }
- if(ui->comboBox_port->currentIndex() == 1)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &m_OutImage, &result2, "yuv");
- }
- if(ui->comboBox_port->currentIndex() == 2)
- {
- TransToRgb(m_InImage, m_InImage, m_InImage, &result1, &result2, &m_OutImage, "yuv");
- }
- }
- }
- catch(...)
- {
- }
- return result;
- }
- void imageconverttool::on_comboBox_currentIndexChanged(int index)
- {
- ui->comboBox_port->setCurrentIndex(0);
- if(index > 0)
- {
- ui->label2->setVisible(true);
- ui->comboBox_port->setVisible(true);
- }
- else
- {
- ui->label2->setVisible(false);
- ui->comboBox_port->setVisible(false);
- }
- emit updateParameter(ShowParameter());
- }
- void imageconverttool::on_comboBox_port_currentIndexChanged(int index)
- {
- emit updateParameter(ShowParameter());
- }
|