123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #include "ImageScrambler.h"
- #include "ui_ImageScrambler.h"
-
-
-
-
-
-
-
- ImageScrambler::ImageScrambler(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::ImageScrambler)
- {
- ui->setupUi(this);
-
- scrambleDepth = 1 ;
-
-
-
-
-
-
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O), this, SLOT(on_btnLoadNewImage_clicked()));
-
-
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(on_btnSave_clicked()));
-
-
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(close()));
-
-
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(on_btnScrambleImage_clicked()));
-
-
- new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_D), this, SLOT(on_btnDescrambleImage_clicked()));
- ui->btnDescrambleImage->setEnabled(false);
-
- }
-
-
-
-
-
-
- ImageScrambler::~ImageScrambler()
- {
- delete ui;
- }
-
-
-
-
-
-
-
- void ImageScrambler::on_btnLoadNewImage_clicked(){
- QString fname = QFileDialog::getOpenFileName(this, tr("Choose an image"), QDir::homePath());
- if (!fname.isEmpty()){
- QImage image(fname);
- if (image.isNull())
- QMessageBox::information(this, tr("Choose an image"),tr("Cannot load %1.").arg(fname));
- originalImage=image;
- scrambledImage=image;
- ui->lblOriginalImage->setPixmap(QPixmap::fromImage(originalImage));
- ui->lblScrambleImage->setPixmap(QPixmap::fromImage(scrambledImage));
- ui->btnDescrambleImage->setEnabled(false);
- }
- }
-
-
-
-
-
-
- void ImageScrambler::on_btnSave_clicked(){
- QPixmap out = QPixmap::grabWidget(this,361,10,481,481);
- QString fname = QFileDialog::getSaveFileName(this, tr("Save Edited Image"), (""), tr("PNG (*.png)" ));
- scrambledImage.save(fname, "PNG");
- }
-
-
-
-
-
-
-
-
-
- void ImageScrambler::on_btnScrambleImage_clicked(){
-
-
- scrambleDepth = ui->scrambleDepth->value() ;
- scrambledImage = ScrambleFilter(originalImage, scrambleDepth, 0, 0, originalImage.width(),originalImage.height());
- ui->lblScrambleImage->setPixmap(QPixmap::fromImage(scrambledImage));
- ui->btnDescrambleImage->setEnabled(true);
-
- }
-
-
-
-
-
-
- void ImageScrambler::on_btnDescrambleImage_clicked(){
- scrambledImage = originalImage;
- ui->lblScrambleImage->setPixmap(QPixmap::fromImage(scrambledImage));
- }
-
-
-
-
-
-
- void ImageScrambler::on_actionLoad_Image_triggered(){
- on_btnLoadNewImage_clicked();
- }
-
-
-
-
-
-
- void ImageScrambler::on_actionSave_Image_triggered(){
- on_btnSave_clicked();
- }
-
-
-
-
-
-
- void ImageScrambler::on_actionScramble_Image_triggered(){
- on_btnScrambleImage_clicked();
- }
-
-
-
-
-
-
- void ImageScrambler::on_actionDescramble_Image_triggered(){
- on_btnDescrambleImage_clicked();
- }
|