List of usage examples for android.graphics PixelFormat OPAQUE
int OPAQUE
To view the source code for android.graphics PixelFormat OPAQUE.
Click Source Link
From source file:Main.java
public static Bitmap drawableToBitmap(Drawable drawable, float ratio) { int width = (int) Math.ceil(drawable.getIntrinsicWidth() * ratio); int height = (int) Math.ceil(drawable.getIntrinsicHeight() * ratio); Bitmap bitmap = Bitmap.createBitmap(width, height, drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); canvas.scale(ratio, ratio);/*w w w. ja v a2 s .co m*/ drawable.setBounds(0, 0, width, height); drawable.draw(canvas); return bitmap; }
From source file:Main.java
public static Bitmap drawableToBitmap(Drawable drawable) { if (drawable == null) { return null; }//from w w w . ja v a2s . c o m int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; Bitmap bitmap = Bitmap.createBitmap(w, h, config); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); drawable.draw(canvas); return bitmap; }
From source file:Main.java
public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas);/*from w ww . j ava2 s. co m*/ return bitmap; }
From source file:org.videolan.vlc.gui.view.PopupLayout.java
@SuppressWarnings("deprecation") private void init(Context context) { mWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.video_pip_width), VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.video_pip_heigth), WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.OPAQUE); params.gravity = Gravity.BOTTOM | Gravity.START; params.x = 50;//from ww w . ja v a 2s . co m params.y = 50; if (AndroidUtil.isHoneycombOrLater()) mScaleGestureDetector = new ScaleGestureDetector(context, this); setOnTouchListener(this); mWindowManager.addView(this, params); mLayoutParams = (WindowManager.LayoutParams) getLayoutParams(); updateWindowSize(); }
From source file:bruce.kk.imglibcompare.glide.GlideActivity.java
@OnClick({ R.id.btn_load_local, R.id.btn_load_url, R.id.btn_load_cancel }) public void onClick(View view) { switch (view.getId()) { case R.id.btn_load_local: Glide.with(GlideActivity.this).load(R.mipmap.ic_loading).into(ivImg); break;//from www .j ava 2 s .c om case R.id.btn_load_url: Glide.with(GlideActivity.this).load(ImgConstant.GIF_URL).centerCrop().placeholder(R.mipmap.ic_loading2) .error(R.mipmap.ic_failed) // tansform .transform(new BitmapTransformation(GlideActivity.this) { @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), toTransform); drawable.setCornerRadius(20); // drawable.setCircular(true); // ? // ? int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); // ?? Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; // bitmap Bitmap bitmap = Bitmap.createBitmap(width, height, config); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, width, height); drawable.draw(canvas); return bitmap; } @Override public String getId() { return "1001"; } }).crossFade().listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { LogDetails.i("model: %s\ntarget: %s\nisFirstResource: %s\nException: %s", model, target, isFirstResource, e); target.onLoadFailed(new Exception("load failed, please check your code"), getResources().getDrawable(R.mipmap.ic_failed)); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { LogDetails.i( "model: %s\ntarget: %s\nisFirstResource: %s\nisFromMemoryCache: %s\nresource: %s", model, target, isFirstResource, isFromMemoryCache, resource); target.onLoadStarted(getResources().getDrawable(R.mipmap.ic_start)); return false; } }).into(ivImg); break; case R.id.btn_load_cancel: Glide.clear(ivImg); break; } }
From source file:bruce.kk.imglibcompare.picasso.PicassoActivity.java
@OnClick({ R.id.btn_load_local, R.id.btn_load_url, R.id.btn_load_cancel }) public void onClick(View view) { switch (view.getId()) { case R.id.btn_load_local: Picasso.with(PicassoActivity.this).load(R.mipmap.ic_loading).into(ivImg); break;//from w w w. j a va 2 s. com case R.id.btn_load_url: // // Picasso.with(PicassoActivity.this) // .load(ImgConstant.IMG_URL) // .resize(80, 80) // .error(R.mipmap.ic_failed) // .into(ivImg); // Picasso.Builder builder = new Picasso.Builder(PicassoActivity.this); builder.listener(new Picasso.Listener() { @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { LogDetails.d(" exception: " + exception); } }); builder.build().load(ImgConstant.IMG_URL) // .load("http://dd.com/ssss.jpg") .placeholder(R.mipmap.ic_loading2).error(R.mipmap.ic_failed) // tansform .transform(new Transformation() { @Override public Bitmap transform(Bitmap source) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), source); drawable.setCornerRadius(50); // drawable.setCircular(true); // ? // ? int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); // ?? Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; // bitmap Bitmap bitmap = Bitmap.createBitmap(width, height, config); if (bitmap != source) { source.recycle(); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, width, height); drawable.draw(canvas); return bitmap; } @Override public String key() { return "rounded"; } }).into(ivImg); break; case R.id.btn_load_cancel: Picasso.with(PicassoActivity.this).cancelRequest(ivImg); break; } }
From source file:net.yanzm.actionbarprogress.MaterialIndeterminateProgressDrawable.java
@Override public int getOpacity() { int trackColorAlpha = trackColor >>> 24; int accentColorAlpha = accentColor >>> 24; if (trackColorAlpha == 255 && accentColorAlpha == 255) { return PixelFormat.OPAQUE; }//from w w w . j a v a 2s . c om if (trackColorAlpha == 0 && accentColorAlpha == 0) { return PixelFormat.TRANSPARENT; } return PixelFormat.TRANSLUCENT; }
From source file:com.dv.Utils.Tools.java
/** * BitMap/*from www.j a v a2 s. c o m*/ * * @param drawable * @return */ public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), (drawable.getOpacity() != PixelFormat.OPAQUE) ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); // canvas.setBitmap(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; }
From source file:uk.ac.kent.jb509.shopper.utils.SlidingUpPanelLayout.java
private static boolean hasOpaqueBackground(final View v) { final Drawable bg = v.getBackground(); if (bg != null) { return bg.getOpacity() == PixelFormat.OPAQUE; }//from w w w .j a v a 2s.co m return false; }
From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java
/** * Surface <br>//w w w.j a va 2 s .co m * ? . * * @since 1.0.0 */ private void setupSurfaceView() { Logger.v("FlipViewGroup::setupSurfaceView()"); surfaceView = new GLSurfaceView(getContext()); renderer = new FlipRenderer(this); surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); surfaceView.setZOrderOnTop(true); surfaceView.setRenderer(renderer); // surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); // ? surfaceView.getHolder().setFormat(PixelFormat.OPAQUE); surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); renderer.getCards().setFlipViewGroup(this); addView(surfaceView); }