2 Replies - 1300 Views - Last Post: 04 February 2011 - 04:38 PM

#1 ThriceSenses  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-March 10

Drawing on an Image

Posted 02 February 2011 - 11:13 PM

Hi,
I'm a beginner when it comes to Android, so bear with me. I have got some code up and running that allows me to draw anywhere I drag my finger and lift. That is running fine. I'm am using a canvas. I want to be able to draw on top of an image though. Do I make an xml layout and reference it in the code. I'm not asking for code, just on ideas on how to do that or some helpful links. Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: Drawing on an Image

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 277
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Drawing on an Image

Posted 03 February 2011 - 09:37 AM

what you want to do is when you first initialize your class that has the ondraw method is have a global variable like so : private Bitmap bmp; then in the constructor initialize it like so:
bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.<image name>);// note: image must be in one of the drawable folders! 


then in your onDraw method do the following:
canvas.drawBitmap(bmp, 0, 0, null); 



Hope this helps :D.
Was This Post Helpful? 1
  • +
  • -

#3 ThriceSenses  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-March 10

Re: Drawing on an Image

Posted 04 February 2011 - 04:38 PM

IT WORKS!!! Thank you. This helps so much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1