try {
URL url = new URL("http://192.168.2.18/SqliteTest/profile_image/" + c.getString("image"));
Log.i("sahusahxsa",url.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(input);
circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
BitmapShader shader = new BitmapShader (bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
Paint paint = new Paint();
paint.setShader(shader);
paint.setAntiAlias(true);
Canvas ca = new Canvas(circleBitmap);
ca.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, bitmap.getWidth()/2, paint);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
ivAttachment.setImageBitmap(circleBitmap);
}
} catch (Exception e) {
e.printStackTrace();
}
如何用url设置圆位图的图像视图
最新推荐文章于 2021-08-04 18:48:26 发布