| ID | CS001058 | Creation date | July 1, 2008 |
| Platform | S60 3rd Edition, MR | Tested on devices | Nokia N95 |
| Category | Symbian C++ | Subcategory | Graphics |
| Keywords (APIs, classes, methods, functions): AknIconUtils, SVG |
The following example shows how to add an SVG image into an application and draw it.
You can use, for example, Inkscape which is a free SVG editor.
The following capabilities and libraries are required:
CAPABILITY NONE
LIBRARY aknicon.lib
This is the icons makefile that generates the icons.mif file from your icon.svg SVG image.
ifeq (WINS,$(findstring WINS, $(PLATFORM)))
ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
else
ZDIR=$(EPOCROOT)epoc32\data\z
endif
TARGETDIR=$(ZDIR)\resource\apps
MY_ICONS=$(TARGETDIR)\icons.mif
HEADERDIR=$(EPOCROOT)epoc32\include
MY_ICONS_HEADER=$(HEADERDIR)\icons.mbg
ICONDIR=..\gfx
do_nothing :
@rem do_nothing
MAKMAKE : do_nothing
BLD : do_nothing
CLEAN : do_nothing
LIB : do_nothing
CLEANLIB : do_nothing
RESOURCE :
mifconv $(MY_ICONS) /h$(MY_ICONS_HEADER) \
/c32 $(ICONDIR)\icon.svg
FREEZE : do_nothing
SAVESPACE : do_nothing
RELEASABLES :
@echo $(MY_ICONS)
@echo $(MY_ICONS_HEADER)
FINAL : do_nothing
Add the gnumakefile into your applicatin bld.inf:
PRJ_MMPFILES
gnumakefile icons_aif_scalable.mk
public:
void LoadIconL(TInt aIndex, CFbsBitmap*& aBitmap,
CFbsBitmap*& aMask, TSize& aSize);
void Draw( const TRect& aRect ) const;
private:
CFbsBitmap* iBitmap;
CFbsBitmap* iMask;
TSize iBitmapSize;
void CYourControl::ConstructL()
{
iBitmapSize = TSize(50,50);
LoadIconL(EMbmIconsIcon, iBitmap, iMask, iBitmapSize);
}
void CYourControl::LoadIconL(TInt aIndex, CFbsBitmap*& aBitmap,
CFbsBitmap*& aMask, TSize& aSize)
{
_LIT(KIconsFile, "\\resource\\apps\\icons.mif");
// Create icon from SVG
AknIconUtils::CreateIconL(aBitmap, aMask, KIconsFile, aIndex, aIndex + 1);
// Give size
AknIconUtils::SetSize(aBitmap, aSize);
}
void CMultiViewsContainer1::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
// Draws icon bitmap from SVG into screen
if (iBitmap)
{
TPoint pos(0,0);
TRect rect(TPoint(0,0), iBitmapSize);
gc.BitBltMasked(pos, iBitmap, rect, iMask, EFalse);
}
}
Add the following line into your .pkg file. It will install the .mif file (SVG icons).
;Files to install
"epoc32\data\Z\RESOURCE\apps\icons.mif" -"!:\resource\apps\icons.mif"
The SVG file has been created as an icon and drawn on the screen.
KIS000398_-_SVG_rendering_problems_caused_by_missing_viewBox_attribute
KIS000531_-_Compatibility_problem_with_binary-encoded_SVG_images
No related wiki articles found