[KPhotoAlbum] Latest patch
Robert L Krawitz
rlk at alum.mit.edu
Sun Jul 9 17:36:40 BST 2006
From: "Jesper K. Pedersen" <blackie at blackie.dk>
Date: Sun, 9 Jul 2006 13:03:00 +0200
Finally, I loaded in a big image, and zoomed out of it till it was
smaller than the screen, and suddenly my computer froze, could you
please check if we end up creating huge pixmaps to show them really
tiny, or what goes on here.
This solves that problem.
BTW, I'm not going to have a chance to do much more work on this for a
while -- I'm going to be out all afternoon and then it's back to work.
void Viewer::DisplayArea::cropAndScale()
{
ViewPreloadInfo* info = _cache[_curIndex];
if ( info && info->angle == _info->angle() ) {
_croppedAndScaledImg = info->img;
_zEnd = QPoint( info->size.width(), info->size.height() );
_cachedView = true;
}
else {
if ( _loadedImage.isNull() || _cachedView ) {
return;
}
if ( _zStart != QPoint(0,0) || _zEnd != QPoint( _loadedImage.width(), _loadedImage.height() ) ) {
QPoint zSpan = _zEnd - _zStart;
if (zSpan.x() > width() && zSpan.y() > height() &&
zSpan.x() > _loadedImage.width() &&
zSpan.y() > _loadedImage.height()) {
double wRatio = zSpan.x() / (double) width();
double hRatio = zSpan.y() / (double) height();
double ratio = wRatio > hRatio ? wRatio : hRatio;
int dWidth = (int) (_loadedImage.width() / ratio);
int dHeight = (int) (_loadedImage.height() / ratio);
QImage tImage = Utilities::scaleImage(_loadedImage,
dWidth, dHeight,
QImage::ScaleMin);
_croppedAndScaledImg = tImage.copy( (int) (_zStart.x() / ratio),
(int) (_zStart.y() / ratio),
(int) (zSpan.x() / ratio),
(int) (zSpan.y() / ratio));
} else {
_croppedAndScaledImg = _loadedImage.copy( _zStart.x(), _zStart.y(), _zEnd.x() - _zStart.x(), _zEnd.y() - _zStart.y() );
}
}
else
_croppedAndScaledImg = _loadedImage;
if ( !_croppedAndScaledImg.isNull() ) // I don't know how this can happen, but it seems not to be dangerous.
_croppedAndScaledImg = Utilities::scaleImage(_croppedAndScaledImg, width(), height(), QImage::ScaleMin);
}
drawAll();
}
More information about the Kphotoalbum
mailing list