×
Namespaces

Variants
Actions

Porting a desktop console application Potrace to S60 using Open C

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: ebra (13 Jun 2007)
Last edited: hamishwillee (27 Jul 2012)

Contents

Introduction

Potrace is an open source tool for converting bitmap images or raster to vector drawings.

Potrace.png


Potrace is a utility for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image. The input is a bitmap (PBM, PGM, PPM, or BMP format), and the default output is an encapsulated PostScript file (EPS).

Potrace produces the following output formats: EPS, PostScript, PDF, SVG (scalable vector graphics), Xfig, Gimppath, and PGM (for easy antialiasing).

Mkbitmap is a program distributed with Potrace which can be used to pre-process the input for better tracing behavior on greyscale and color images.

Potrace

Potrace home page

Version
1.8
 
Author
Copyright © 2001-2007 Peter Selinger.
 
License
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

Porting strategy

The idea behind the porting was to keep the changes to the minimum. Therefore a decision to keep the Potrace as a console application was made and a separate S60 UI application needs to be created to use it's functionality. See Communication options between Open C engine and S60 UI

The S60 UI application collects the options from the user launches Potrace and is informed when Potrace has finished it's task.

Another fact which supports separate process strategy is the way how Potrace handles error situations. When an error occurs Potrace simply exits with an error code and since there are quite a few places where the errors are handled it would mean quite extensive code modifications to handle errors differently.

With a separate S60 UI application the user sees only the front end application which can give user information about the error and the user can change parameters accordingly.

Changed functionality

Currently the S60 smart phones and multimedia computers support only a subset of SVG called SVG Tiny (SVG-T). http://www.w3.org

Therefore the backend of Potrace which creates the SVG files was modified to produce SVG-T files. Luckily Potrace uses only SVG modules which are also available for SVG-T and the only change is in the SVG file header.

Original output

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="468pt" height="289pt" viewBox="0 0 468 289"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.8, written by Peter Selinger 2001-2007
</metadata>
...

Modified output

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<svg baseProfile="tiny" version="1.0" xmlns="http://www.w3.org/2000/svg"
width="468pt" height="289pt" viewBox="0 0 468 289"
preserveAspectRatio="xMidYMid meet"
xmlns:xlink="http://www.w3.org/1999/xlink">
<metadata>
Created by potrace 1.8, written by Peter Selinger 2001-2007
</metadata>
...

New files

bld.inf

/**
* Copyright (c) 2007 Nokia Corporation
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
PRJ_PLATFORMS
WINSCW ARMV5 GCCE
 
PRJ_MMPFILES
gnumakefile icons_scalable_dc.mk
potrace.mmp

potrace.mmp

/**
* Copyright (c) 2007 Nokia Corporation
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
TARGET potrace.exe
TARGETTYPE exe
UID 0x100039CE 0xA0002AD7
VENDORID 0
 
SOURCEPATH ..\data
START RESOURCE potrace_reg.rss
#ifdef WINSCW
TARGETPATH \private\10003a3f\apps
#else
TARGETPATH \private\10003a3f\import\apps
#endif
END //RESOURCE
 
SOURCEPATH ..\src
SOURCE main.c
SOURCE backend_eps.c
SOURCE backend_gimp.c
SOURCE backend_pdf.c
SOURCE backend_pgm.c
SOURCE backend_svg.c
SOURCE backend_xfig.c
SOURCE curve.c
SOURCE decompose.c
SOURCE flate.c
SOURCE getopt1.c
SOURCE lzw.c
SOURCE potracelib.c
SOURCE render.c
SOURCE trace.c
SOURCE greymap.c
SOURCE bitmap_io.c
 
USERINCLUDE ..\inc
 
SYSTEMINCLUDE \epoc32\include
 
// Include path for Open C headers
SYSTEMINCLUDE \epoc32\include\stdapis
 
// Using main() as entry point
STATICLIBRARY libcrt0.lib
 
LIBRARY libc.lib
LIBRARY libm.lib
LIBRARY euser.lib
 
 
// No capabilities needed by this application
CAPABILITY None

potrace_reg.rss

/**
* Copyright (c) 2007 Nokia Corporation
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#include <appinfo.rh>
 
UID2 KUidAppRegistrationResourceFile
UID3 0xA0002AD7
 
RESOURCE APP_REGISTRATION_INFO
{
app_file="potrace";
 
embeddability=KAppNotEmbeddable;
newfile=KAppDoesNotSupportNewFile;
hidden = KAppIsHidden;
}

potrace.pkg

;/**
; * Copyright (c) 2007 Nokia Corporation
; * This program is free software; you can redistribute it and/or modify
; * it under the terms of the GNU General Public License as published by
; * the Free Software Foundation; either version 2 of the License, or
; * any later version.
 
; * This program is distributed in the hope that it will be useful,
; * but WITHOUT ANY WARRANTY; without even the implied warranty of
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; * GNU General Public License for more details.
 
; * You should have received a copy of the GNU General Public License
; * along with this program; if not, write to the Free Software
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
; */
 
;Language - standard language definitions
&EN
 
; standard SIS file header
#{"potrace"},(0xA0002AD7),1,0,0
 
;Localised Vendor name
%{"Nokia"}
 
;Unique Vendor name
:"Nokia"
 
;Supports S60 v 3.0
[0x101F7961], 0, 0, 0, {"Series60ProductID"}
 
;Files to install
"$(EPOCROOT)epoc32\release\$(PROJECT)\$(TARGET)\potrace.exe"-"!:\sys\bin\potrace.exe"
"$(EPOCROOT)epoc32\data\z\private\10003a3f\import\apps\potrace_reg.rsc" -"!:\private\10003a3f\import\apps\potrace_reg.rsc"
 
;required for application to be covered by backup/restore facility
"backup_registration.xml"-"!:\private\A0002AD7\backup_registration.xml"

backup_registration.xml

<?xml version="1.0" standalone="yes"?>
<backup_registration>
<system_backup/>
<restore requires_reboot = "no"/>
</backup_registration>

Icons_scalable_dc.mk

ifeq (WINS,$(findstring WINS, $(PLATFORM)))
ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
else
ZDIR=$(EPOCROOT)epoc32\data\z
endif
 
TARGETDIR=$(ZDIR)\resource\apps
ICONTARGETFILENAME=$(TARGETDIR)\potrace.mif
 
ICONDIR=..\gfx
 
do_nothing :
@rem do_nothing
 
MAKMAKE : do_nothing
 
BLD : do_nothing
 
CLEAN : do_nothing
 
LIB : do_nothing
 
CLEANLIB : do_nothing
 
RESOURCE :
mifconv $(ICONTARGETFILENAME) \
/c32 $(ICONDIR)\qgn_menu_potrace.svg
 
FREEZE : do_nothing
 
SAVESPACE : do_nothing
 
RELEASABLES :
@echo $(ICONTARGETFILENAME)
 
FINAL : do_nothing

Limitations

This has been tested on S60 3rd Edition version MR and FP1 using Carbide 1.1 and can be set up using the article Open C and Carbide C

Modified files

Currently the Open C tool chain does not support Autoconf. GNU's Autoconf is a tool for configuring source code and Makefiles.

The original Potrace code contained lines such as:

fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n");

which were changed to:

fprintf(stdout, "potrace 1.8. Copyright (C) 2001-2007 Peter Selinger.\n");

'main.c'

Add the following #ifdef lines for linking to Open Clibrary

 #ifdef __GCCE__
#include <staticlibinit_gcce.h>
#endif

before this #ifdef

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
This page was last modified on 27 July 2012, at 07:15.
76 page views in the last 30 days.