From: george82 Date: Mon, 27 Mar 2006 15:20:44 +0000 (+0000) Subject: Calculate the changed pixel rect in the scaled image with X-Git-Tag: v0.0.90~384^2~331 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=256d305b41cd063e8539eb91987c737997f1af0f;p=tigervnc.git Calculate the changed pixel rect in the scaled image with calculateScaledBoundary(). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@504 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/rfb/ScaledPixelBuffer.cxx b/rfb/ScaledPixelBuffer.cxx index b566ea4e..b2304ff0 100644 --- a/rfb/ScaledPixelBuffer.cxx +++ b/rfb/ScaledPixelBuffer.cxx @@ -85,28 +85,21 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) { static U8 g0, g1, g2, g3; static U8 b0, b1, b2, b3; static double c1_sub_dx, c1_sub_dy; - static double x_start, x_end, y_start, y_end; static double dx, dy; static int i, j; + static Rect scaled_rect; // Calculate the scale boundaries - x_start = vncmax(0, (r.tl.x-1) * scale_ratio); - (x_start==int(x_start)) ? true : x_start=(int)(x_start+1); - x_end = vncmin(scaled_width - 1, r.br.x * scale_ratio); - ((x_end==int(x_end))&&(x_end!=scaled_width-1)&&(x_end>0)) ? x_end-=1:x_end=(int)(x_end); - y_start = vncmax(0, (r.tl.y-1) * scale_ratio); - (y_start==int(y_start)) ? true : y_start=(int)(y_start+1); - y_end = vncmin(scaled_height - 1, r.br.y * scale_ratio); - ((y_end==int(y_end))&&(y_end!=scaled_height-1)&&(y_end>0)) ? y_end-=1:y_end=(int)(y_end); + scaled_rect = calculateScaleBoundary(r); // Scale the source rect to the destination image buffer using // bilinear interplation - for (int y = (int)y_start; y <= y_end; y++) { + for (int y = scaled_rect.tl.y; y < scaled_rect.br.y; y++) { j = (int)(dy = y / scale_ratio); dy -= j; c1_sub_dy = 1 - dy; - for (int x = (int)x_start; x <= x_end; x++) { + for (int x = scaled_rect.tl.x; x < scaled_rect.br.x; x++) { ptr = &scaled_data[(x + y*scaled_width) * 4]; i = (int)(dx = x / scale_ratio);