当前位置:首页 » 安卓系统 » android图片添加文字

android图片添加文字

发布时间: 2023-04-11 17:40:43

① android怎样实现在图片上任意位置添加文字 要代码 急求。。

android在图片上任意位置添加文字,可以使用canvas类进行操作,实例如下:

java">@Override
protectedvoidonDraw(Canvascanvas)
{
super.onDraw(canvas);
canvas.drawBitmap(m_LogInBmp,null,m_LogIndst,m_txBackPaint);

floattleft=m_LogIndst.left+(m_LogIndst.right-m_LogIndst.left-FontWidth*m_TextLogIn.length())/2;
floatttop=m_LogIndst.top+(m_LogIndst.bottom-m_LogIndst.top-FontHeight)/2+FontHeight;
canvas.drawText(m_TextLogIn,tleft,ttop,mLogInPaint);
}

② Android图片添加竖排文字水印

在相机设置里选择水印。
进入相机拍照界面,选择“水印模式”(或进入图库,打开某张图片,点击编辑-水印),然后选择一种带文字水印,点击虚线文本框,即可修改内容。

③ Android给图片添加文字和水印

话不多说 上图

在Activity中获取到ImageView对象,并且获取Bitmap对象,对Bitmap进行canva绘图,添加水印

添加一个布局,上面是原始图片,下面是添加水印后的图片

④ Android给图片添加竖排文字水印

就下载一个加水印的软件就可以了。
文字水印代码:
privateBitmapcreateBitmap(Bitmapphoto,Stringstr,intmark_x,intmark_y){
intwidth=photo.getWidth(),hight=photo.getHeight();
System.out.println("宽"width"高"hight);
//建立一个空的BItMap
Bitmapicon=Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);
//初始化画布绘制的图像到icon上
Canvascanvas=newCanvas(icon);

PaintphotoPaint=newPaint();//建立画笔
photoPaint.setDither(true);//获取跟清晰的图像采样
photoPaint.setFilterBitmap(true);//过滤一些

//创建一个指定的新矩形的坐标
Rectsrc=newRect(0,0,photo.getWidth(),photo.getHeight());
//创建一个指定的新矩形的坐标
Rectdst=newRect(0,0,width,hight);
//将photo缩放或则扩大到dst使用的填充区photoPaint
canvas.drawBitmap(photo,src,dst,photoPaint);

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:585
制作脚本网站 发布:2025-10-20 08:17:34 浏览:880
python中的init方法 发布:2025-10-20 08:17:33 浏览:574
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:761
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:676
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1004
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:248
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:108
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:798
python股票数据获取 发布:2025-10-20 07:39:44 浏览:705