开发者

How can i have image (takePicture) with text at the bottom of it. Eg. Date time

开发者 https://www.devze.com 2023-03-11 06:13 出处:网络
I would like to add the text to be part of my image.Eg.Date and time,or \"You are using the Free version\".Is it p开发者_StackOverflow中文版ossible....? Please help me.Thanks in advance.Use a Canvas a

I would like to add the text to be part of my image. Eg. Date and time, or "You are using the Free version". Is it p开发者_StackOverflow中文版ossible....? Please help me. Thanks in advance.


Use a Canvas and drawText.


Thanks Gabriel for the right direction: Following code helped me.

     public static Bitmap WaterMark(Bitmap src, String watermark,int x, int y,  int size) {
        int w = src.getWidth();
        int h = src.getHeight();
    //  TML_Library.Debug("Image Width = "+w+" Image Height = "+h);
        Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());

        Canvas canvas = new Canvas(result);
        canvas.drawBitmap(src, 0, 0, null);
        Paint paint = new Paint();
        paint.setTextSize(size);

        paint.setColor(Color.rgb(255, 0, 0));

        paint.setAntiAlias(true);

        canvas.drawText(watermark, x, y, paint);

        return result;
    }   
0

精彩评论

暂无评论...
验证码 换一张
取 消