View Full Version : AknIconUtils is caching the image
Tatanka.nbr1
2006-11-02, 15:24
Hi,
I´m having a bit trouble with the AknIconUtils. I´m using an svg image, I create the image using the AknIconUtils::CreateIconL, I set the size and display the image.
I´m using scanlines and dataadress to manipulate the imag, like mirror it and so on. When I delete the image and then reload the image from the mif file using AknIconUtils as I described above, the image that is shown is still the manipulated image. AknIconUtils does not change the image back allthough I deleted the bitmap and re-read it from the mif file. It still displays the image like it was after I changed it.
Has any one seen this problem and if so, did you find any solution?
Thanx for your help
Yes it seems that AknIconUtils will cache images. My solution is to change the mif name when there is any change in the mif file.
Tatanka.nbr1
2006-11-03, 14:11
Hi, thanx for your reply. I'm not sure I fully understand you. What name do you change? The name of the image or the name of the mif-file?
Thanx
Yes it seems that AknIconUtils will cache images. My solution is to change the mif name when there is any change in the mif file.
The name of the .mif.
E.g. from abc.mif change to abc_new.mif
Tatanka.nbr1
2006-11-04, 13:15
Oki, I see. Thank you for your help.
I also noticed that if you load a different icon from the mif file and then loads the original file (the one that was modified) then the real original is displayed.
It seems like the system is caching the latest loade file from the mif file.
It would be great to get this to work by not using any hack, anyone who has a clue?
Thank you
Tatanka.nbr1
2006-11-07, 09:23
Hmm, I was wrong in my last post. It does not help to load a dummy icon. When I load the image that I manipulated after loading a dummy, the image is still looks the same as it did after I changed it.
How can I get the original image back. If someone from Nokia could answer this it would be great, it sounds crazy if there is nothing to do about this. There should be a possibility to reload the image in it´s original state.
Please help.
Thanx
wizard_hu_
2006-11-07, 16:10
What happens if you try AknIconUtils::SetSize? It might force AvKon to redraw your bitmap using the original SVG content (especially if you try resizing to some dummy size, and then to your target-size).
Tatanka.nbr1
2006-11-07, 16:37
Hi, thank you for your answer. I´m sorry to say that it did no difference. I tried to load a dummy and set the size of the dummy and then reload the original image again. When displaying the image it is still changed.
Any other idea, it would be nice to clear the cache somehow.
What happens if you try AknIconUtils::SetSize? It might force AvKon to redraw your bitmap using the original SVG content (especially if you try resizing to some dummy size, and then to your target-size).
wizard_hu_
2006-11-07, 18:57
Not exactly, I imagine something like this:AknIconUtils::CreateIconL(iBitmap,iMask,filename,EBitmapId,EMaskID);
AknIconUtils::SetSize(iBitmap,TSize(100,100));
...
corrupt the bitmap somehow
...
AknIconUtils::SetSize(iBitmap,TSize(22,22));
AknIconUtils::SetSize(iBitmap,TSize(100,100));
Tatanka.nbr1
2006-11-08, 08:47
I tested exactly what you did below but with no success. It´s pretty frustrating not being able to control this at all.
Thanx for trying to help.
Not exactly, I imagine something like this:AknIconUtils::CreateIconL(iBitmap,iMask,filename,EBitmapId,EMaskID);
AknIconUtils::SetSize(iBitmap,TSize(100,100));
...
corrupt the bitmap somehow
...
AknIconUtils::SetSize(iBitmap,TSize(22,22));
AknIconUtils::SetSize(iBitmap,TSize(100,100));
Tatanka.nbr1
2006-11-08, 10:59
Some new information.
I have the following code, I create two images (two different CFbsBitmaps) with the same id from the mif file.
AknIconUtils::CreateIconL(iTmpBitmap, iTmpMask, iconFile,
EMbmHelloworldbasicImage1,
EMbmHelloworldbasicImage1_mask);
AknIconUtils::CreateIconL(iBitmap, iMask, iconFile,
EMbmHelloworldbasicImage1,
EMbmHelloworldbasicImage1_mask);
I then set the size
AknIconUtils::SetSize(iTmpBitmap, rect.Size(),
EAspectRatioPreservedAndUnusedSpaceRemoved);
AknIconUtils::SetSize(iBitmap, rect.Size(),
EAspectRatioPreservedAndUnusedSpaceRemoved);
I then call DrawDeferred() and BitBltMasked iBitmap and iMask.
After this I call a function that manipulates the data in iTmpBitmap and displays this image. The manipulated image is now shown correctly.
I then call the first function that does the above code and displays iBitmap again. It now looks exactly like iTmpBitmap does after the manipulation of it. This is very strange.
If I debug the application, I can see that the adresspointer and the serverhandle is the same for these two CFbsBitmaps, allthough they are created once for itself.
On the other hand if I change the code:
AknIconUtils::SetSize(iTmpBitmap, rect.Size(),
EAspectRatioPreservedAndUnusedSpaceRemoved);
AknIconUtils::SetSize(iBitmap, rect.Size(),
EAspectRatioPreservedAndUnusedSpaceRemoved);
To:
AknIconUtils::SetSize(iTmpBitmap, rect.Size(),
EAspectRatioPreservedAndUnusedSpaceRemoved);
AknIconUtils::SetSize(iBitmap, rect.Size());
The iBitmap image is displayed as if the data never has been changed, it now works as it should. The adresspointer and the serverhandle is not the same as it is for the iTmpBitmap.
Isn´t it very strange that two icons, even if they are exactly the same, that is created seperatelly points to the same adress and has the same serverhandle.
Does anyone know how to get around this? I think the whole behaviour of the AknIconUtil is very strange and in my eyes not very logic.
Thanx
PawelDefee
2007-01-05, 18:55
Any news on this one? I just experienced the caching problem myself :).
Basically, I also have to load the same SVG image over and over again at different sizes - but only the first size load is ever effective, even if the bitmaps are destroyed in between!
PawelDefee
2007-01-05, 20:08
All right, problem solved !
To empty a bitmap from Avkon Server cache, use this:
if( iCachedBitmap )
{
AknIconUtils::DestroyIconData( iCachedBitmap );
}
if( iCachedMask )
{
AknIconUtils::DestroyIconData( iCachedMask );
}
Please note that this will NOT destroy any objects in your applications, simply flush the corresponding SVG data on the server side, you still need to call "delete iCachedBitmap" and so on if you own the bitmap objects.
Cheers,
Pawel