Hi
I have a question regarding fading bitmaps. I want to launch an application which occupies part of the main screen. when it is started i want the rest of background bitmap(which remains visible) to fade.
How can i do this?
Thanks
If you want it to fade exactly like it does when you pop up a menu or dialog, just create your own CEikDialog and launch that.
If you want some other kind of fade, only way I can think of (that work in current symbian) is to actually draw your app in fullscreen, but before you create your first window you take a screenshot of the current scene (use CWsScreenDevice::CopyScreenToBitmap()) and then draw that as a background to your scene with whatever fading you want.
Will not work with dynamic content (animations, or anything else that update) in the background though.
Thanks alh,
I think the way i wanted to be it is the 1st one you mention. the only problem is that the launched app is not implemented by me so i cannot derive it from CEikDialog.
In the 2nd case, i managed to get the screenshot of the current scene and i was thinking to use a BitBltMask,when i faced the fact that i do not know how to create the mask(the 3rd or 4th parameter of the function).
Any suggestions?Maybe there is other method instead of BitBltMask...
Thanks
try to simply not call "SetFadingParameters" at all.
The default should be good.
Setting the values you set means you tell it to not fade.
Quote from the documentation:
"If aBlackMap=0 and aWhiteMap=255 then the colours are mapped unchanged"
Also, you should _never_ever_ load bitmaps in your Draw function.
First, you must never Leave in the Draw function.
And second, it makes your Draw call tens of thousands of times slower then it should be, pulling unnecessary battery power, and risking timeouts and panics.
Load the bitmap in your ConstructL, and just draw it in Draw
and in draw method i just draw the bitmap and the view:
void CtestAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
TPoint origin(0,0);
gc.SetFaded(ETrue);
gc.BitBlt(origin, iBitmap);
gc.SetFaded(EFalse);
// Gets the control's extent
TRect drawRect(Rect());
}
But no success, the background appears exactly the same. Myabe BitBlt function is not called with proper params. (0,0) is the left corner of the view or of the screen? my intention is to have the bitmap drawn on (0,0) coord of the screen(becouse the bitmap is the screen image saved in ConstructL).
The coords are relative to the window you draw in, and you can't draw outside your window, so if you want it to stay at 0,0 on the screen you have to make your window fullscreen.
(SetExtentToWholeScreen() in your CCoeControls constructL).
Dont know why setfaded didn't work, I havn't actually tried it myself... but I think it should work
Is anything getting drawn? (check if Draw is called at all in your debugger)
This is a bit hacky way to do it though, there should be some way to control fading the same way the CEikDialogs do, but I'm unsure if those API:s are public or not...
You should try search forum.nokia and the nokia wiki and knowledgebase also.
Forum posts: 1419
If you want it to fade exactly like it does when you pop up a menu or dialog, just create your own CEikDialog and launch that.
If you want some other kind of fade, only way I can think of (that work in current symbian) is to actually draw your app in fullscreen, but before you create your first window you take a screenshot of the current scene (use CWsScreenDevice::CopyScreenToBitmap()) and then draw that as a background to your scene with whatever fading you want.
Will not work with dynamic content (animations, or anything else that update) in the background though.
Forum posts: 16
Thanks alh,
I think the way i wanted to be it is the 1st one you mention. the only problem is that the launched app is not implemented by me so i cannot derive it from CEikDialog.
In the 2nd case, i managed to get the screenshot of the current scene and i was thinking to use a BitBltMask,when i faced the fact that i do not know how to create the mask(the 3rd or 4th parameter of the function).
Any suggestions?Maybe there is other method instead of BitBltMask...
Thanks
Forum posts: 1419
BitBltMasked is for drawing transparent images, if you need per pixel transparency.
If the system fading is enough, you should be able to just call SetFaded() on the CWindowGc and draw the bitmap with a normal BitBlt.
Forum posts: 16
Thanks,
I used SetFaded but it doesnt seem to work(no fading effect). My code is like this(in draw method of the View):
void MYView::Draw(const TRect& /*aRect*/)
{
CWindowGc& gc = SystemGc();
TPoint origin(0,0);
CWsScreenDevice* screenDev = CCoeEnv::Static()->ScreenDevice();
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL( bitmap );
User::LeaveIfError( bitmap->Create( screenDev->SizeInPixels(), screenDev->DisplayMode() ) );
User::LeaveIfError( screenDev->CopyScreenToBitmap( bitmap ) );
//now we have the bitmap
gc.SetFadingParameters(0,255);
gc.SetFaded(ETrue);
gc.BitBlt(origin, bitmap);
gc.SetFaded(EFalse);
//draw the view
TRect drawRect(Rect());
}
Which might be the problem with this code?
Thanks
Forum posts: 1419
try to simply not call "SetFadingParameters" at all.
The default should be good.
Setting the values you set means you tell it to not fade.
Quote from the documentation:
"If aBlackMap=0 and aWhiteMap=255 then the colours are mapped unchanged"
Forum posts: 1419
Also, you should _never_ever_ load bitmaps in your Draw function.
First, you must never Leave in the Draw function.
And second, it makes your Draw call tens of thousands of times slower then it should be, pulling unnecessary battery power, and risking timeouts and panics.
Load the bitmap in your ConstructL, and just draw it in Draw
Forum posts: 16
You are right,
anyway i used that code in draw method just to test the fading efect. Now i moved the code in ConstructL like this:
void MYView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
CWsScreenDevice* screenDev = CCoeEnv::Static()->ScreenDevice();
TSize size = screenDev->SizeInPixels();
iBitmap = new (ELeave) CFbsBitmap();
User::LeaveIfError( iBitmap->Create( screenDev->SizeInPixels(),screenDev->DisplayMode() ) );
User::LeaveIfError( screenDev->CopyScreenToBitmap( iBitmap ) );
}
and in draw method i just draw the bitmap and the view:
void CtestAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
TPoint origin(0,0);
gc.SetFaded(ETrue);
gc.BitBlt(origin, iBitmap);
gc.SetFaded(EFalse);
// Gets the control's extent
TRect drawRect(Rect());
}
But no success, the background appears exactly the same. Myabe BitBlt function is not called with proper params. (0,0) is the left corner of the view or of the screen? my intention is to have the bitmap drawn on (0,0) coord of the screen(becouse the bitmap is the screen image saved in ConstructL).
Forum posts: 1419
The coords are relative to the window you draw in, and you can't draw outside your window, so if you want it to stay at 0,0 on the screen you have to make your window fullscreen.
(SetExtentToWholeScreen() in your CCoeControls constructL).
Dont know why setfaded didn't work, I havn't actually tried it myself... but I think it should work
Is anything getting drawn? (check if Draw is called at all in your debugger)
This is a bit hacky way to do it though, there should be some way to control fading the same way the CEikDialogs do, but I'm unsure if those API:s are public or not...
You should try search forum.nokia and the nokia wiki and knowledgebase also.