
正文
android图片文字,手机图片文字
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
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);
相关问答
Q1: android怎样实现在图片上任意位置添加文字 要代码 急求。。
android在图片上任意位置添加文字,可以使用canvas类进行操作,实例如下:
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
canvas.drawBitmap(m_LogInBmp, null, m_LogIndst, m_txBackPaint);
float tleft = m_LogIndst.left + (m_LogIndst.right - m_LogIndst.left - FontWidth*m_TextLogIn.length())/2;
float ttop = m_LogIndst.top + (m_LogIndst.bottom - m_LogIndst.top - FontHeight)/2 +FontHeight;
canvas.drawText( m_TextLogIn, tleft, ttop, mLogInPaint);
}
Q2: Android给图片添加文字和水印
话不多说 上图
在Activity中获取到ImageView对象,并且获取Bitmap对象,对Bitmap进行canva绘图,添加水印
添加一个布局,上面是原始图片,下面是添加水印后的图片







