C++ save image as SVG - c++

I have to save my chart as SVG file (my enviroment C++, eclipse C/C++, windows 7).
I'm able to save it as image file (as you can see bellow), but it's not enough.
I've tried:
gnuplot (gnuplot_i.hpp): don't know how to save the image as SVG file
simple-svg: don't know how not to show black points
cairo: i'm not able to use it at all
Could you recommend me some light and easy-to-understand-and-install tool which helps me to draw charts in C++ and save it directly as SVG file (so nothing like jpg2svg convertor:-)?

I know in command-line gnuplot, it is possible to save a plot as a SVG by doing:
> set term svg
> plot ...
Looking over gnuplot_i.hpp, I would suggest trying:
Gnuplot myGP;
myGP.set_terminal_std("svg");
myGP.setGNUPlotPath("/your/path/here");
myGP.showonscreen();
While I haven't tested it (and there may be more complexity in the Gnuplot class than I can see from the header file), the general idea is there. Set the terminal to svg, set the output path, and plot.

How exactly do you obtain that image? Is there something specific to it that prevents you from just fprintf-ing the image, since SVG is an XML (text) file format?

Related

Use clipboard images to draw paths that repeat over entire length of the line

Using Inkscape, I have an image path created similar to below:
With this image copied to the clipboard I can then draw paths using the image, however each line I draw will 'stretch' the base image...for example:
Or...
My question is to find if there is a way to prevent the 'stretching'...? I would like the base image copied to clipboard to 'fill' and/or 'repeat' over the entire length of the drawn line...is this possible? To show it graphically I would like to draw line(s) where the base image repeats to cover the entire length of the drawn line, similar to this:
...Possible? Any advice appreciated. I thank you in advance.
Sure. Use the 'Pattern along Path' extension or the 'Pattern along Path' path effect (< recommended, because you can modify it 'live').
Actually, that path effect is the same one as the 'from clipboard' option in the Bézier and Pencil tools, only with the 'single, stretched' option instead of 'repeated'.

how vtk do th zoom for jpeg reader and dicom reader

This is an example of a code of vtk to read a jpeg image http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/JPEGReader or dicom file http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOM ,
when I run these projects, i can zomm the image with the right button of the mouse
however, in the code there is nothing in a direct relation with zoom or something like this, so there is something inside the classes
can anyone tell me how vtk can do this zoom because i need it in another project ?
Yes, certainly there is code inside the other classes. vtkRenderWindow, vtkRenderWindowInteractor, and vtkRenderer are all referenced by that sample. You can trace down the zooming code through those. https://github.com/Kitware/VTK/tree/master/Rendering/Core

Quil: Don't even open the window

I'm trying to use quil to procedurally generate images. I think it's really great, but I'm not trying to display the image at all. I'm just trying to save the image to a file.
Is it possible to not actually open the window and just save the file directly?

Qt rendering an image and showing it

I have a small app that renders an image. It's in .ppm format and opens nicely in Mac's Xee image viewer. The image is created in the default project folder.
However, the user doesn't know where the image is after it is rendered and I would like to open it automatically or perhaps offer where to save the image before it is created.
That is the first problem. The second problem is .ppm - it's not opened by default on Windows, you need Irfan Viewer or something alike.
Is there a way to solve both those problems easily in Qt? For instance, the image is created where the user wants and my app displays it in that ppm format without using some other software? And If a user wants to reopen the image, I should probably make it possible, as well.
I am not a Qt, nor a C++ developer so I am struggling a bit with this, but I have to do it.
Thanks in advance for the tips and advices.
If you convert your image to a QImage (if it's not one already), you can specify where and in what format to save it when calling the QImage::save method.

Decoding Microsoft True Type Font Files

I am working on an embedded platform (STM32F407) with a TFT LCD as a display (480x800px) and would like to make my user interface somewhat customizable to the end user. I figured the best source of fonts would be windows compatible as their the most common.
My current implementation uses my own custom drawn font in a binary format and a descriptor table giving the character width and ascii value but having to draw my own font bit by bit is tedious.
I would like to read in a True Type Font file from an SD card and be able to use the different sized glyphs inside it but I have not seen a strait forward implementation on how to actually achieve this magic. Can somebody point me to a good c/c++ example of what I am looking for?
Even better as a way to iron out the kinks I would like to make a simple gcc command line program that will print out my input with a selected font using '#' as pixels. That way I can just worry about implementation and not any other random bugs that might pop up.
Can anybody help me out?
Perhaps you can use the Freetype library.
As duskwuff says: TTF is primarily a vector format, would need to write a renderer. Better off using an image file to define the font, or using a bitmap font format like FNT (Windows) or BDF (UNIX).
Here is my answer to my own question: AngelCode's BMFont & Useage. This makes choosing selective characters from the installed char set, mix in a font and exports an image with a map file to each character. Simple to use.