List of usage examples for android.graphics.drawable BitmapDrawable setTileModeX
public void setTileModeX(Shader.TileMode mode)
From source file:com.artioml.practice.activities.LicenseActivity.java
public BitmapDrawable drawParallelogramLine(int width) { Matrix matrix = new Matrix(); Path path = new Path(); path.addRect(0, 0, (4 * width) / 40, (4 * width) / 200, Path.Direction.CW); Path pathStamp = new Path(); Paint p;// w ww.j ava2 s . co m Bitmap bitmap; p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setStyle(Paint.Style.FILL); bitmap = Bitmap.createBitmap(width / 4, width / 80 * 2 + (4 * width) / 200, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); p.setColor(ContextCompat.getColor(this, R.color.colorPrimaryLight)); matrix.reset(); matrix.setTranslate(0, 0); matrix.postSkew(-1f, 0.0f, 0, (4 * width) / 200); path.transform(matrix, pathStamp); canvas.drawPath(pathStamp, p); p.setColor(ContextCompat.getColor(this, R.color.colorAccent)); matrix.reset(); matrix.setTranslate(width / 8, 0); matrix.postSkew(-1f, 0.0f, width / 8, (4 * width) / 200); path.transform(matrix, pathStamp); canvas.drawPath(pathStamp, p); BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap); bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); return bitmapDrawable; }
From source file:org.deviceconnect.android.deviceplugin.host.activity.CanvasProfileActivity.java
/** * ????.//from www. ja va2s . com * @param drawObj ?? */ private void showDrawObject(final CanvasDrawImageObject drawObj) { switch (drawObj.getMode()) { default: case NON_SCALE_MODE: Matrix matrix = new Matrix(); matrix.postTranslate((float) drawObj.getX(), (float) drawObj.getY()); mCanvasView.setImageBitmap(mBitmap); mCanvasView.setScaleType(ScaleType.MATRIX); mCanvasView.setImageMatrix(matrix); break; case SCALE_MODE: mCanvasView.setImageBitmap(mBitmap); mCanvasView.setScaleType(ScaleType.FIT_CENTER); mCanvasView.setTranslationX((int) drawObj.getX()); mCanvasView.setTranslationY((int) drawObj.getY()); break; case FILL_MODE: BitmapDrawable bd = new BitmapDrawable(getResources(), mBitmap); bd.setTileModeX(Shader.TileMode.REPEAT); bd.setTileModeY(Shader.TileMode.REPEAT); mCanvasView.setImageDrawable(bd); mCanvasView.setScaleType(ScaleType.FIT_XY); mCanvasView.setTranslationX((int) drawObj.getX()); mCanvasView.setTranslationY((int) drawObj.getY()); break; } }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static Drawable buildImageDrawable(final Context context, final Object object, final boolean tileImage, final KrollProxy proxy) { if (object instanceof TiBlob) { switch (((TiBlob) object).getType()) { case TiBlob.TYPE_DRAWABLE: return buildImageDrawable(context, ((TiBlob) object).getDrawable(), tileImage, proxy); case TiBlob.TYPE_FILE: case TiBlob.TYPE_IMAGE: final String cacheKey = ((TiBlob) object).getCacheKey(); Bitmap b = TiApplication.getImageMemoryCache().get(cacheKey); if (b == null) { b = ((TiBlob) object).getImage(); }//from ww w . j a v a2 s . com return buildImageDrawable(context, b, tileImage, proxy); default: return null; } } else if (object instanceof String) { String url = (String) object; if (url != null) { url = resolveImageUrl(url, proxy); } Drawable imageDrawable = null; if (url != null) { Cache cache = TiApplication.getImageMemoryCache(); Bitmap bitmap = cache.get(url); if (bitmap == null) { imageDrawable = TiFileHelper.loadDrawable(url); if (imageDrawable instanceof BitmapDrawable) { bitmap = ((BitmapDrawable) imageDrawable).getBitmap(); cache.set(url, ((BitmapDrawable) imageDrawable).getBitmap()); } } else { imageDrawable = new BitmapDrawable(proxy.getActivity().getResources(), bitmap); } if (tileImage) { if (imageDrawable instanceof BitmapDrawable) { BitmapDrawable tiledBackground = (BitmapDrawable) imageDrawable; tiledBackground.setTileModeX(Shader.TileMode.REPEAT); tiledBackground.setTileModeY(Shader.TileMode.REPEAT); } } } return imageDrawable; } else if (object instanceof Drawable) { Drawable imageDrawable = (Drawable) object; if (tileImage && imageDrawable instanceof BitmapDrawable) { BitmapDrawable tiledBackground = (BitmapDrawable) imageDrawable; tiledBackground.setTileModeX(Shader.TileMode.REPEAT); tiledBackground.setTileModeY(Shader.TileMode.REPEAT); } return imageDrawable; } else if (object instanceof Bitmap) { BitmapDrawable imageDrawable = new BitmapDrawable(context.getResources(), (Bitmap) object); if (tileImage) { if (imageDrawable instanceof BitmapDrawable) { BitmapDrawable tiledBackground = (BitmapDrawable) imageDrawable; tiledBackground.setTileModeX(Shader.TileMode.REPEAT); tiledBackground.setTileModeY(Shader.TileMode.REPEAT); imageDrawable = tiledBackground; } } return imageDrawable; } return null; }