
|
Image
Converter Example
Examples\MultiMedia\ImageConv\
Disclaimer: The example application code that I am modifying is solely owned by the Symbian (www.symbian.com). I have published my modifications here to assist the Symbian user community to compile and build useful example applications.
Symbian SDK: UIQ 2.1 IDE: Codewarrior 5.2.1283 After loading the the imageconv.mmp into the Codewarrior IDE and compiling against the UIQ 2.1 SDK, we get 27 compiler errors! I will go through and resolve these compiler errors to see if we can get a working Image Conversion sample application. Error : Symbian Resource - The first couple of errors tell us that there was an issue during resource compilation (rcomp). It's complaining about the control structure "NUMBER_EDITOR". This structure is related to the Series 60 number editor "CEikNumberEditor", but in UIQ we use the CQikNumberEditor. This control uses a different control structure QIK_NUMBER_EDITOR. So we will go ahead and make this change in every instance we find this structure referred to in the resource file (should be 3 references). Also make sure to include the Qikon resource header (qikon.rh) at the top of the resource file. These changes get rid of our resource compiler errors. Inspecting the application directory found at epoc32\release\winscw\udeb\Z\System\APPS\IMAGECONV, we can see that the imageconv.rsc file has been built. The next series of errors are related to references to the series 60 number editor class, CEikNumberEditor. In UIQ, we use the CQikNumberEditor class. We will change the references to the CEikNumberEditor to CQikNumberEditor in the CImageAppUi.h file. We will also need to include the header file qiknumbereditor.h, and add qikctl.lib to the imageconv.mmp file or we will have linking errors later. Remember to re-import your MMP file back into Codewarrior so knows to include that library during linking. The remaining eleven errors are in CImageAppUI.cpp, and are more references to the CEikNumberEditor. Changing all references of CEikNumberEditor to CQikNumberEditor gets us down to 6 remaining errors. These are caused by API differences in the two controls. CEikNumberEditor uses the methods TInt Number() and void SetNumber(TInt aNumber). CQikNumberEditor user the methods TInt Value() and void SetValueL(TInt aValue). We can pretty much replace the CEikNumberEditor methods with the CQikNumberEditor commands, but we must be careful because the SetValueL in the CQikNumberEditor can now leave. So the methods that use this API must also be able to leave, or we have to TRAP these calls. In this example application, both methods that make this call do leave, so we are fine. If we replace the old CEikNumberEditor methods with the CQikNumberEditor methods, you should be able to compile and link. If you get link errors, you forgot to re-import your mmp file into Codewarror. Now try to run the application by launching it the
EPOC emulator. You will probably notice it crash the emulator as soon
as the Imageconv application tries to launch. Stepping through the
initialization code we can find that the application is crashing in
DynInitMenuBarL. This is because the code is trying to make a method
call on a pointer that is NULL. In CImageAppUI::ConstructL, we call the base class ConstructL, this does a bunch of initialization and at some point calls DynInitBarL. We initialize the iFrame pointer in CImageAppUI::ConstructL after the call to CEikAppUI::ConstructL. There are a couple ways we can fix this. I believe its always good practice to validate your pointers before using them so I will validate to make sure iFrame is Not NULL before I try to use the memory. if (!iFrame || iFrame->SizeInPixels().iWidth == 0) The example wants to dim out the image menu until the image is loaded. So if iFrame is NULL, the image is not loaded. So we will call the same code to dim out the image menu. Launch the application in the emulator again, and you should not see the crash. However, you will not be greeted by a working image converter UI either. It will probably look a lot like this.
Needless to say, this is not too useful. So we have to dig into the code and find out what is drawing this blue background to the entire screen. The problem is the code in the CImageAppView's ConstructL method void CImageAppView::ConstructL(const TRect& /*aRect*/) This code does exactly what it says it will do. Line 5 sets the background of the window to dark blue, and line 6 sets the CCoeControl's (the view) extent to the entire screen. Which effectively renders the emulator useless. The rectangle passed into the ConstructL function from the AppUi is also ignored. Therefore we never set the controls rectangle. Changing the ConstructL function to the code below should resolve our issues. void
CImageAppView::ConstructL(const TRect& aRect) Now after a recompile, you should be able to launch the imageconv application and to load up one of the sample images from the sample directory or one of your own that you have in your emulator's virtual drives.
There is still one nagging issue, the image menu title never becomes enabled even when an image is in the view. After some debugging it became clear that DynInitMenuBarL is only called when the toolbar is first initialized. I tried several methods to get the Symbian UI framework to call this method again, I even tried just calling SetToolbarL when ever we can SetBitmap in the View. I then decided to rewrite it in what I consider the correct method, by overriding the AppUi method DynInitMenuPaneL. This is called anytime you click on a menupane, and it allows the developer to modify the menu pane base on context. Here is version of DynInitMenuPaneL void CImageAppUi::DynInitMenuPaneL(TInt
aResourceId,CEikMenuPane* aMenuPane) At this time, 28 Aug 04, these are all the changes I have made to modify the Image Converter sample application in order for you to build and use it for the UIQ environment. Please contact me if you have found this useful, as it encourages me to continue with this process of modifying the Symbian example applications and to publish my modifications on this web site. Please also contact me if you find any errors in my logic so I can make corrections to the code.
|