List of usage examples for android.graphics.drawable BitmapDrawable getBitmap
public final Bitmap getBitmap()
From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java
private void saveImageToGallery() { BitmapDrawable drawable = (BitmapDrawable) mImageView.getDrawable(); if (drawable != null) { String title = ImageWorker.getTitle(); String url = MediaStore.Images.Media.insertImage(getContentResolver(), drawable.getBitmap(), title, null);//from w w w. j a v a2 s.co m GalleryWorker.add(title, Uri.parse(url)); } }
From source file:com.hackvg.android.views.activities.MoviesActivity.java
@Override public void onClick(View touchedView, int moviePosition, float touchedX, float touchedY) { Intent movieDetailActivityIntent = new Intent(MoviesActivity.this, MovieDetailActivity.class); String movieID = mMoviesAdapter.getMovieList().get(moviePosition).getId(); movieDetailActivityIntent.putExtra(EXTRA_MOVIE_ID, movieID); movieDetailActivityIntent.putExtra(EXTRA_MOVIE_POSITION, moviePosition); ImageView mCoverImage = (ImageView) touchedView.findViewById(R.id.item_movie_cover); BitmapDrawable bitmapDrawable = (BitmapDrawable) mCoverImage.getDrawable(); if (mMoviesAdapter.isMovieReady(moviePosition) || bitmapDrawable != null) { sPhotoCache.put(0, bitmapDrawable.getBitmap()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) startDetailActivityBySharedElements(touchedView, moviePosition, movieDetailActivityIntent); else/*from w ww . ja v a 2 s. c o m*/ startDetailActivityByAnimation(touchedView, (int) touchedX, (int) touchedY, movieDetailActivityIntent); } else { Toast.makeText(this, getString(R.string.activity_movies_message_loading_film), Toast.LENGTH_SHORT) .show(); } }
From source file:com.waveface.installer.util.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. *//*w w w .j a v a2 s . c o m*/ private void forceDownload(String url, ImageView imageView, int resId) { // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys. BitmapDrawable draw = (BitmapDrawable) mContext.getResources().getDrawable(resId); Bitmap bm = draw.getBitmap(); if (url == null) { imageView.setImageBitmap(bm); return; } if (cancelPotentialDownload(url, imageView)) { switch (mode) { case NO_ASYNC_TASK: Bitmap bitmap = downloadBitmap(url); addBitmapToCache(url, bitmap); imageView.setImageBitmap(bitmap); break; case NO_DOWNLOADED_DRAWABLE: imageView.setMinimumHeight(156); BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); task.execute(url); break; case CORRECT: task = new BitmapDownloaderTask(imageView); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, bm); imageView.setImageDrawable(downloadedDrawable); task.execute(url); break; } } }
From source file:com.cypress.cysmart.BLEServiceFragments.RGBFragment.java
/** * Method to set up the GAMOT view/*from www . j ava 2 s. c om*/ */ void setUpControls() { mRGBcanavs = (ImageView) rootView.findViewById(R.id.imgrgbcanvas); mcolorpicker = (ImageView) rootView.findViewById(R.id.imgcolorpicker); mTextalpha = (TextView) rootView.findViewById(R.id.txtintencity); mTextred = (TextView) rootView.findViewById(R.id.txtred); mTextgreen = (TextView) rootView.findViewById(R.id.txtgreen); mTextblue = (TextView) rootView.findViewById(R.id.txtblue); mColorindicator = (ImageView) rootView.findViewById(R.id.txtcolorindicator); mViewContainer = (ViewGroup) rootView.findViewById(R.id.viewgroup); mIntencityBar = (SeekBar) rootView.findViewById(R.id.intencitychanger); mProgressDialog = new ProgressDialog(getActivity()); mParent = (RelativeLayout) rootView.findViewById(R.id.parent); mParent.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub } }); BitmapDrawable bmpdwbl = (BitmapDrawable) mRGBcanavs.getDrawable(); mBmp = bmpdwbl.getBitmap(); Drawable d = getResources().getDrawable(R.drawable.gamut); mRGBcanavs.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP) { float x = event.getX(); float y = event.getY(); if (x >= 0 && y >= 0) { int x1 = (int) x; int y1 = (int) y; if (x < mBmp.getWidth() && y < mBmp.getHeight()) { int p = mBmp.getPixel(x1, y1); if (p != 0) { if (x > mRGBcanavs.getMeasuredWidth()) x = mRGBcanavs.getMeasuredWidth(); if (y > mRGBcanavs.getMeasuredHeight()) y = mRGBcanavs.getMeasuredHeight(); setwidth(1.f / mRGBcanavs.getMeasuredWidth() * x); setheight(1.f - (1.f / mRGBcanavs.getMeasuredHeight() * y)); r = Color.red(p); g = Color.green(p); b = Color.blue(p); UIupdation(); isReaded = false; moveTarget(); return true; } } } } return false; } }); intensity = mIntencityBar.getProgress(); mTextalpha.setText(String.format("0x%02x", intensity)); // Seek bar progress change listener mIntencityBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { intensity = progress; UIupdation(); isReaded = false; } public void onStartTrackingTouch(SeekBar seekBar) { } public void onStopTrackingTouch(SeekBar seekBar) { isReaded = false; BluetoothLeService.writeCharacteristicRGB(mReadCharacteristic, r, g, b, intensity); } }); }
From source file:com.android.datacloud.Entity.java
/** * Devuelve un bitmap del recurso en la aplicacin * /*from w w w . ja va 2 s. c o m*/ * @param name nombre del campo * @return valor (Tipo bitmap) */ public Bitmap getBitmap(String name) { int id = DataCloud.getInstance().getContext().getResources().getIdentifier( DataCloud.getInstance().getPackage() + ":drawable/" + getValue(name).toString(), null, null); java.io.InputStream is = DataCloud.getInstance().getContext().getResources().openRawResource(id); BitmapDrawable bmd = new BitmapDrawable(BitmapFactory.decodeStream(is)); return bmd.getBitmap(); }
From source file:rhcad.touchvg.view.internal.ImageCache.java
public final Bitmap getBitmap(String name) { BitmapDrawable drawable = null; try {//from w ww . j av a 2 s.c om drawable = (BitmapDrawable)(mCache != null ? mCache.get(name) : null); } catch (ClassCastException e) { Log.v(TAG, "Not BitmapDrawable(getImage)", e); } return drawable != null ? drawable.getBitmap() : null; }
From source file:com.github.programmerr47.vkgroups.imageloading.ImageWorker.java
private Drawable postProcessDrawable(BitmapDrawable drawable, LoadBitmapParams loadingParams) { if (loadingParams.isRound) { Bitmap sourceBitmap = drawable.getBitmap(); RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(mResources, sourceBitmap); roundDrawable.setCircular(true); return roundDrawable; } else {//from w ww . j a v a 2s . c o m return drawable; } }
From source file:com.facebook.samples.rps.RpsFragment.java
public void shareUsingNativeDialog() { if (playerChoice == INVALID_CHOICE || computerChoice == INVALID_CHOICE) { FacebookDialog.ShareDialogBuilder builder = new FacebookDialog.ShareDialogBuilder(getActivity()) .setLink(SHARE_GAME_LINK).setName(SHARE_GAME_NAME).setFragment(this); // share the app if (builder.canPresent()) { builder.build().present();//from ww w .j a v a 2 s. c o m } } else { ThrowAction throwAction = OpenGraphAction.Factory.createForPost(ThrowAction.class, ThrowAction.TYPE); throwAction.setGesture(getBuiltInGesture(playerChoice)); throwAction.setOpposingGesture(getBuiltInGesture(computerChoice)); // The OG objects have their own bitmaps we could rely on, but in order to demonstrate attaching // an in-memory bitmap (e.g., a game screencap) we'll send the bitmap explicitly ourselves. ImageButton view = gestureImages[playerChoice]; BitmapDrawable drawable = (BitmapDrawable) view.getBackground(); Bitmap bitmap = drawable.getBitmap(); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder( getActivity(), throwAction, ThrowAction.PREVIEW_PROPERTY_NAME).setFragment(this) .setImageAttachmentsForAction(Arrays.asList(bitmap)); // share the game play if (builder.canPresent()) { builder.build().present(); } } }
From source file:com.facebook.samples.rps.RpsFragment.java
public void shareUsingMessengerDialog() { if (playerChoice == INVALID_CHOICE || computerChoice == INVALID_CHOICE) { FacebookDialog.MessageDialogBuilder builder = new FacebookDialog.MessageDialogBuilder(getActivity()) .setLink(SHARE_GAME_LINK).setName(SHARE_GAME_NAME).setFragment(this); // share the app if (builder.canPresent()) { builder.build().present();/*w ww .j a v a2 s . c om*/ } } else { ThrowAction throwAction = OpenGraphAction.Factory.createForPost(ThrowAction.class, ThrowAction.TYPE); throwAction.setGesture(getBuiltInGesture(playerChoice)); throwAction.setOpposingGesture(getBuiltInGesture(computerChoice)); // The OG objects have their own bitmaps we could rely on, but in order to demonstrate attaching // an in-memory bitmap (e.g., a game screencap) we'll send the bitmap explicitly ourselves. ImageButton view = gestureImages[playerChoice]; BitmapDrawable drawable = (BitmapDrawable) view.getBackground(); Bitmap bitmap = drawable.getBitmap(); FacebookDialog.OpenGraphMessageDialogBuilder builder = new FacebookDialog.OpenGraphMessageDialogBuilder( getActivity(), throwAction, ThrowAction.PREVIEW_PROPERTY_NAME).setFragment(this) .setImageAttachmentsForAction(Arrays.asList(bitmap)); // share the game play if (builder.canPresent()) { builder.build().present(); } } }
From source file:madiyarzhenis.kz.universityguide.information.details.FlexibleSpaceWithImageWithViewPagerTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flexiblespacewithimagewithviewpagertab); final Intent intent = getIntent(); mPager = (ViewPager) findViewById(R.id.pager); imageView = (ImageView) findViewById(R.id.image); mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height); mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height); progressBar = (ProgressBar) findViewById(R.id.progressBarInformation); final TextView titleView = (TextView) findViewById(R.id.title); gson = new Gson(); relativeLayout = (RelativeLayout) findViewById(R.id.gradientImage); frameLayout = (FrameLayout) findViewById(R.id.root); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); parameter = new HashMap<String, Object>(); parameter.put("university_id", intent.getStringExtra("objectId")); Log.i("objectId", intent.getStringExtra("objectId")); if (isOnline()) { ParseCloud.callFunctionInBackground("university", parameter, new FunctionCallback<Object>() { public void done(Object response, ParseException e) { // arrayList = new ArrayList<>(); // objectIDArray.clear(); if (e != null) { Log.i("E", "error"); Log.e("Exception", e.toString()); } else { String json = gson.toJson(response); if (json.equals("[]")) { Log.i("json", "null"); Log.i("json_null", json); } else { Log.i("JSON_UNIVERSITY_ABOUT", json); }//w w w . j av a 2 s .co m try { JSONArray jsonArray = new JSONArray(json); JSONObject jsonObject = jsonArray.getJSONObject(0); JSONObject estimatedData = jsonObject.getJSONObject("estimatedData"); JSONObject jsonImage = estimatedData.getJSONObject("image"); String imageUrl = jsonImage.getString("url"); final String aboutUs = estimatedData.getString("about_us"); final String magistratura = estimatedData.getString("magistratura"); final String dormitory = estimatedData.getString("dormitory"); final String abiturient = estimatedData.getString("abiturient"); final String photo_gallery = estimatedData.getString("photo_gallery"); final String video_gallery = estimatedData.getString("video_gallery"); final String faculty = estimatedData.getString("faculty"); final String map = estimatedData.getString("map"); final String phone_number = estimatedData.getString("phone_number"); Picasso.with(FlexibleSpaceWithImageWithViewPagerTabActivity.this).load(imageUrl) .into(imageView, new Callback() { @Override public void onSuccess() { titleView.setText(intent.getStringExtra("name")); progressBar.setVisibility(View.GONE); BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable(); Bitmap bitmap = drawable.getBitmap(); ColorArt colorArt = new ColorArt(bitmap); // frameLayout.setBackgroundColor(colorArt.getBackgroundColor()); // GradientDrawable gd = new GradientDrawable( // GradientDrawable.Orientation.TOP_BOTTOM, // new int[]{0x00000000, colorArt.getBackgroundColor()}); // gd.setCornerRadius(0f); // relativeLayout.setBackgroundDrawable(gd); mPagerAdapter = new NavigationAdapter(getSupportFragmentManager(), aboutUs, abiturient, magistratura, dormitory, photo_gallery, video_gallery, faculty, map, phone_number, colorArt.getBackgroundColor()); mPager.setAdapter(mPagerAdapter); mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); mSlidingTabLayout.setSelectedIndicatorColors( getResources().getColor(R.color.accent)); mSlidingTabLayout.setDistributeEvenly(true); mSlidingTabLayout.setViewPager(mPager); } @Override public void onError() { } }); } catch (JSONException e1) { e1.printStackTrace(); } } } }); } else { Toast.makeText(getApplicationContext(), getString(R.string.no_connection), Toast.LENGTH_SHORT).show(); } // BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable(); // Bitmap bitmap = drawable.getBitmap(); // Log.i("COLOR=", getDominantColor1(bitmap) + ""); // Initialize the first Fragment's state when layout is completed. ScrollUtils.addOnGlobalLayoutListener(mSlidingTabLayout, new Runnable() { @Override public void run() { translateTab(0, false); } }); }