#include "imagezoomer.h"
#include <QtGui>
#include <qdir.h>
#include <QColor>
ImageZoomer::ImageZoomer(Ui::MainWindow *_mwin): mwin(_mwin)
{
frame
= new QFrame(mwin
->centralwidget
);
frame
->setGeometry
(QRect(60,
70,
591,
571));
frame
->setFrameShape
(QFrame::StyledPanel);
frame
->setFrameShadow
(QFrame::Plain);
canvas = new Q3Canvas(500,500);
canview = new Q3CanvasView(frame);
canview->setCanvas(canvas);
canvas->setBackgroundColor(Qt::black);
resize(500, 400);
connect(mwin->actionOpen, SIGNAL(activated()), this, SLOT(open()));
}
ImageZoomer::~ImageZoomer()
{
}
void ImageZoomer::open()
{
int x,y;
if (!filename.isEmpty())
{
if (image.isNull())
{
QMessageBox::information(this, tr
("Image Zoomer"),tr
("Cannot load %1.").
arg(filename
));
return;
}
canvas
->setBackgroundPixmap
(QPixmap::fromImage(image
));
scalefactor = 1.0;
x = image.width();
y = image.height();
canview->resizeContents(x,y);
}
}
#include "imagezoomer.h"
#include <QtGui>
#include <qdir.h>
#include <QColor>
ImageZoomer::ImageZoomer(Ui::MainWindow *_mwin): mwin(_mwin)
{
frame = new QFrame(mwin->centralwidget);
frame->setGeometry(QRect(60, 70, 591, 571));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Plain);
canvas = new Q3Canvas(500,500);
canview = new Q3CanvasView(frame);
canview->setCanvas(canvas);
canvas->setBackgroundColor(Qt::black);
resize(500, 400);
connect(mwin->actionOpen, SIGNAL(activated()), this, SLOT(open()));
}
ImageZoomer::~ImageZoomer()
{
}
void ImageZoomer::open()
{
int x,y;
QString filename = QFileDialog::getOpenFileName(this, tr("Open File"),QDir::currentPath());
if (!filename.isEmpty())
{
QImage image(filename);
if (image.isNull())
{
QMessageBox::information(this, tr("Image Zoomer"),tr("Cannot load %1.").arg(filename));
return;
}
canvas->setBackgroundPixmap(QPixmap::fromImage(image));
scalefactor = 1.0;
x = image.width();
y = image.height();
canview->resizeContents(x,y);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks