Android theme功能临时存放

this.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath();对应路径
@NonNull
private Bitmap getBitmapFromDrawable(@NonNull Drawable drawable) {
    final Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bmp);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bmp;
}

【icon_mask.png】图像蒙板(黑色区域图像全部透过,边缘空白区域被屏蔽不显示,从而将不规则图标统一大小和形状)
【icon_border.png】图标饰边层(其实也是图像蒙板),盖在原图标上,通过半透效果或饰边,增加图标的个性
【icon_background_01.png】图标背景,用来填满图标空白区域,但是依然会有不听话的图标,就是不爱穿衣服!

搜狗截图19年02月21日0735_1.png

/storage/emulated/0/Android/data/com.example.testpplication/files/Pictures

   public void  getScreenWidthAndHeight(Context context){
      this.heightPixels = context.getResources().getDisplayMetrics().heightPixels / 2 + 50;
      this.widthPixels  = context.getResources().getDisplayMetrics().widthPixels  /3 - 10;
   }
public  Bitmap getimage(InputStream bitmapIS) {
   BitmapFactory.Options newOpts = new BitmapFactory.Options();
   newOpts.inJustDecodeBounds = true;
   Bitmap bitmap = BitmapFactory.decodeStream(bitmapIS,null, newOpts);
   final int height = newOpts.outWidth;
   final int width = newOpts.outHeight;
   int inSampleSize = 1;
   if (height > heightPixels || width > widthPixels) {
      final int heightRatio = Math.round((float) height / (float) heightPixels);
      final int widthRatio = Math.round((float) width / (float) widthPixels);
      inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
   }
   newOpts.inSampleSize = inSampleSize;// 设置缩放比例
   newOpts.inJustDecodeBounds = false;
   bitmap = BitmapFactory.decodeStream(bitmapIS,null, newOpts);
   return bitmap;
}

public  Bitmap getBitmap(Bitmap orightBitmap, float prevW, float prevH)
{
   int mWidth=orightBitmap.getWidth();
   int mHeight=orightBitmap.getHeight();
   float scaleW=(float)prevW/mWidth;
   float scaleH=(float)prevH/mHeight;
   Matrix scaleMatrix = new Matrix();
   scaleMatrix.postScale(scaleW, scaleH);
   Bitmap resizeBmp = Bitmap.createBitmap(orightBitmap, 0, 0, mWidth,mHeight, scaleMatrix, true);
   return resizeBmp;
}
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值