Hi Geert, I have a small patch to scale-region.c that I would to have your opinion on. I noticed that the current code sometimes does an unneeded copy operation. This happens when the scale factor is 2^n. For example when an image of 800x600 pixels is scaled to 400x300. The function determine_scale() then decides that a first scale step to 400x300 needs to be made and the result is then scaled again with a scale factor of 1.0. There's even an optimization n the scale() function for this special case. Attached is a patch that changes determine_scale() to avoid this extra step. Is there anything that I am missing or do you agree that it should be safe to apply this? Sven
Index: app/paint-funcs/scale-region.c =================================================================== --- app/paint-funcs/scale-region.c (revision 26730) +++ app/paint-funcs/scale-region.c (working copy) @@ -170,7 +170,7 @@ determine_scale (PixelRegion *srcPR, *max_progress = ((height % TILE_HEIGHT) + 1) * ((width % TILE_WIDTH) + 1); /* determine scaling levels */ - while (scalex >= 2) + while (scalex > 2) { scalex /= 2; width *=2; @@ -179,7 +179,7 @@ determine_scale (PixelRegion *srcPR, ((width % TILE_WIDTH) + 1)); } - while (scaley >= 2) + while (scaley > 2) { scaley /= 2; height *= 2; @@ -188,7 +188,7 @@ determine_scale (PixelRegion *srcPR, ((width % TILE_WIDTH) + 1)); } - while (scalex <= 0.5) + while (scalex < 0.5) { scalex *= 2; width /= 2; @@ -197,7 +197,7 @@ determine_scale (PixelRegion *srcPR, ((width % TILE_WIDTH) + 1)); } - while (scaley <= 0.5) + while (scaley < 0.5) { scaley *= 2; height *= 2; @@ -370,6 +370,9 @@ scale_region_tile (PixelRegion /* determine scaling levels */ determine_scale (srcPR, dstPR, &levelx, &levely, &max_progress); + g_printerr ("%d x %d -> %d x %d: %d, %d\n", + width, height, dstPR->w, dstPR->h, levelx, levely); + if (levelx == 0 && levely == 0) { scale (srcTM, dstTM, interpolation,
_______________________________________________ Gimp-developer mailing list Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer