07-17-2009 09:19 AM - edited 07-17-2009 09:20 AM
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?
Could you elaborate on how you solved this issue? I'm running into the exact same issue as you did.
07-20-2009 10:53 AM
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!
07-20-2009 02:46 PM
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?
07-20-2009 02:52 PM
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.
07-20-2009 02:56 PM
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.
07-20-2009 03:03 PM
I tried that and it doesn't work for me 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:
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?