BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-18-2007, 11:06 AM   #1 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default graphics.draw on transparent imagepart

Please Login to Remove!

i have an icon of 64x64 size, only the horizontal middle is visible, the rest is transparent.

i'd like to draw a number on the transparent part, as to appear under the icon.

Code:
Bitmap b = Bitmap.getBitmapResource("icon.png");
Graphics g = new Graphics(b);
g.drawText("10", 40, 30);
unfortunately the text is cut off on the lower end of the nontransparent area.

i tried g.setGlobalAlpha(255); with no effect.

any idea how to draw on the transparent part?
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-19-2007, 08:01 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it seems that drawing on a transparent image is not possible.
i draw my partly transparent image on a white one, add the text and replace all white with transparency. not pretty but it works.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-19-2007, 09:35 AM   #3 (permalink)
vph
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8700
PIN: N/A
Carrier: Cingular
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have not tried your case which you use the graphics object of the bitmap to draw the text, but I could draw text on the transparent picture by loading the BitmapField onto the screen then loading the RichTextField onto the screen and above the BitmapField.


Bitmap bm = new Bitmap(268, 196);
BitmapField bmf = new BitmapField(bm);
m.add(bmf, 0, 0, 268, 196);
Graphics g = new Graphics(bm);
Utility.drawImage(g, "about2.gif", 0, 0, 268, 196);

RichTextField f = new RichTextField();
// application name
f.setText(CohFsConstants.aboutApplication);
m.add(f, 7, 20, 300, 16);
// version

f = new RichTextField();
f.setText(CohFsConstants.aboutVersion);
m.add(f, 7, 50, 300, 16);
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.