借鉴位图圈 [英] draw circle on bitmap
问题描述
我已经写了一个应用程序,捕捉画面并将其保存在SD卡。然后我可以加载图像插入的ImageView来显示它。我想画一个圆圈上的位图前,我显示出来。低于code显示位图,但没有圈,任何想法,为什么圆,不是吗?
感谢。
BitmapFactory.Options BFO =新BitmapFactory.Options();
bfo.inSampleSize = 5;
位图BM = BitmapFactory.de codeByteArray(imageArray,0,imageArray.length,BFO);
Log.e(TAG,bm.toString());
//imageview.setImageBitmap(bm);
位图bmOverlay = Bitmap.createBitmap(bm.getWidth(),bm.getHeight(),bm.getConfig());
帆布=新的Canvas(bmOverlay);
涂料粉刷=新的油漆();
paint.setColor(Color.RED);
canvas.drawBitmap(BM,新的Matrix(),NULL);
canvas.drawCircle(750,14,11,油漆);
imageview.setImageBitmap(bmOverlay);
您可以检查 bm.getWidth
。如果您使用的是5样本大小,然后你的形象会比原来小5倍,从而导致你的圈子消失过右侧的形象。
您可以尝试:
paint.setStrokeWidth(10);
canvas.drawCircle(50,50,25);
只是作为一个全面的检查。
i've written an app that captures a picture and saves it on the sdcard. i then can load that image into an imageview to display it. i'd like to draw a circle on the bitmap before i display it. the code below displays the bitmap but no circle, any ideas why the circle is not there?
thanks.
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inSampleSize = 5;
Bitmap bm = BitmapFactory.decodeByteArray(imageArray, 0, imageArray.length, bfo);
Log.e(TAG, bm.toString());
//imageview.setImageBitmap(bm);
Bitmap bmOverlay = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), bm.getConfig());
canvas = new Canvas(bmOverlay);
Paint paint = new Paint();
paint.setColor(Color.RED);
canvas.drawBitmap(bm, new Matrix(), null);
canvas.drawCircle(750, 14, 11, paint);
imageview.setImageBitmap(bmOverlay);
You might check bm.getWidth
. If you are using a sample size of 5 then your image will be 5 times smaller than the original, causing your circle to disappear off the right side of the image.
You could try:
paint.setStrokeWidth(10);
canvas.drawCircle(50, 50, 25);
just as a sanity check.
这篇关于借鉴位图圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!