This page was last modified 10:39, 1 July 2008.
CS001058 - Using SVG
From Forum Nokia Wiki
| 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 |
Overview
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.
MMP file
The following capabilities and libraries are required:
CAPABILITY NONE
LIBRARY aknicon.lib
icons_aif_scalable.mk Icon make file
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
bld.inf file
Add the gnumakefile into your applicatin bld.inf:
PRJ_MMPFILES
gnumakefile icons_aif_scalable.mk
Header file
public: void LoadIconL(TInt aIndex, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, TSize& aSize); void Draw( const TRect& aRect ) const; private: CFbsBitmap* iBitmap; CFbsBitmap* iMask; TSize iBitmapSize;
Source file
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); } }
pkg file
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"
Postconditions
The SVG file has been created as an icon and drawn on the screen.
See also
KIS000398_-_SVG_rendering_problems_caused_by_missing_viewBox_attribute
KIS000531_-_Compatibility_problem_with_binary-encoded_SVG_images
TSS000295_-_How_to_compress_SVG_files
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Embebed Flash Lite objects | fjorge_ht | General Browsing | 5 | 2007-09-04 21:05 |
| Midlets with SVG content. | javalis@rogers.com | Graphics & Video & Streaming | 3 | 2008-05-22 18:42 |
| SVG issue in S60 3rd | iulian_moldovan | General Symbian C++ | 33 | 2007-01-01 07:25 |
| Problem with svg for icon application | silviuccia | Symbian User Interface | 4 | 2007-12-05 14:29 |
| svg menus | Larry101 | Mobile Java General | 0 | 2007-03-06 08:44 |
