thx for reply did u mean font's paint? i believe it's not that the font is cannot be drawn. i think it's the position of the position 0,0 of the bitmap is not really 0,0 (it's out of bounds) because when i move the position of bitmap (bitmap.translate) with some x and y, i could see the text and text background is drawn.
On Jun 24, 11:22 pm, MrChaz <[email protected]> wrote: > setTextSize() and setStyle() need to be called on the Paint object I > think. > > On Jun 23, 4:37 pm, sleith <[email protected]> wrote: > > > hi, i'm trying to draw bitmap in canvas. > > the bitmap is used to draw text and background using canvas (named > > canvasBitmap) > > but the text or background that are drown to bitmap is not displayed, > > as if it's out of bounds. > > i have to translate the canvasBitmap at some points to make it draw at > > right position. > > The problem is i don't know how many pixel i should translate to. > > > here's the code example: > > > public OnDraw(Canvas c){ > > > Paint mBackgroundPaint = new Paint(); > > mBackgroundPaint.setColor(Color.RED); > > > String mText = "Testing"; > > > Paint mFontPaint = new Paint(); > > mFontPaint.setColor(Color.WHITE); > > > //setting rect > > Rect mBackgroundRect = new Rect(); > > mFontPaint.getTextBounds(mText, 0, mText.length(), mBackgroundRect); > > > //the bitmap to be drawn a text and backgroundRect > > Bitmap mBitmap = Bitmap.createBitmap(mBackgroundRect.width(), > > mBackgroundRect.height(), > > Bitmap.Config.ARGB_8888); > > Canvas mCanvasBitmap = new Canvas(mBitmap); > > > //draw text and background to bitmap > > mCanvasBitmap.drawColor(Color.CYAN); > > mCanvasBitmap.drawRect(mBackgroundRect, mBackgroundPaint); > > mCanvasBitmap.drawText(mText, 0, 0, mFontPaint); > > > //draw bitmap to canvas > > c.drawBitmap(mBitmap, 0, 0, null); > > > } > > > this will only drawn Cyan color, the text and red background is not > > displayed > > i have to translate for example : > > mCanvasBitmap.translate(0, mBackgroundRect.height()) > > > to make it displayed (but not 100% correctly position) > > please help >.< > > thx --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

