This page was last modified 21:27, 26 October 2007.
Portando a aplicação desktop Potrace para S60 usando Open C
From Forum Nokia Wiki
Original: Porting a desktop console application Potrace to S60 using Open C
Contents |
Introdução
Potrace é uma ferramenta de código livre para converter imagens bitmap em images vetoriais.
Potrace é um utulitário que transforma um bitmap em um imagem escalável. A entrada é um bitmap (PBM, PGM, PPM, or BMP format), e o formato de saída padrão é um arquivo postscript encapsulado (EPS).
Potrace produz os seguintes formatos: EPS, Postscript, PDF, SVG (gráficos de vetores escaláveis -- scalable vector graphics), Xfig, Gimppath, e PGM (para facilitar antialiasing).
Mkbitmap é um programa distribuído junto com o Potrace que pode ser usado para pré-processar a entrada para obter melhores resultados em imagens coloridas ou em preto e branco.
Potrace
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.
Estratégias de porte
A idéia por trás do porte é minimizar as modificações. Portante, a decisão de deixar o Potrace como uma aplicação de linha de comando foi feita e uma aplicação S60 precisa ser criada para usar sua funcionalidade. Veja Opções de comunicação entre máquina Open C e S60 UI.
A interface de usuário S60 lê as opções do usuário e executa Potraca e espera até que ele termine sua tarefa.
Outro fator que suporta a estratégia de separar os processos é a forma como Potrace trata situações de erro. Quando um erro ocorre Potrace simplesmente termina com um código de erro. Como existem poucos lugares onde erros são tratados, pode ser bastante custoso modificar o código para tratar os erros apropriadamente.
Com uma aplicação S60 UI separada o usuário vê apenas uma capa da aplicação que pode dar informações ao usuário sobre erros e o usuário pode modificar parâmetros apropriadamente.
Funcionalidade modificada
Atualmente os smartphones e computadores multimedia S60 suportam apenas um subconjunto do SVG chamado SVG Tiny (SVG-T).
Portante, a máquina Potrace que cria arquivos SVG foi modificada para produzir arquivos SVG-T. Felizmente Potrace usa apenas módulos SVG que estão também disponíveis para SVG-T e a única mudança necessária foi no arquivo de cabeçalho SVG.
Saída original
<?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> ...
Saída modified
<?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> ...
Arquivos novos
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 Series 60 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
Limitações
O porte do Potrace foi testado usando S60 3a. Edição versão MR e FP1 usando o Carbide 1.1 e pode ser refeita usando o artigo Open C and Carbide C.
Arquivos modificados
Atualmente Open C não suporta Autoconf. O autoconf GNU é uma ferramenta para configurar código fonte e Makefiles.
O código original do Potrace contém linhas como:
fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2007 Peter Selinger.\n");
que foram modificadas para:
fprintf(stdout, "potrace 1.8. Copyright (C) 2001-2007 Peter Selinger.\n");
'main.c'
E as seguintes linhas #ifdef foram adicionadas para ligar com as bibliotecas Open C.
#ifdef __GCCE__ #include <staticlibinit_gcce.h> #endif
antes do seguinte #ifdef
#ifdef HAVE_CONFIG_H #include "config.h" #endif
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| is it possible to add icon to desktop on symbian? | topwingo | General Symbian C++ | 1 | 2007-01-09 04:27 |
| browser issue on N70 and N80... | sanjubhi | General Browsing | 7 | 2007-01-21 19:23 |
| Send and receive sms through Desktop | Pravin_Bagade | Mobile Java Networking & Messaging & Security | 1 | 2007-09-04 18:35 |
| Remote desktop via mobile network | conian | General Symbian C++ | 4 | 2007-10-11 14:02 |
| Netbeans 6.0 and Symbian S60 emulator nS60_jme_sdk_3rd_x | tmsaur | Mobile Java Tools & SDKs | 1 | 2008-01-26 01:31 |

