improved "zoom to fit" functionality
- fix regression in image quality for the previous zoom levels - ignore the finer-grained zoom levels when zooming manually (either with the scroll wheel or with the buttons), but use them only only for zoom to fit
This commit is contained in:
@@ -176,8 +176,8 @@ void CropHandler::setZoom (int z, int centerx, int centery)
|
||||
cw = ww * 1000 / zoom;
|
||||
ch = wh * 1000 / zoom;
|
||||
} else {
|
||||
cw = ww * zoom / 10;
|
||||
ch = wh * zoom / 10;
|
||||
cw = ww * (zoom / 10);
|
||||
ch = wh * (zoom / 10);
|
||||
}
|
||||
|
||||
cx = cax - cw / 2;
|
||||
@@ -221,8 +221,8 @@ void CropHandler::setWSize (int w, int h)
|
||||
cw = ww * 1000 / zoom;
|
||||
ch = wh * 1000 / zoom;
|
||||
} else {
|
||||
cw = ww * zoom/10;
|
||||
ch = wh * zoom/10;
|
||||
cw = ww * (zoom / 10);
|
||||
ch = wh * (zoom / 10);
|
||||
}
|
||||
|
||||
compDim ();
|
||||
@@ -320,7 +320,7 @@ void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procp
|
||||
|
||||
cropimgtrue = nullptr;
|
||||
|
||||
if (ax == cropX && ay == cropY && aw == cropW && ah == cropH && askip == (zoom >= 1000 ? 1 : zoom/10)) {
|
||||
if (ax == cropX && ay == cropY && aw == cropW && ah == cropH && askip == (zoom >= 1000 ? 1 : zoom / 10)) {
|
||||
cropimg_width = im->getWidth ();
|
||||
cropimg_height = im->getHeight ();
|
||||
cropimg = new unsigned char [3 * cropimg_width * cropimg_height];
|
||||
@@ -362,14 +362,13 @@ void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procp
|
||||
}
|
||||
|
||||
if (ch->cropimg) {
|
||||
if (ch->cix == ch->cropX && ch->ciy == ch->cropY && ch->ciw == ch->cropW && ch->cih == ch->cropH && ch->cis == (ch->zoom >= 1000 ? 1 : ch->zoom/10)) {
|
||||
if (ch->cix == ch->cropX && ch->ciy == ch->cropY && ch->ciw == ch->cropW && ch->cih == ch->cropH && ch->cis == (ch->zoom >= 1000 ? 1 : ch->zoom / 10)) {
|
||||
// calculate final image size
|
||||
//int czoom = ch->zoom < 1000 ? 1000 : ch->zoom;
|
||||
float czoom = ch->zoom >= 1000 ?
|
||||
ch->zoom / 1000.f :
|
||||
float((ch->zoom/10) * 10) / float(ch->zoom);
|
||||
int imw = ch->cropimg_width * czoom;// / 1000;
|
||||
int imh = ch->cropimg_height * czoom;// / 1000;
|
||||
int imw = ch->cropimg_width * czoom;
|
||||
int imh = ch->cropimg_height * czoom;
|
||||
|
||||
if (imw > ch->ww) {
|
||||
imw = ch->ww;
|
||||
@@ -381,12 +380,12 @@ void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procp
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> tmpPixbuf = Gdk::Pixbuf::create_from_data (ch->cropimg, Gdk::COLORSPACE_RGB, false, 8, ch->cropimg_width, 2 * ch->cropimg_height, 3 * ch->cropimg_width);
|
||||
ch->cropPixbuf = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh);
|
||||
tmpPixbuf->scale (ch->cropPixbuf, 0, 0, imw, imh, 0, 0, czoom /* / 1000.0*/, czoom /* / 1000.0*/, Gdk::INTERP_NEAREST);
|
||||
tmpPixbuf->scale (ch->cropPixbuf, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_NEAREST);
|
||||
tmpPixbuf.clear ();
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> tmpPixbuftrue = Gdk::Pixbuf::create_from_data (ch->cropimgtrue, Gdk::COLORSPACE_RGB, false, 8, ch->cropimg_width, 2 * ch->cropimg_height, 3 * ch->cropimg_width);
|
||||
ch->cropPixbuftrue = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh);
|
||||
tmpPixbuftrue->scale (ch->cropPixbuftrue, 0, 0, imw, imh, 0, 0, czoom /* / 1000.0*/, czoom /* / 1000.0*/, Gdk::INTERP_NEAREST);
|
||||
tmpPixbuftrue->scale (ch->cropPixbuftrue, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_NEAREST);
|
||||
tmpPixbuftrue.clear ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user