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
Developer
ryansweny
Posts: 64
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Rogers

Re: Animated Screen transitions

Thanks! I was using Display.screenshot.. I guess this constructor is the one to use:

 

Graphics(Bitmap bitmap) 

Please use plain text.
Developer
kchantp
Posts: 77
Registered: ‎11-20-2008
My Device: Not Specified

Re: Animated Screen transitions

[ Edited ]

Hey Martin,

 

I've been trying to implement the some screen animations for some time and thanksfully this thread's really helped me.  I took a peek at your Vision for Youtube app and you've got some really cool animations there.  I think I finally understand the steps you are taking to do animations but just like ryansweny, I haven't figured out how to get the screen capture of the second screen in order to pass it into my animation screen.  You mention that you don't use the Display.screenshot method and I can't seem to find another way to capture a screen.  Could you suggest a place to start looking? 

 

Also, I'm not sure what you mean about creating the bitmap and passing it directly into the screen.paint() method.  Right now, I'm trying to take the screenshots and then pass them directly as arguments into the AnimationScreen.  Am I missing something?

 

Ryansweny,

 

Could you elaborate on how you solved this issue?  I'm running into the exact same issue as you did.

Message Edited by kchantp on 07-17-2009 09:20 AM
Please use plain text.
Developer
Comitic
Posts: 68
Registered: ‎02-05-2009
My Device: Not Specified

Re: Animated Screen transitions

Hey  everyone, I am using the following code and it seems to work fine for the "prev" screen, but I get the "next" screen as a blank Bitmap which is very weird and I was trying to solve this issue for some time already but I can't figure out what's wrong.

 

this.img1 = new Bitmap(Display.getWidth(), Display.getHeight()); this.img2 = new Bitmap(Display.getWidth(), Display.getHeight()); Graphics gPrev = new Graphics(img1); prev.paint(gPrev); Graphics gNext = new Graphics(img2); next.paint(gNext); //Now img1 is supposed to contain bitmap of prev screen and img2 bitmap of next screen

 

I also tried the following:

 

 

MotionableScreen scr = new ScreenOne(); Bitmap img2 = new Bitmap(Display.getWidth(), Display.getHeight()); Graphics gNext = new Graphics(img2); scr.paint(gNext); pushScreen(new BitmapTestScreen(img2));

 

This does not work for any screen for some reason.

 

 

So while I believe that is the way Martin was suggesting to use, and it partially works for me, it does not work fully however and I am puzzled as to the reason why sometimes I get the right Bitmap and sometimes I just get a blank bitmap. 

 

So in the first code snippet, I WILL get the Bitmap, but in the second snippet I won't get the snippet. (I do invoke those snippets in different context but there's too much code to paste so I believe this is the reason, but it drives me nuts as to why this is not working).

 

 

Expecting for a gentle push to the right direction! Thanks!

 

 

 

Please use plain text.
Developer
kchantp
Posts: 77
Registered: ‎11-20-2008
My Device: Not Specified

Re: Animated Screen transitions

Thanks MaxSA!  I was able to finally get both bitmaps from your code snippet.  With your first method, you said you get the Bitmap, while with the second, you don't.  The problem is that with the first method, it's not consistent, that at times you get it and at times it's blank? 

 

I took mreed's advice and keep everything in the same thread.  With this, I can consistently get the bitmap back.  Perhaps try removing the invokes?

Please use plain text.
Developer
Comitic
Posts: 68
Registered: ‎02-05-2009
My Device: Not Specified

Re: Animated Screen transitions

Hey, kshantp

 

 

I was hopping that my snipets will help you to figure out your problem. I mostly figured out mine as will by now. It worked fine on my toy example, but when I integrated it to the main application - everything broke... I suspect the problem is generated from overriding the paint method of the screen to be public which messes up things.

 

If you care  to share how you override the paint method to be public and render everything prooperly, I'd be grateful to you.

 

Regards,

Max.

Please use plain text.
Developer
kchantp
Posts: 77
Registered: ‎11-20-2008
My Device: Not Specified

Re: Animated Screen transitions

I have one "screen" class that implements an interface called "PaintableScreen".  The PaintableScreen interface has one public method of paint.  In this one screen class, I implement this method by simply calling "super.paint(g)."  All my screens in the application then extend from that one screen so that they all have a public paint method.

 

There are times that I need to cast the screens to PaintableScreens but it seems to work for me.  Let me know if that works for you.

Please use plain text.
Developer
Comitic
Posts: 68
Registered: ‎02-05-2009
My Device: Not Specified

Re: Animated Screen transitions

I tried that and it doesn't work for me :smileysad:  that's why it didn't work for me originally. I did exactly what you are saying and was getting just "blank" bitmap.

 

I started a new thread hoping that someone will help me out with this:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=49533

 

So I struggled with it for couple hours now and I figured that I need to call doLayout() first before I call super.paint(g) and that solved the problem - I was now getting a real bitmap, but now some of the screens' layout is completely messed up (things don't show up, impossible to navigate to some things etc...)

 

 

So you are saying that it works for you with no problems... Then it must be the case that I am doing something wrong somewhere else... ?!?

 

Any help solving this matter would be greatly appreciated!

 

I build against 4.5 btw, what about you?

 

 

Please use plain text.
Developer
kchantp
Posts: 77
Registered: ‎11-20-2008
My Device: Not Specified

Re: Animated Screen transitions

I'm working on the 4.6 platform with a Bold.  I'll give it a try in 4.5 and see what I get.
Please use plain text.
Developer
Comitic
Posts: 68
Registered: ‎02-05-2009
My Device: Not Specified

Re: Animated Screen transitions

I am fine! :smileyhappy:

 

Turns out someoneelse broke the code and I thought it was me... It's now working fine! :smileyhappy: yey!

Please use plain text.
Developer
kchantp
Posts: 77
Registered: ‎11-20-2008
My Device: Not Specified

Re: Animated Screen transitions

[ Edited ]
Glad to hear everything is working properly now. We're both winners!
Message Edited by kchantp on 07-20-2009 04:24 PM
Please use plain text.