tnfh.net
当前位置:首页 >> AnDroiD url转BitmAp >>

AnDroiD url转BitmAp

Bitmap bitmap = BitmapFactory.decodeFile(String path);

ByteArrayOutputStream stream = new ByteArrayOutputStream();bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);byte[] byteArray = stream.toByteArray();

ImageView mImageView = (ImageView)findViewById(R.id.item_image); mImageView.setImageBitmap(Bitmap);

* Author:FounderWatts * context:调用方上下文,Activity.this * urlStr:指定的网址,如:“http://www.baidu.com” * */ public Bitmap getBitmapFromUrl(Context context,String urlStr){ URL url = null; Bitmap bitmap = null; HttpURLConnec...

以R文件的方式,假设 res/drawable下有 test.jpg文件 Bitmap bitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.test);

想读取本地项目里的资源图片,但又不能用到R文件。查了很多资料终于找到了。现总结以下几种读取Bitmap的方法。1.以文件流的方式,假设在sdcard下有test.png图片FileInputStream fis = newFileInputStream("/sdcard/test.png");Bitmap bitmap=Bi...

InputStream is = getResources().openRawResource(R.drawable.icon); Bitmap mBitmap = BitmapFactory.decodeStream(is);

public static Uri bitmap2uri(Context c,Bitmap b) { File path = new File(c.getCacheDir() + File.separator + System.currentTimeMillis() + ".jpg"); try { OutputStream os = new FileOutputStream(path); b.compress(Bitmap.CompressForm...

把imageview 转为Bitmap的方法如下: imageView.buildDrawingCache(); Bitmap bmap = imageView.getDrawingCache(); Bitmap bmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();

通过new bitmap的方式,在画布上画图 b = Bitmap.createBitmap(viewWidth, viewHeight, Config.ARGB_8888); Canvas cvs = new Canvas(b); //然后在cvs上的操作也都会在bitmap上进行记录。这种方式对view和surfaceview都通用。

网站首页 | 网站地图
All rights reserved Powered by www.tnfh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com