List of usage examples for android.graphics Canvas setBitmap
public void setBitmap(@Nullable Bitmap bitmap)
From source file:com.android.launcher2.Workspace.java
/** * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. * Responsibility for the bitmap is transferred to the caller. *///from w ww. ja v a 2 s. c om private Bitmap createDragOutline(View v, Canvas canvas, int padding) { final int outlineColor = getResources().getColor(android.R.color.holo_blue_light); final Bitmap b = Bitmap.createBitmap(v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); canvas.setBitmap(b); drawDragView(v, canvas, padding, true); mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor); canvas.setBitmap(null); return b; }
From source file:cc.flydev.launcher.Workspace.java
public Bitmap createWidgetBitmap(ItemInfo widgetInfo, View layout) { int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(widgetInfo.spanX, widgetInfo.spanY, widgetInfo, false);//from www .j a va 2 s. co m int visibility = layout.getVisibility(); layout.setVisibility(VISIBLE); int width = MeasureSpec.makeMeasureSpec(unScaledSize[0], MeasureSpec.EXACTLY); int height = MeasureSpec.makeMeasureSpec(unScaledSize[1], MeasureSpec.EXACTLY); Bitmap b = Bitmap.createBitmap(unScaledSize[0], unScaledSize[1], Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); layout.measure(width, height); layout.layout(0, 0, unScaledSize[0], unScaledSize[1]); layout.draw(c); c.setBitmap(null); layout.setVisibility(visibility); return b; }
From source file:cc.flydev.launcher.Workspace.java
/** * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. * Responsibility for the bitmap is transferred to the caller. *///from w w w. j a v a2 s .c o m private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h, boolean clipAlpha) { final int outlineColor = getResources().getColor(R.color.outline_color); final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); canvas.setBitmap(b); Rect src = new Rect(0, 0, orig.getWidth(), orig.getHeight()); float scaleFactor = Math.min((w - padding) / (float) orig.getWidth(), (h - padding) / (float) orig.getHeight()); int scaledWidth = (int) (scaleFactor * orig.getWidth()); int scaledHeight = (int) (scaleFactor * orig.getHeight()); Rect dst = new Rect(0, 0, scaledWidth, scaledHeight); // center the image dst.offset((w - scaledWidth) / 2, (h - scaledHeight) / 2); canvas.drawBitmap(orig, src, dst, null); mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor, clipAlpha); canvas.setBitmap(null); return b; }
From source file:cc.flydev.launcher.Workspace.java
/** * Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location. * Responsibility for the bitmap is transferred to the caller. *///from w w w.j a v a 2 s . c o m private Bitmap createDragOutline(View v, Canvas canvas, int padding) { final int outlineColor = getResources().getColor(R.color.outline_color); final Bitmap b = Bitmap.createBitmap(v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); canvas.setBitmap(b); drawDragView(v, canvas, padding, true); mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor); canvas.setBitmap(null); return b; }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public Bitmap createWidgetBitmap(ItemInfoBean widgetInfo, View layout) { int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(widgetInfo.spanX, widgetInfo.spanY, widgetInfo, false);// ww w .ja v a 2 s . c om int visibility = layout.getVisibility(); layout.setVisibility(VISIBLE); int width = MeasureSpec.makeMeasureSpec(unScaledSize[0], MeasureSpec.EXACTLY); int height = MeasureSpec.makeMeasureSpec(unScaledSize[1], MeasureSpec.EXACTLY); Bitmap b = Bitmap.createBitmap(unScaledSize[0], unScaledSize[1], Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); layout.measure(width, height); layout.layout(0, 0, unScaledSize[0], unScaledSize[1]); layout.draw(c); c.setBitmap(null); layout.setVisibility(visibility); return b; }
From source file:cc.flydev.launcher.Workspace.java
/** * Returns a new bitmap to show when the given View is being dragged around. * Responsibility for the bitmap is transferred to the caller. *//* www .ja v a 2 s. c om*/ public Bitmap createDragBitmap(View v, Canvas canvas, int padding) { Bitmap b; if (v instanceof TextView) { Drawable d = ((TextView) v).getCompoundDrawables()[1]; b = Bitmap.createBitmap(d.getIntrinsicWidth() + padding, d.getIntrinsicHeight() + padding, Bitmap.Config.ARGB_8888); } else { b = Bitmap.createBitmap(v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888); } canvas.setBitmap(b); drawDragView(v, canvas, padding, true); canvas.setBitmap(null); return b; }