안드로이드 앱에서 이미지에 워터 마크를 추가하고 싶습니다. 내 응용 프로그램 사용자가 이미지를 선택하고 편집 텍스트에 텍스트를 쓸 수 있습니다. 버튼을 누르면 선택한 이미지에 워터 마크 텍스트가 필요합니다. 아래 코드를 시도했지만 작동하지 않습니다.안드로이드 이미지에 워터 마크 추가
public static void mark(String watermark,String filePath) {
try{
Bitmap bmp = BitmapFactory.decodeFile(filePath);
int w = bmp.getWidth();
int h = bmp.getHeight();
Bitmap result = Bitmap.createBitmap(100, 100, bmp.getConfig());
Canvas canvas = new Canvas(result);
canvas.drawBitmap(bmp, 0, 0, null);
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setAlpha(40);
paint.setTextSize(20);
paint.setAntiAlias(true);
canvas.drawText(watermark,w/2, h/2+20, paint);
File nFile = new File(getDevicePath(mContext)+"output1.jpg");
nFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(nFile);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
}
catch(Exception e){
e.printStackTrace();
}
}
위의 문제를 해결하는 방법을 알려주십시오.
미리 감사드립니다.
문제가 있습니까? –
어떤면에서 "작동하지 않습니까?" –
http://shaikhhamadali.blogspot.in/2013/08/water-mark-image-in-imageview-android.html 나는 어떤 솔루션이라도 가지고 있다고 생각한다. – ckpatel