Example usage for android.graphics.drawable BitmapDrawable BitmapDrawable

List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable BitmapDrawable BitmapDrawable.

Prototype

private BitmapDrawable(BitmapState state, Resources res) 

Source Link

Usage

From source file:com.android.nsboc.ComposeFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == ComposeActivity.RESULT_OK) {
        if (requestCode == ComposeActivity.REQUEST_IMAGE_CAPTURE) {
            Bundle extras = data.getExtras();
            Bitmap imageBitmap = (Bitmap) extras.get("data");

            int selectorId = data.getIntExtra("image_selector_id", -1);
            if (selectorId != -1) {
                TextView selectorLabel = (TextView) mRootView.findViewById(selectorId);
                if (selectorLabel != null) {
                    Drawable imagePreview = new BitmapDrawable(getResources(), imageBitmap);
                    selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null);
                }/*ww w  .jav a 2  s.c om*/
            }

        } else if (requestCode == ComposeActivity.REQUEST_FROM_GALLERY
                || requestCode == ComposeActivity.REQUEST_SIGNATURE) {
            Uri imageUri = data.getData();
            String imagePath = getPath(imageUri);
            Drawable imagePreview = Drawable.createFromPath(imagePath);

            int selectorId = data.getIntExtra("image_selector_id", -1);
            if (selectorId != -1) {
                TextView selectorLabel = (TextView) mRootView.findViewById(selectorId);
                if (selectorLabel != null) {
                    selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null);
                }
            }
        }
    }
}

From source file:com.example.app_2.activities.ImageGridActivity.java

private void setActionBar() {
    mActionBar = getActionBar();/*from   w w w. j  a  v a 2  s .  c  om*/
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    if (mEditMode) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(0xff0084b3));
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(true);
    } else {
        mActionBar.setBackgroundDrawable(new ColorDrawable(0xff4d055e));
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(true);
        Uri uri = Uri.parse(UserContract.CONTENT_URI + "/" + logged_user_id);
        Cursor c = getContentResolver().query(uri, new String[] { UserContract.Columns.IMG_FILENAME }, null,
                null, null);
        c.moveToFirst();
        if (!c.isAfterLast()) {
            String path = Storage.getPathToScaledBitmap(c.getString(0), 50);
            Bitmap user_icon = ScalingUtilities.decodeFile(path, 50, 50, ScalingLogic.FIT);
            mActionBar.setIcon(new BitmapDrawable(getResources(), user_icon));
        }
        c.close();
    }

    navSpinner = new ArrayList<SpinnerNavItem>();
    navSpinner.add(new SpinnerNavItem("Alfabetycznie", R.drawable.sort_ascend));
    navSpinner.add(new SpinnerNavItem("Ostatnio zmodyfikowane", R.drawable.clock));
    navSpinner.add(new SpinnerNavItem("Najczciej uywane", R.drawable.favourites));

    title_nav_adapter = new TitleNavigationAdapter(getApplicationContext(), navSpinner);
    mActionBar.setListNavigationCallbacks(title_nav_adapter, this);
}

From source file:fi.tuukka.weather.utils.Utils.java

public static void setBackGroundDrawable(Activity activity, LinearLayout layout, Bitmap bmp) {
    // int sdk = android.os.Build.VERSION.SDK_INT;
    // if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
    layout.setBackgroundDrawable(new BitmapDrawable(activity.getResources(), bmp));
    // } else {/*  w ww .  ja  va2s . co m*/
    // layout.setBackground(new BitmapDrawable(activity.getResources(), bmp));
    // }
}

From source file:com.jxlc.tajiproject.ui.MainActivity.java

private ScreenShotable replaceFragment(ScreenShotable screenShotable, int topPosition, String name) {
    // make Animation
    View view = findViewById(R.id.content_frame);
    int finalRadius = Math.max(view.getWidth(), view.getHeight());
    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(view, 0, topPosition, 0, finalRadius);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.setDuration(ViewAnimator.CIRCULAR_REVEAL_ANIMATION_DURATION);
    findViewById(R.id.content_overlay)//w w  w.j  a v  a 2  s  .co m
            .setBackground(new BitmapDrawable(getResources(), screenShotable.getBitmap()));
    animator.start();

    // switch layout
    curLayout = name;
    getSupportActionBar().setTitle(PAGENAME_MAP.get(name));
    ContentFragment newFragment = ContentFragment.newInstance(name);
    if (name.equals(TOWERCRANE) || name.equals(CONSTRUCTIONSITE)) {
        mUnityPlayer = new UnityPlayer(this);
        newFragment.setUnityPlayer(mUnityPlayer);
    }
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, newFragment).commit();
    return newFragment;
}

From source file:com.dvn.vindecoder.ui.seller.AddDriverActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == GALLERY_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (data != null) {
                uri = data.getData();/*from w ww  .  java2 s  . c  om*/
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                try {
                    // BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options);
                    options.inSampleSize = calculateInSampleSize(options, 100, 100);
                    options.inJustDecodeBounds = false;
                    Bitmap image = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null,
                            options);
                    if (check_img_status == 1) {
                        img_view_drivingLicense.setImageBitmap(image);
                    } else if (check_img_status == 2) {
                        insurance_plate_img_view.setImageBitmap(image);
                    } else if (check_img_status == 3) {
                        passport_imageView.setImageBitmap(image);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
            }
        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
        }
    } else if (requestCode == CAMERA_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (data.hasExtra("data")) {
                Bitmap bitmap = (Bitmap) data.getExtras().get("data");
                uri = getImageUri(AddDriverActivity.this, bitmap);
                File finalFile = new File(getRealPathFromUri(uri));
                //img_view_drivingLicense.setImageBitmap(bitmap);
                if (check_img_status == 1) {
                    img_view_drivingLicense.setImageBitmap(bitmap);
                } else if (check_img_status == 2) {
                    insurance_plate_img_view.setImageBitmap(bitmap);
                } else if (check_img_status == 3) {
                    passport_imageView.setImageBitmap(bitmap);
                }
            } else if (data.getExtras() == null) {

                Toast.makeText(getApplicationContext(), "No extras to retrieve!", Toast.LENGTH_SHORT).show();

                BitmapDrawable thumbnail = new BitmapDrawable(getResources(), data.getData().getPath());
                //img_view_drivingLicense.setImageDrawable(thumbnail);
                if (check_img_status == 1) {
                    img_view_drivingLicense.setImageDrawable(thumbnail);
                } else if (check_img_status == 2) {
                    insurance_plate_img_view.setImageDrawable(thumbnail);
                } else if (check_img_status == 3) {
                    passport_imageView.setImageDrawable(thumbnail);
                }
            }

        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:sjizl.com.ChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (CommonUtilities.isInternetAvailable(getApplicationContext())) //returns true if internet available
    {//from   ww w. ja  v a2s  .  c o  m

        SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE);
        pid = sp.getString("pid", null);
        naam = sp.getString("naam", null);
        username = sp.getString("username", null);
        password = sp.getString("password", null);
        foto = sp.getString("foto", null);
        foto_num = sp.getString("foto_num", null);
        Bundle bundle = getIntent().getExtras();
        pid_user = bundle.getString("pid_user");
        user = bundle.getString("user");
        user_foto_num = bundle.getString("user_foto_num");
        user_foto = bundle.getString("user_foto");

        // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show();

        if (user.equalsIgnoreCase(naam.toString())) {
            Toast.makeText(getApplicationContext(), "You can't message yourself!", Toast.LENGTH_SHORT).show();
            finish();
        }

        AbsListViewBaseActivity.imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext()));

        //registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION));
        setContentView(R.layout.activity_chat);

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d1 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "",
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        d2 = new BitmapDrawable(getResources(), loadedImage);

                    }
                });

        smilbtn = (ImageView) findViewById(R.id.smilbtn);
        listView = (ListView) findViewById(android.R.id.list);
        underlayout = (LinearLayout) findViewById(R.id.underlayout);
        smiles_layout = (LinearLayout) findViewById(R.id.smiles);
        textView1_bgtext = (TextView) findViewById(R.id.textView1_bgtext);
        textView1_bgtext.setText(user);
        imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard);
        imageView1_logo = (ImageView) findViewById(R.id.imageView1_logo);
        imageView_bericht = (ImageView) findViewById(R.id.imageView_bericht);
        textView2_under_title = (TextView) findViewById(R.id.textView2_under_title);
        right_lin = (LinearLayout) findViewById(R.id.right_lin);
        left_lin1 = (LinearLayout) findViewById(R.id.left_lin1);
        left_lin3 = (LinearLayout) findViewById(R.id.left_lin3);
        left_lin4 = (LinearLayout) findViewById(R.id.left_lin4);
        middle_lin = (LinearLayout) findViewById(R.id.middle_lin);
        smile_lin = (LinearLayout) findViewById(R.id.smile_lin);
        ber_lin = (LinearLayout) findViewById(R.id.ber_lin);
        progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole);
        progressBar_hole.setVisibility(View.INVISIBLE);
        imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto,
                imageView2_dashboard, options);
        new UpdateChat().execute();
        mNewMessage = (EditText) findViewById(R.id.newmsg);

        ber_lin = (LinearLayout) findViewById(R.id.ber_lin);
        photosend = (ImageView) findViewById(R.id.photosend);

        /*
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    
                    
                    
            imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() {
               @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        super.onLoadingComplete(imageUri, view, loadedImage);
                
        Bitmap LoadedImage2 = loadedImage;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
           if(loadedImage!=null){
        LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext());
           }
        }
                
        if (Build.VERSION.SDK_INT >= 16) {
                
           listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2));
                
          } else {
                
             listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2));
          }
                
        }
        }
            );
        }
        */
        final ImageView left_button;
        left_button = (ImageView) findViewById(R.id.imageView1_back);
        CommonUtilities u = new CommonUtilities();
        u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1,
                left_button);

        listView.setOnScrollListener(new OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                mScrollState = scrollState;
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
            }

        });
        listView.setLongClickable(true);
        registerForContextMenu(listView);

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        viewPager_smiles = new ViewPager(this);
        viewPager_smiles.setId(0x1000);
        LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams555.width = LayoutParams.MATCH_PARENT;
        layoutParams555.height = (metrics.heightPixels / 2);
        viewPager_smiles.setLayoutParams(layoutParams555);
        TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mNewMessage);
        viewPager_smiles.setAdapter(mAdapter);
        LayoutInflater inflater = null;
        viewPager_smiles.setVisibility(View.VISIBLE);
        smiles_layout.addView(viewPager_smiles);
        smiles_layout.setVisibility(View.GONE);

        left_lin4.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });
        middle_lin.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class);
                    profile.putExtra("user", user);
                    profile.putExtra("user_foto", user_foto);
                    profile.putExtra("user_foto_num", user_foto_num);
                    profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(profile);
                }
                return false;
            }
        });

        smile_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                opensmiles();
            }
        });

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent dashboard = new Intent(getApplicationContext(), ProfileActivityMain.class);
                dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                dashboard.putExtra("user", ArrChatLines.get(position).getNaam());
                dashboard.putExtra("user_foto", foto);
                dashboard.putExtra("user_foto_num", foto_num);
                startActivity(dashboard);
            }
        });

        mNewMessage.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {

                    v.setFocusable(true);
                    v.setFocusableInTouchMode(true);

                    smiles_layout.setVisibility(View.GONE);
                    smilbtn.setImageResource(R.drawable.emoji_btn_normal);
                    return false;
                }
                return false;
            }
        });

        TextWatcher textWatcher = new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                //after text changed
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                if (ArrChatLines.get(0).getblocked_profile().equals("1")) {

                } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) {

                } else {
                    CommonUtilities.startandsendwebsock(
                            "" + pid_user + " " + naam + " " + pid + " is typing to you ...");
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() {
                  @Override
                     public void onCompleted(Exception ex, WebSocket webSocket) {
                         if (ex != null) {
                   ex.printStackTrace();
                   return;
                         }
                         webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ...");
                                 
                         webSocket.close();
                     }
                 });
                 */
            }
        };

        photosend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (ArrChatLines.get(0).getblocked_profile().equals("1")) {

                } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) {

                } else {
                    openGallery(SELECT_FILE1);
                }
            }
        });

        mNewMessage.addTextChangedListener(textWatcher);

        ber_lin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText();
                Spanned cs = (Spanned) mNewMessage.getText();
                String a = Html.toHtml(spanStr);
                String text = mNewMessage.getText().toString();
                mNewMessage.setText("");
                mNewMessage.requestFocus();
                mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto;
                if (text.length() < 1) {
                } else {
                    addItem(foto, foto_num, "0", naam, text.toString(),
                            "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a);
                }
            }
        });

        hideSoftKeyboard();

    } else {

        Intent dashboard = new Intent(getApplicationContext(), NoInternetActivity.class);
        dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dashboard);

        finish();
    }
    mNewMessage.clearFocus();
    listView.requestFocus();

    final String wsuri = "ws://sjizl.com:9300";

    WebSocketConnection mConnection8 = new WebSocketConnection();

    if (mConnection8.isConnected()) {
        mConnection8.reconnect();

    } else {
        try {
            mConnection8.connect(wsuri, new WebSocketConnectionHandler() {

                @Override
                public void onOpen() {
                    Log.d("TAG", "Status: Connected to " + wsuri);

                }

                @Override
                public void onTextMessage(String payload) {

                    if (payload.contains("message send")) {
                        String[] parts = payload.split(" ");
                        String zender = parts[0];
                        String send_from = parts[1];
                        String send_name = parts[2];
                        String send_foto = parts[3];
                        String send_foto_num = parts[4];
                        String send_xxx = parts[5];

                        //      Toast.makeText(getApplication(), "" +   "\n zender: "+zender+"" +   "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" +
                        //         "\n send_from: "+send_from, 
                        //                  Toast.LENGTH_LONG).show();
                        if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) {

                            if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) {

                                //Toast.makeText(getApplication(), "uu",    Toast.LENGTH_LONG).show();

                                new UpdateChat().execute();

                            }
                        }

                    } else if (payload.contains("is typing to you")) {

                        String[] parts = payload.split(" ");
                        String part1 = parts[0]; // 004
                        is_typing_name = parts[1]; // 034556
                        if (is_typing_name.equalsIgnoreCase(user)) {

                            if (ArrChatLines.size() > 0) {
                                oldvalue = ArrChatLines.get(0).getLaatstOnline();

                            } else {
                                oldvalue = textView2_under_title.getText().toString();
                            }

                            Timer t = new Timer(false);
                            t.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText("typing ...");
                                        }
                                    });
                                }
                            }, 2);

                            Timer t2 = new Timer(false);
                            t2.schedule(new TimerTask() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            textView2_under_title.setText(oldvalue);
                                        }
                                    });
                                }
                            }, 2000);
                        }

                    }
                    Log.d("TAG", "Got echo: " + payload);
                }

                @Override
                public void onClose(int code, String reason) {
                    Log.d("TAG", "Connection lost.");
                }
            });
        } catch (WebSocketException e) {
            Log.d("TAG", e.toString());
        }
    }

}

From source file:ch.dbrgn.android.simplerepost.activities.RepostActivity.java

/**
 * Add the watermark from the specified resource file onto the
 * specified image./* www.j a v a 2  s.c o m*/
 */
private Bitmap addWatermark(String filename, int watermarkResourceFile) {
    // Read background into drawable
    BitmapDrawable background = null;
    try {
        final InputStream is = openFileInput(filename);
        background = new BitmapDrawable(getResources(), is);
        is.close();
    } catch (FileNotFoundException e) {
        ToastHelper.showShortToast(this, "Could not find downloaded image on filesystem");
        Log.e(LOG_TAG, "IOException: " + e.toString());
        return null;
    } catch (IOException e) {
        Log.w(LOG_TAG, "Could not close InputStream");
    }

    // Read watermark into Drawable
    final InputStream is = getResources().openRawResource(watermarkResourceFile);
    final BitmapDrawable watermark = new BitmapDrawable(getResources(), is);
    try {
        is.close();
    } catch (IOException e) {
        Log.w(LOG_TAG, "Could not close InputStream");
    }

    // Get dimensions
    int w = background.getBitmap().getWidth();
    int h = background.getBitmap().getHeight();

    // Create canvas for final output
    Bitmap watermarked = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(watermarked);

    // Write background onto canvas
    background.setBounds(0, 0, w, h);
    background.draw(canvas);
    background.getBitmap().recycle();

    // Write watermark onto canvas
    watermark.setBounds(0, 0, w, h);
    watermark.draw(canvas);
    watermark.getBitmap().recycle();

    return watermarked;
}

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.//ww w.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());

}

From source file:com.hunch.ImageManager.java

protected Drawable getCachedCategoryImage(final Context context, final URL url) {
    // is the drawable in the level one cache (in memory)
    Drawable drawable = getDrawableFromMemoryCache(context, url);
    if (drawable != null) {
        // we got lucky, it was in memory
        return drawable;
    }//from  w  w w.  jav  a2 s  . c om

    // otherwise check the internal file cache
    FileInputStream imageFileStream = getImageFileStreamFromInternal(context, url);

    // if the stream doesn't exist, we don't have the image cached
    if (imageFileStream == null) {
        return null;
    }

    Bitmap bitmap = BitmapFactory.decodeStream(imageFileStream);

    // add the bitmap to the in memory cache
    addToMemoryCache(bitmap, url);

    return new BitmapDrawable(context.getResources(), bitmap);
}

From source file:com.mobicage.rogerthat.plugins.messaging.FriendsThreadActivity.java

private void setThreadBackground() {
    Bitmap background = SystemPlugin.getAppAsset(mService, SystemPlugin.ASSET_CHAT_BACKGROUND);
    if (background == null) {
        findViewById(R.id.thread_container).setBackgroundResource(R.color.mc_background_color);
    } else {/*from w  ww .j a  v a2  s.c o m*/
        BitmapDrawable backgroundDrawable = new BitmapDrawable(getResources(), background);
        backgroundDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        findViewById(R.id.thread_container).setBackground(backgroundDrawable);
    }
}