1

Possible Duplicate:
How to edit image for e.g. permanently adding text on the image which becomes the part of that image in android?

my query is to get the size of the image and then i will edit at the bottom with the text. let say i have image and i want to edit it at the bottom using text but i dont know the size as the picture is taken by the camera or may be from Sd card storage. The problem is i can not give a static location in

canvas.drawText("Text",Xpos,Ypos,paint);

so just want size and according to that i will edit at the bottom by passing Xpos and Ypos in above methode. Can anybody help me on that...?

Community
  • 1
  • 1
School Boy
  • 1,207
  • 2
  • 19
  • 33
  • explain a bit more. is your view taking the size of the image? is your image in an imageview? – blessanm86 Sep 13 '11 at 05:52
  • see what i am doing is taking image from the camera and storing it to database and sending it to server. while capturing image from camera at that time i am editing it using canvas and paint. i am displaying it on the imageview but i dont know whether imageview is doing something wrong as in one of the case i am getting the text and in ohter case i am not getting text. i think this is all because i dont know the size of the image. so i want to change that image at runtime. Hope this explains my query if you still need more, i will post my code also. Thank you for the reply. – School Boy Sep 13 '11 at 06:08

2 Answers2

4

When you have loaded your image as a Bitmap : http://developer.android.com/reference/android/graphics/Bitmap.html

You can access the methods wich will give you the height and the width of your image.

myBitmap.getHeight();
myBitmap.getWidth();

then just do:

canvas.drawText("Text",myBitmap.getWidth() - (lenghtOfText * sizeOfText) ,myBitmap.getHeight() - sizeOfText ,paint);
GrandMarquis
  • 1,913
  • 1
  • 18
  • 30
1

Get the bitmap of the image using bitmap factory,decode file. Then use your_bitmap.getwidth() and your_bitmap.getheight().

Pavankumar Vijapur
  • 1,196
  • 2
  • 10
  • 15