/** * Draw the symbol. * * @param ytop The ylocation (in pixels) where the top of the staff starts. */ public void Draw(Canvas canvas, Paint paint, int ytop) { if (!candraw) return; canvas.translate(getWidth() - getMinWidth(), 0); Bitmap numer = images[numerator]; Bitmap denom = images[denominator]; /* Scale the image width to match the height */ int imgheight = SheetMusic.NoteHeight * 2; int imgwidth = numer.getWidth() * imgheight / numer.getHeight(); Rect src = new Rect(0, 0, numer.getWidth(), numer.getHeight()); Rect dest = new Rect(0, ytop, imgwidth, ytop + imgheight); canvas.drawBitmap(numer, src, dest, paint); src = new Rect(0, 0, denom.getWidth(), denom.getHeight()); dest = new Rect( 0, ytop + SheetMusic.NoteHeight * 2, imgwidth, ytop + SheetMusic.NoteHeight * 2 + imgheight); canvas.drawBitmap(denom, src, dest, paint); canvas.translate(-(getWidth() - getMinWidth()), 0); }