donwayne28 / android-vnc-viewer

Automatically exported from code.google.com/p/android-vnc-viewer
1 stars 0 forks source link

Request: more 'minus-zoom' (as far as fit to screen) #290

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I want keep "Scaling=Zoomable", but still reach 'Fit to screen' size. Currently 
when max zoom out, I can see only half of the screen's height/width (=one 
fourth of the screen).

Original issue reported on code.google.com by aapo.rantalainen on 15 Feb 2012 at 7:32

GoogleCodeExporter commented 8 years ago
I think MinimumScale is calculated wrongly. Here is patch which works for me:

--- a/eclipse_projects/androidVNC/src/android/androidVNC/AbstractBitmapData.java
+++ b/eclipse_projects/androidVNC/src/android/androidVNC/AbstractBitmapData.java
@@ -62,15 +62,14 @@ abstract class AbstractBitmapData {
         */
        float getMinimumScale()
        {
-               double scale = 0.75;
                int displayWidth = vncCanvas.getWidth();
                int displayHeight = vncCanvas.getHeight();
-               for (; scale >= 0; scale -= 0.25)
-               {
-                       if (scale * bitmapwidth < displayWidth || scale * 
bitmapheight < displayHeight)
-                               break;
-               }
-               return (float)(scale + 0.25);
+               float scaleW = (float) displayWidth / bitmapwidth;
+               float scaleH = (float) displayHeight/ bitmapheight;
+
+               //select smaller
+               float scale = (scaleW < scaleH)?scaleW:scaleH;
+               return scale;
        }

        /**

------------------
Tested with server 1680x1050px, client 1024x600px. And then scale is about 
.57142857, I don't see reason why it should be rounded (or even rounded to the 
nearest scaling-step, now it is independent for scaling-step).

Original comment by aapo.rantalainen on 27 Mar 2012 at 12:47