@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.btn_apply: try { wallpaperManager.setBitmap(mWall.getDrawingCache()); } catch (IOException e) { e.printStackTrace(); } break; } }
public String encodeImageView(ImageView imageview) { String imageString = ""; try { imageview.setDrawingCacheEnabled(true); Bitmap bitmap = imageview.getDrawingCache(); imageString = encodeBitmap(bitmap); imageview.setDrawingCacheEnabled(false); } catch (Exception e) { e.printStackTrace(); } return imageString; }
// the following method is based on the camera control activity from the lecture notes private void saveSnap() { // Commit all the changes into preference file // Save profile image into internal storage. mProPic.buildDrawingCache(); Bitmap bmap = mProPic.getDrawingCache(); try { FileOutputStream fos = openFileOutput(getString(R.string.profile_photo_file_name), MODE_PRIVATE); bmap.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } catch (IOException ioe) { ioe.printStackTrace(); } }
public int getHotspotColor(int hotspotId, int x, int y) { ImageView img = (ImageView) findViewById(hotspotId); if (img == null) { Log.d("ImageAreasActivity", "Hot spot image not found"); return 0; } else { img.setDrawingCacheEnabled(true); Bitmap hotspots = Bitmap.createBitmap(img.getDrawingCache()); if (hotspots == null) { Log.d("ImageAreasActivity", "Hot spot bitmap was not created"); return 0; } else { img.setDrawingCacheEnabled(false); return hotspots.getPixel(x, y); } } }
private File getImageBitmap() { mImageView.setDrawingCacheEnabled(true); Bitmap bitmap = mImageView.getDrawingCache(); File filepath = Environment.getExternalStorageDirectory(); File dir = new File(filepath.getAbsolutePath() + "/Pictures/TechTatva15/"); dir.mkdirs(); count = getSharedPreferenceInteger(getApplicationContext(), "COUNT"); File file = new File(dir, "IMG_INSTA_" + String.valueOf(count) + ".png"); OutputStream output; try { output = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.PNG, 100, output); output.flush(); output.close(); f = true; } catch (Exception e) { e.printStackTrace(); f = false; } return file; }
public Bitmap getVisibleRectangleBitmap() { ImageView imageView = getImageView(); return imageView == null ? null : imageView.getDrawingCache(); }