Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

graphics tutorial?

ive been looking through the available links but havent seen anything specific to graphics tutorials. i have somewhere between basic/intermediate programming experience -- as far as the logic and data portions of my application go, I dont forsee any problems getting my app to do what i need.  I'm slowly getting there on screen layouts / managers and I think I can do what I need with them as well.  One thing I have no experience with is specifically with graphics/images - terms like "alpha" and  "rop" are all new to me.  Specifically I am trying to get images to be transparent, which i have seen a few threads on in here but havent had any luck.

Would I be able to learn from standard J2ME graphics tutorials, or are these issues ill need to deal with specific to blackberry ?  or do I just need to try to learn more about graphics/images in general? 

I can't wait for the new proposed wiki, i think it would be great for newbies like me Smiley Happy

 

Thanks for any guidance!

 

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: graphics tutorial?

I haven't really worked with UI, so I don't have any links, but I can tell you that "Alpha" is the dgree of transparency that an object has. For example, 100% transparency means that the object is invisible, 0% being opaque (completely solid). I have no idea what "rop" means.

 

If you check the Javadocs (5.0), you can find a few methods relating to Alpha in the Bitmap and related classes. I'd suggest hitting up the index and searching for the terms "alpha" or "transparency". You'll get a lot you can't use, but I'm sure there's something you can.

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: graphics tutorial?

ROP is Raster Operation. A grid of pixels (Bitmap, EncodedImage, "screen", etc) is a raster image. If you do 255 & 128 the result is 128, if you do a "AND" ROP on a image, it does the same thing per pixel.

 

When you draw using graphics you can set the alpha for drawing. Just to add on to @DAquilina, 100% alpha is 0, 0% alpha is 255.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

Re: graphics tutorial?

Thanks for the responses Smiley Happy

I have bitmaps that are PNGs that are transparent ... in photoshop they are transparent, when i load them as bitmaps and do hasAlpha it says true.  ive been trying to change the paint and paintbackground methods for the bitmapfield and the manager its going on, but no matter what i do the image has a white background instead of being able to see the image behind it (regardless if its focused or not). i keep trying different combinations of setting different backgrounds for managers/fields/etc, and nothing seems to work. so im assuming there is just something i should know that im missing ...

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: graphics tutorial?

the screens of an uiapplication are always white (and not transparent)

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

Re: graphics tutorial?

For testing ... Im extending MainScreen. i set background to blue. then i add MyManager which extends Manager and contains bitmapfields.  The bitmaps all show up with a white square around them.  even if i set the background of MyManager to a color, the square is still white.  so then i try setting a background to the bitmapfields themselves,  but still the square is white.

I understand that the underlying screen is white, but should i be able to set a background to either the screen or a manager thats in the screen, and then have that background show through the transparent parts of the bitmapfield on top of that ?

 

 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: graphics tutorial?

You are descibing a situation where the PNG is actually not transparent.

 

Try adding some spacing around the image in your Bitmap, just to see what happens.

 

 

 

Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

Re: graphics tutorial?

Rex - when you say to add spacing in the image, do you mean on the bb or to edit the image and add it there?  right now when i open the png in photoshop, i can copy and paste it on top of something else it it looks right -- i see the background image fine through the transparent spots.  

Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

Re: graphics tutorial?

Something must be wrong with my heirarchy of screens/managers, because the image is good. i did this test on a completely new mainscreen and it gives me the correct display .. so something im doing with my manager must be causing a problem..

 

 

Background bg = BackgroundFactory.createLinearGradientBackground(Color.BLACK, Color.BLUE, Color.RED, Color.CORAL);
this.getMainManager().setBackground( bg );

// get bitmap
Bitmap bm = Bitmap.getBitmapResource( SEARCH_ICON );
BitmapField bmf = new BitmapField( bm );

this.add( bmf );

 

 

 

Contributor
Posts: 10
Registered: ‎03-20-2010
My Device: Curve 2 8530

Re: graphics tutorial?

Ok sorry for posting so many messages in a row ... but i think i found the problem (but not the solution).  im continuously re-sizing/scaling the image as it moves.  before scaling it, it works, but i guess the new image created after scaling isnt transparent.   to scale im using the following ... 

 

 

Bitmap bitmapScaled = new Bitmap(scale, scale);
bm.scaleInto( bitmapScaled, Bitmap.FILTER_BILINEAR ); bitmapScaled.createAlpha( Bitmap.ALPHA_BITDEPTH_8BPP );

 

I'm trying different combinations of different filters and SCALE types but not having luck yet. Is there another way to scale that would keep the transparency?

 

thanks all Smiley Happy