30 #include "../../config.h" 36 return getJPEGSize( QFile::encodeName(filename), w, h );
40 int idealWidth,
int idealHeight,
45 if(origWidth <= idealWidth &&
46 origHeight <= idealHeight)
54 float widthRatio = ((float)idealWidth) / ((float)origWidth);
55 float heightRatio = ((float)idealHeight) / ((float)origHeight);
57 if(widthRatio < heightRatio)
60 height = (int)((((
float)idealWidth) / ((
float)origWidth)) * ((float)origHeight));
65 width = (int)((((
float)idealHeight) / ((
float)origHeight)) * ((float)origWidth));
70 QImage& slideshowImage, QImage& thumbnailImage)
74 int origWidth, origHeight;
78 int thumbWidth, thumbHeight;
81 thumbWidth, thumbHeight);
83 int slideWidth, slideHeight;
86 slideWidth, slideHeight);
92 scaleImage( imageName, temp, slideWidth, slideHeight );
93 slideWidth = temp.width();
94 slideHeight = temp.height();
98 slideshowImage.fill( QColor(Qt::white).rgb() );
103 bitBlt( &slideshowImage, xDiff/2, yDiff/2,
104 &temp, 0, 0, slideWidth, slideHeight );
108 scaleImage( imageName, thumbnailImage, thumbWidth, thumbHeight );
119 QImage origImage(fileIn);
120 QImage transformedImage;
125 if(!transformedImage.create( origImage.height(), origImage.width(), origImage.depth() ) )
129 for(x=0; x < origImage.height(); x++)
131 for(y=0; y < origImage.width(); y++)
132 transformedImage.setPixel(origImage.height() - 1 - x, y, origImage.pixel(y, x) );
137 if(!transformedImage.create( origImage.height(), origImage.width(), origImage.depth() ) )
141 for(x=0; x < origImage.height(); x++)
143 for(y=0; y < origImage.width(); y++)
144 transformedImage.setPixel(x, origImage.width() - 1 - y, origImage.pixel(y, x) );
147 else if(transformation ==
FLIP_H)
148 { transformedImage = origImage.mirror(
false,
true); }
150 { transformedImage = origImage.mirror(
true,
false); }
153 transformedImage.save( fileOut,
"JPEG", 95 );
158 int newWidth,
int newHeight)
162 if(
scaleImage(fileIn, scaledImage, newWidth, newHeight ) )
164 scaledImage.save( fileOut,
"JPEG", 95 );
171 bool scaleImage(QString fileIn, QImage& scaledImage,
int targetWidth,
int targetHeight)
174 QString extension = QFileInfo(fileIn).extension(
false).lower();
175 if( extension.compare(
"jpeg") == 0 ||
176 extension.compare(
"jpg") == 0 )
177 return scaleJPEG( QFile::encodeName(fileIn), scaledImage, targetWidth, targetHeight );
182 if(QMIN( ((
float)targetWidth)/orig.width(), ((float)targetHeight)/orig.height() ) > 2)
184 targetWidth = 2*orig.width();
185 targetHeight = 2*orig.height();
188 scaledImage = orig.smoothScale( targetWidth, targetHeight, Qt::KeepAspectRatio );
204 QString extension = QFileInfo(filename).extension(
false).lower();
205 if( extension.compare(
"jpeg") == 0 ||
206 extension.compare(
"jpg") == 0 )
211 QImage image(filename);
212 width = image.width();
213 height = image.height();
219 double r = ((double)qRed(*rgb) )/255.0;
220 double g = ((double)qGreen(*rgb) )/255.0;
221 double b = ((double)qBlue(*rgb) )/255.0;
232 double *h,
double *s,
double *v )
234 double min, max, delta;
236 min = QMIN(QMIN( r, g), b );
237 max = QMAX(QMAX( r, g), b );
252 *h = ( g -
b ) / delta;
254 *h = 2 + ( b - r ) / delta;
256 *h = 4 + ( r - g ) / delta;
265 double h,
double s,
double v )
280 q = v * ( 1 - s * f );
281 t = v * ( 1 - s * ( 1 - f ) );
bool getJPEGSize(const char *filename, int &width, int &height)