/** * returns the divisor best suited to be used to meet the minimum image packet size * Since we only want to scale using whole numbers, we need to find what common divisors * are available for the given width & height. We will check those divisors to find the smallest * number (that we can divide our screen dimensions by) that would meet the minimum image * packet size required to match the count of the LEDs on the destination hyperion server. * @param width The original width of the device screen * @param height The original height of the device screen * @return int The divisor bes suited to scale the screen dimensions by **/ public int findDivisor(int width, int height) { List<Integer> divisors = getCommonDivisors(width, height); if (DEBUG) Log.d(TAG, "Available Divisors: " + divisors.toString()); ListIterator it = divisors.listIterator(divisors.size()); // iterate backwards since the divisors are listed largest to smallest while (it.hasPrevious()) { int i = (int) it.previous(); // check if the image packet size for this divisor is >= the minimum image packet size // like above we multiply the dimensions together and then by 3 for each byte in RGB if ((width / i) * (height / i) * 3 >= MINIMUM_IMAGE_PACKET_SIZE) return i; } return 1; }