摘要:public Bitmap getNewBitMap(String text) { Bitmap newBitmap = Bitmap.createBitmap(120,150, Config.ARGB_4444); Canvas canvas = new Canvas(newBitmap); canvas.drawBitmap(bmp, 0, 0, null); TextPaint textPaint = new TextPaint(); textPaint.setAntiAlias(true); textP...
阅读全文
摘要:两种方法:1.直接在图片上写文字 String str = "PICC要写的文字"; ImageView image = (ImageView) this.findViewById(R.id.ImageView); Bitmap photo = BitmapFactory.decodeResource(this.getResources(), R.drawable.text); int width = photo.getWidth(), hight = photo.getHeight(); System.out.println("...
阅读全文
摘要:查询了google发现在android一下有几种方法可以做到,但是经过实际测试发现下面这种方法是最准确的Rect bounds = new Rect();String text = "Hello World";TextPaint paint;paint = findViewById(R.id.hello_world).getPaint();paint.getTextBounds(text, 0, text.length(), bounds);int width = bounds.width();Paint pFont = new Paint();Rect rect = ne
阅读全文
摘要:第一部分:由于Android下摄像头预览数据只能 ImageFormat.NV21 格式的,所以解码时要经过一翻周折.Camera mCamera = Camera.open();Camera.Parameters p = mCamera.getParameters();p.setPreviewFormat(ImageFormat.NV21);/*这是唯一值,也可以不设置。有些同学可能设置成 PixelFormat 下面的一个值,其实是不对的,具体的可以看官方文档*/mCamera.setParameters(p);mCamera.startPreview();方式一:系统SDK2.2自带解码
阅读全文