AlbumShaper 1.0a3
scaledPreviewInterface.cpp
Go to the documentation of this file.
1//==============================================
2// copyright : (C) 2003-2005 by Will Stokes
3//==============================================
4// This program is free software; you can redistribute it
5// and/or modify it under the terms of the GNU General
6// Public License as published by the Free Software
7// Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//==============================================
10
11//Systemwide includes
12#include <qapplication.h>
13//Added by qt3to4:
14#include <QResizeEvent>
15#include <QDesktopWidget>
16
17//Projectwide includes
20
21//==============================================
23 QWidget *parent, const char* name ) :
24 SplitViewInterface (parent, name )
25{
26 //store original image dimensions
27 getImageSize( imageFilename, origImageSize );
28
29 //resize image to current screen size for faster
30 //scaling during resize events
31 QRect screenSize = qApp->desktop()->availableGeometry();
32 scaleImage( imageFilename, fullScreenImage, screenSize.width()/2, screenSize.height()/2 );
33 //-----
34}
35//==============================================
37{
38 //if image has yet to be set return
39 if( fullScreenImage.isNull() ) return;
40
41 //generate orig image
42 //set adjusted image to null so repain won't occur until it is reset
43 setImages( fullScreenImage.scaled( width(), height(), Qt::KeepAspectRatio ),
44 QImage() );
45
46 //emit resized signal
47 emit resized();
48}
49//==============================================
51{
52 //a 500x375 is 4:3 aspect ratio which is fairly typical
53 //we'll clamp the hight to 375 in the situation where an image is mucher taller than wide
54 //(and hence computed height would be so big window won't fit on screen)
55 int w = 500;
56 int h = QMIN( 375, (w*origImageSize.height())/origImageSize.width() );
57
58 return QSize( w,h );
59}
60//==============================================
62{
63 QSize baseMinSize = SplitViewInterface::minimumSizeHint();
64 int w = baseMinSize.width();
65 int h = QMAX( baseMinSize.height(), (w*origImageSize.height())/origImageSize.width() );
66 return QSize( w, h );
67}
68//==============================================
int width
Definition blur.cpp:79
int height
Definition blur.cpp:79
void resizeEvent(QResizeEvent *)
QImage fullScreenImage
Full screen version of image.
ScaledPreviewInterface(QString imageFilename, QWidget *parent=0, const char *name=0)
Creates layout.
virtual QSize minimumSizeHint() const
QSize origImageSize
original image dimensions
virtual QSize sizeHint() const
A split view interface provides a means to show before and after versions of an image while adjustmen...
virtual QSize minimumSizeHint() const
void setImages(QImage origImage, QImage adjustedImage)
bool scaleImage(QString fileIn, QString fileOut, int newWidth, int newHeight)
Scale image and save copy to disk.
bool getImageSize(const char *filename, QSize &size)
Get image dimensions.