On Tue, Sep 28, 2010 at 3:16 PM, woefulwabbit <[email protected]>wrote:
> Hi, > > I have noticed that loading an image into a GLTexture using > > Drawable d = getResource().getDrawable(...); > Bitmap bitmap = Bitmap.createBitmap(...); > Rect rect = new Rect(...) > d.setBounds(rect) > d.draw(new Canvas(bitmap)); > GLUtils.texImage2D(...) > > Will create a texture with premultiplied alpha. Not a problem, as long > as I use glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) to blend instead > of glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) which will cause > dark borders. > > However, I've found that if I render text onto the Bitmap and convert > to glTexture using: > > Bitmap bitmap = Bitmap.createBitmap(...); > Canvas c = new Canvas(bitmap); > Paint p = new Paint(); > p.setColor/setAntiAlias/setTextSize(...) > c.drawText(text, x, y, p) > GLUtils.texImage2D(...) > > ..the resultant texture is NOT premultiplied, and using > glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) will cause ugly over- > saturated edges when blended into the 3D world. Blending using > glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) makes it look right > again. > > To confirm this, I saved the bitmap into a PNG file and load it as a > resource into a texture, and the resultant texture is premultiplied > and renders correctly using glBlendFunc(GL_ONE, > GL_ONE_MINUS_SRC_ALPHA) > > Is there a way to force the text rendering onto the bitmap to be pre- > multiplied? > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Julie tradinglogically.blogspot.com -- 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

