Example usage for android.widget RelativeLayout getGlobalVisibleRect

List of usage examples for android.widget RelativeLayout getGlobalVisibleRect

Introduction

In this page you can find the example usage for android.widget RelativeLayout getGlobalVisibleRect.

Prototype

public final boolean getGlobalVisibleRect(Rect r) 

Source Link

Usage

From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java

/**
 * Pulls the bitmap image of the body part out of its RelativeLayout, colors it appropriatly,
 * and then tells the zoomLayout where it needs to zoom to. Also swaps the FRONT/BACK buttons
 * for the ADD/DELETE buttons./*  w ww .j a  v  a 2 s.com*/
 *
 * @param image the body part the touch occured in.
 */
private void zoomOnImage(RelativeLayout image) {

    Bitmap bitm = ((BitmapDrawable) image.getBackground()).getBitmap();

    Bitmap temp = bitm.copy(bitm.getConfig(), true);
    int[] pixels = new int[temp.getHeight() * temp.getWidth()];

    temp.getPixels(pixels, 0, temp.getWidth(), 0, 0, temp.getWidth(), temp.getHeight());

    for (int i = 0; i < temp.getHeight() * temp.getWidth(); i++) {

        if (pixels[i] != 0) {

            int r, g, b;

            if (!blue) {
                r = Color.red(pixels[i]) + 100;
                if (r > 255) {
                    r = 255;
                }
                g = Color.green(pixels[i]) - 50;
                b = Color.blue(pixels[i]) - 50;
            } else {
                r = Color.red(pixels[i]) - 30;
                g = Color.green(pixels[i]) + 15;
                b = Color.blue(pixels[i]) + 100;
                if (b > 255) {
                    b = 255;
                }

            }
            pixels[i] = Color.argb(Color.alpha(pixels[i]), r, g, b);
        }
    }

    temp.setPixels(pixels, 0, temp.getWidth(), 0, 0, temp.getWidth(), temp.getHeight());
    image.setBackground(new BitmapDrawable(getResources(), temp));

    Rect rect = new Rect();
    image.getGlobalVisibleRect(rect);

    zoomLayout.zoomToRect(rect, 0, getYOffset());
    current = image;
    zoomed = true;
    swapButtons();

    placePointer(rect.centerX(), rect.centerY());

}