as in the title, I have annoying problem with Android canvas. I draw text on point 0, 0 next I save image to external memory but on my image almost all of text is out of image.
My code:
btn_calc.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bmp = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);
Canvas canv = new Canvas(bmp);
//canv.
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
canv.drawPaint(paint);
paint.setTextSize(14);
canv.drawColor(Color.WHITE);
paint.setColor(Color.BLACK);
canv.drawText("Testy", 0, 0, paint);
try {
File f = new File(Environment.getExternalStorageDirectory() + "/test_image.png");
f.createNewFile();
FileOutputStream out = new FileOutputStream(f);
bmp.compress(CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Image: Imgur
Thanks for any help. Regards Paweł