Is there a library that would help to convert GDI+ GraphicsPath to HTML5 canvas Path? Or do I have to manually run through all GraphicsPath.PathPoints and GraphicsPath.PathTypes to emit corresponding HTML5 code (if so please share any hints)?
Unfortunately I couldn't find anything useful. Some people suggested using SVG as a way to "transport" curves from GDI to Canvas, but I couldn't find any decent SVG library for .NET. It took me quite some time to understand how the data inside GraphicsPath is stored because it is not as straightforward as you might think. This is what I've came up to.
Knowing how GraphicsPath actually work I've managed to recreate it using bunch of HTML5 functions: .moveTo(), .lineTo() and .bezierCurveTo(). The result was pretty neat although final string building takes some time and resulting JS files sometimes contain tenths of thousands lines of code if source GraphicsPath represents long text written with fancy font. Surprisingly Firefox handles them without problems.
I won't paste the code that I'm using as it is nothing special as long as you read and understand my answer from another SO question.
Related
I am in need of converting a base64 encoded svg to a png and then returning it to the client to be rendered.
The idea is that I am drawing an svg on the client using d3.js and I need to convert it to png.
I tried taking the javascript root and writing the svg on the canvas and then converting it toDataUrl but IE has problems with this on all versions so this is not a viable option.
I have searched online a bit and all I could find is Inkscape.
This is not a viable solution for me because of limited access on the server and frankly I don't think it's a good idea to install an entire application for a simple functionality.
Is there any other solution that can take a base 64 encoded svg and return a png that can be displayed in an image?
I found that since I have to support IE 11 I instead went with canvas to blob to PNG using "canvas-toBlob.js" and "FileSaver.js"
$("#save-btn").click(function()
{
$("#myChart").get(0).toBlob(function(blob)
{
saveAs(blob, "chart_1.png");
});
});
https://jsfiddle.net/mfvmoy64/155
I am facing the same issue, however I been able to render the SVG into an image so your users could right click to download the image or right click on the canvas. There is also Canvg which has a library that appears to work with IE, however it is not accurate for complex SVG and so does not meet my needs. Perhaps it will help you.
I have code in my question that will work in IE, just use the IMG or Canvas object, you do not need to call toDataURI.
Checkout Canvg, it might be of help.
Good luck! If you find a better solution, please let me know. :-)
I need draw some pictures and save it into a JPG file.
I know that the C# GDI can draw string with method Graphics.DrawString.
But what troubles me is that I need draw some math symbols, like below:
So are there some libraries can help me to do that? How can I get the math symbols with GDI?
In case you don't find a pure .NET solution, I would look for a command-line tool or a native DLL library which can render standard formattings like MathML or LaTeX math expressions. You will find plenty of FOSS stuff for these and I don't think it would be too hard to integrate. In case you work with bitmaps, you can just tell the 3rd party to render a given size bitmap. If you need vectorized drawings, then you could aim to produce your entire output in LaTeX or maybe you can turn MathML/LaTeX formulas to RTF/HTML.
I'm working with a set of DICOM images that are 512(columns) X 384(rows)
Is there a tool that would make the images 512X512? That is, filling the rows in this case to make it 512.
I've researched VTK with no luck.
Thanks!
Argh, you was almost there! In fact, VTK is not the proper tool for that. ITK is.
To be precise, VTK is for 3D visualization (that is, rendering of 3D objects), while ITK is specifically concerned for image processing.
So, using ITK, you could use a padding filter, here's a complete example from the official wiki, ready to be compiled and executed: http://public.kitware.com/pub/itk/Examples/src/Filtering/ImageGrid/PadAnImageWithAConstant/Documentation.html.
But, if you want to do the things in an easier way, I suggest MATLAB (ITK could be difficult to configure). In this case, this post could help: Padding an image in MATLAB.
Good luck!
I have been trying to create a decoder that will stream through a pcx file and display it on screen as a bitmap. I have managed to get the information from the image header by using a binary reader, but I have now reached the part that seems to take the least amount of code, yet is also the hardest: creating an array of pixels.
I understand that i may need to add two embeddded for loops to process the data. I have looked at some C and C++ examples, but struggle to understand them. I also need to get the array to display it. if you need more code then I will share it.
I have searched far and wide and read the spec, but I don't know how to approach this. If anyone could help me, I would be very grateful.
Regards.
The .NET does not support PCX images natively, you have two choices. Read the specification and decode the image by yourself or use some library.
As suggested on bytes.com you can use Dot Net Fireball (a Free Image wrapper) and load the image like this:
Fireball.Drawing.FreeImage freeImage = new FreeImage(#"c:\test.pcx");
Image image = freeImage.GetBitmap();
http://magick.codeplex.com/
a nice wrapper working with http://imagemagick.codeplex.com/
easy to setup and get going, see samples at the bottom of the page here:
http://magick.codeplex.com/documentation
I am currently working on a project and my goal is to locate text in an image. OCR'ing the text is not my intention as of yet. I want to basically obtain the bounds of text within an image. I am using the AForge.Net imaging component for manipulation. Any assistance in some sense or another?
Update 2/5/09:
I've since went along another route in my project. However I did attempt to obtain text using MODI (Microsoft Office Document Imaging). It allows you to OCR an image and pull text from it with some ease.
This is an active area of research. There are literally oodles of academic papers on the subject. It's going to be difficult to give you assistance especially w/o more deatails. Are you looking for specific types of text? Fonts? English-only? Are you familiar with the academic literature?
"Text detection" is a standard problem in any OCR (optical character recognition) system and consequently there are lots of bits of code on the interwebs that deal with it.
I could start listing piles of links from google but I suggest you just do a search for "text detection" and start reading :). There is ample example code available as well.
recognizing text inside an image is indeed a hot topic for researchers in that field, but only begun to grow out of control when captcha's became the "norm" in terms of defense against spam bots. Why use captcha's as protection? well because it is/was very hard to locate (and read) text inside an image!
The reason why I mention captcha's is because the most advancement* is made within that tiny area, and I think that your solution could be best found there.
especially because captcha's are indeed about locating text (or something that resembles text) inside a cluttered image and afterwards trying to read the letters correctly.
so if you can find yourself a good open source captcha breaking tool you probably have all you need to continue your quest...
You could probably even throw away the most dificult code that handles the character recognition itself, because those OCR's are used to read distorted text, something you don't have to do.
*: advancement in terms of visible, usable, and practical information for a "non-researcher"
If you're ok with using an online API for this, the API at http://www.wisetrend.com/wisetrend_ocr_cloud.shtml can do text detection in addition to just OCR.
Stroke width transform can do that for you. That's at least what MS developed for their mobile phone OS. A discussion on the implementation is here at https://stackoverflow.com/