Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AspectRatioCalculator Class Reference

#include <displayer.h>

List of all members.

Public Member Functions

 AspectRatioCalculator (int widgetWidth, int widgetHeight, int imageWidth, int imageHeight, int maxImageWidth, int maxImageHeight)
 AspectRatioCalculator (int widgetWidth, int widgetHeight, int imageWidth, int imageHeight, bool isPAL, bool isWidescreen)

Public Attributes

int x
int y
int width
int height


Constructor & Destructor Documentation

AspectRatioCalculator::AspectRatioCalculator int  widgetWidth,
int  widgetHeight,
int  imageWidth,
int  imageHeight,
int  maxImageWidth,
int  maxImageHeight
 

Definition at line 31 of file displayer.cc.

References height, width, x, and y.

00034 {
00035     double ratioWidth = ( double ) widgetWidth / ( double ) imageWidth;
00036     double ratioHeight = ( double ) widgetHeight / ( double ) imageHeight;
00037     double ratioConstant = ratioHeight < ratioWidth ?
00038                            ratioHeight : ratioWidth;
00039     width = ( int ) ( imageWidth * ratioConstant + 0.5 );
00040     height = ( int ) ( imageHeight * ratioConstant + 0.5 );
00041     if ( width > maxImageWidth )
00042         width = maxImageWidth;
00043     if ( height > maxImageHeight )
00044         height = maxImageHeight;
00045     x = ( widgetWidth - width ) / 2;
00046     y = ( widgetHeight - height ) / 2;
00047 }

AspectRatioCalculator::AspectRatioCalculator int  widgetWidth,
int  widgetHeight,
int  imageWidth,
int  imageHeight,
bool  isPAL,
bool  isWidescreen
 

Definition at line 49 of file displayer.cc.

References Preferences::displayMode, Preferences::getInstance(), height, width, x, and y.

00051 {
00052 
00053     static Preferences & prefs = Preferences::getInstance();
00054 
00055     if ( prefs.displayMode == 0 && imageWidth == 360 )
00056     {
00057         imageWidth *= 2;
00058         imageHeight *= 2;
00059     }
00060 
00061     // cerr << "Original: " << imageWidth << "x" << imageHeight << endl;
00062 
00063     if ( isWidescreen )
00064     {
00065         if ( isPAL )
00066         {
00067             // PAL: 720 x 576 at 16:9 aspect ratio: Use an image size of 1024 x 576.
00068             imageWidth = imageWidth * 1024 / 720;
00069             imageHeight = imageHeight * imageHeight / 576;
00070         }
00071         else
00072         {
00073             // NTSC: 720 x 480 at 16:9 aspect ratio: Use an image size of 854 x 480
00074             imageWidth = imageWidth * 854 / 720;
00075             imageHeight = imageHeight * imageHeight / 480;
00076         }
00077     }
00078     else
00079     {
00080         if ( isPAL )
00081         {
00082             // PAL: 720 x 576 at 4:3 aspect ratio: Use an image size of 768 x 576.
00083             imageWidth = imageWidth * 768 / 720;
00084             imageHeight = imageHeight * imageHeight / 576;
00085         }
00086         else
00087         {
00088             // NTSC: 720 x 480 at 4:3 aspect ratio: Use an image size of 720 x 540
00089             imageWidth = imageWidth * imageWidth / 720;
00090             imageHeight = imageHeight * 540 / 480;
00091         }
00092     }
00093 
00094     // cerr << "Changed : " << imageWidth << "x" << imageHeight << endl;
00095 
00096     double ratioWidth = ( double ) widgetWidth / ( double ) imageWidth;
00097     double ratioHeight = ( double ) widgetHeight / ( double ) imageHeight;
00098 
00099     if ( ratioHeight < ratioWidth )
00100     {
00101         width = ( int ) ( imageWidth * ratioHeight + 0.5 );
00102         height = ( int ) ( imageHeight * ratioHeight + 0.5 );
00103     }
00104     else
00105     {
00106         width = ( int ) ( imageWidth * ratioWidth + 0.5 );
00107         height = ( int ) ( imageHeight * ratioWidth + 0.5 );
00108     }
00109 
00110     // cerr << "Final   : " << width << "x" << height << endl;
00111     // cerr << "Ratio   : " << (double)width / (double)height << endl;
00112 
00113     x = ( widgetWidth - width ) / 2;
00114     y = ( widgetHeight - height ) / 2;
00115 }


Member Data Documentation

int AspectRatioCalculator::height
 

Definition at line 58 of file displayer.h.

Referenced by AspectRatioCalculator(), ExportStills::doExport(), GdkDisplayer::put(), XvDisplayer::put(), PageCapture::saveFrame(), KinoCommon::saveFrame(), and KinoCommon::setPreviewSize().

int AspectRatioCalculator::width
 

Definition at line 57 of file displayer.h.

Referenced by AspectRatioCalculator(), ExportStills::doExport(), GdkDisplayer::put(), XvDisplayer::put(), PageCapture::saveFrame(), KinoCommon::saveFrame(), and KinoCommon::setPreviewSize().

int AspectRatioCalculator::x
 

Definition at line 55 of file displayer.h.

Referenced by AspectRatioCalculator(), and XvDisplayer::put().

int AspectRatioCalculator::y
 

Definition at line 56 of file displayer.h.

Referenced by AspectRatioCalculator(), and XvDisplayer::put().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:12:43 2007 for Kino by  doxygen 1.4.2