Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Svg Painter
Svg Painter [message #20247] Thu, 05 March 2009 01:28 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I have uploaded to bazaar the code and demo to test a function to open and show with Painter static .svg files (Scalable Vector Graphics):

    void ParseSVG(Painter& p, const char *svg);


This is an initial version and it is open to contributions by improving it or by testing it with .svg files.

I have included the next files and folders:

- PainterSvg
   - ParseSvg.cpp: The code
- PainterSvg demo
   - SvgDemo.cpp: The demo (compatible with Painter demo)
   - Examples.h: Rest of files have been taken from Painter demo
   - Examples.lay
   - init
   - main.cpp
   - PainterSvg demo.upp


To open the .svg file copy it in C:\demo.svg or change String file in SvgDemo.cpp.

Before using it please download the last Upp svn.

It has been tested with GCC in Ubuntu/Linux and MinGW/MSC9 in XP.

Here I enclose you a screenshot.

Best regards
Koldo

index.php?t=getfile&id=1603&private=0
  • Attachment: svgdemo.jpg
    (Size: 47.84KB, Downloaded 910 times)


Best regards
Iñaki

[Updated on: Thu, 05 March 2009 08:39]

Report message to a moderator

Re: Svg Painter [message #20300 is a reply to message #20247] Sat, 07 March 2009 20:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hi,

this might be useful:

http://www.w3.org/Graphics/SVG/WG/wiki/Test_Suite_Overview

Mirek
Re: Svg Painter [message #20301 is a reply to message #20300] Sat, 07 March 2009 20:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have done following changes:

1) Changed the interface: const char *svg now points to actual SVG text, not to filename (-> you can use other resources than files, while doing LoadFileBOM is simple).

2) I have "separated" SvgPainter to package

3) I have created SvgView test application that allows you to browse files and view them as .svg.

That said, I have tried this with .svg files from above link and the result is sad Smile There is a lot of work left to do.

Mirek

[Updated on: Sat, 07 March 2009 20:56]

Report message to a moderator

Re: Svg Painter [message #20312 is a reply to message #20301] Mon, 09 March 2009 10:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello luzr

Yes that is true. Svg format has meny options.

For example you can enter a color in at least 5 ways:
- 3-digit hex
- 6-digit hex
- rbg() integer form
- rgb() percentage form
- named ('HTML') colors

and the same for many things.

I can only say that I will continue adding things and if somebody needs to paint certain file not supported, he/she can send a sample and I will add the necessary for supporting it.

Best regards
Koldo


Best regards
Iñaki
Re: Svg Painter [message #20329 is a reply to message #20247] Wed, 11 March 2009 22:19 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I have added Image support and changed the function to:

void ParseSVG(Painter& p, const char *svg, const char *folder = '\0');

as sometimes when the image file name referenced in the svg file is in the svg folder, the folder name is not in the file so we have to give to ParseSVG() the svg folder to search there.

It is also changed the demo to open a FileSel window to search for the svg file. Also there are two samples included.


Best regards
Koldo


Best regards
Iñaki
Re: Svg Painter [message #20330 is a reply to message #20329] Wed, 11 March 2009 23:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 11 March 2009 17:19


It is also changed the demo to open a FileSel window to search for the svg file. Also there are two samples included.


Ehm, have you seen SvgView?

Re: Svg Painter [message #20334 is a reply to message #20247] Thu, 12 March 2009 09:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello luzr

Perhaps we can remove PainterSvg demo...

Best regards
Koldo


Best regards
Iñaki
Re: Svg Painter [message #26077 is a reply to message #20334] Tue, 30 March 2010 18:05 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Hi!

There is a small bug in SvgView. The code should be as following to avoid the partial clipping of images:
void SvgView::Load(const char *filename)
{
	img.SetImage(Null);
	ImageBuffer ib(img.GetSize());


Also a bigger bug, the serialization of "files" causes an assert failure.

And something a little bit strange, the pattern used for drawing empty image backgrounds is different on XP and Vista. Is this intentional?

I have started improving SVG compatibility. Right now I'm implementing viewports and other small details and I manged to get two images from on-line SVG spec almost pixel perfect. This is encouraging. On the other hand, my implementation is poor and I'm going to start from scratch with viewports. I'm afraid that I'm going to have to keep in memory all shapes and after computing the bounding box apply scale and translate to achieve correct implementation. Unfortunately, Even SVG Tiny is extremely complicated to get compatible and this without animation. SVG is a devilishly complicated format masquerading as something simple.

The good news is that Firefox has very poor SVG support, so I thing we can reach that level with a little effort. Opera is very good on the other hand. Anyway, I just have a few SVGs that I would like to load without modifications.
Re: Svg Painter [message #26110 is a reply to message #26077] Thu, 01 April 2010 15:44 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I have attached a small and very hackish version which almost loads 30 examples from the official test suite. These tests have animation and we don't, but except for this little detail it is pretty much pixel perfect.

It also includes the beginning of a feature that will log all elements that are not understood by the current implementation. This might be useful when someone decides to do full implementation (GSoC 2011? Smile))

I'm only uploading this as a sample and test; it is not ready for production yet. Also, I need a place to keep a backup Smile.

Re: Svg Painter [message #26572 is a reply to message #26110] Wed, 12 May 2010 12:42 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Here is an updated version of the test packages. I contains a few official test pictures and the compatibility is OK in some cases. It even has extremely primitive animation support that I quickly threw together.

While the compatibility with official test cases has increased, the compatibility with the few pictures included in the original package, like "demo.svg" is zero now.

  • Attachment: svg.zip
    (Size: 102.09KB, Downloaded 228 times)
Previous Topic: usvn - SVN for dummies (and me)
Next Topic: Docking: How to call a callback on DockableCtrl's close
Goto Forum:
  


Current Time: Thu Mar 28 22:24:29 CET 2024

Total time taken to generate the page: 0.02259 seconds