Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


6 Pages123>»
Options
Go to last post Go to first unread
Offline Alex M.  
#1 Posted : 14 February 2016 09:46:23(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
This Image Region plugin is continuation of work on a plugin first created by Uni and further developed by Kay.
http://en.smath.info/for...st1786_Image-Region.aspx
http://en.smath.info/for...itable-Image-Region.aspx
The plugin is compatible with existing Image Region.

I would like to thank Davide Carpi and Martin Kraska for help with my programming efforts.

Improvements over previous version of Image Region:

- Enabled selection between blank file types (previously only a blank .png would be created)
- You can set the size of the blank file by adjusting the dimensions of the region (previously the size of the new image was static)
- Scaling of renders from SVG files created by inkscape is fixed (previously .svg did not scale when region dimensions were changed)
- Copy/paste and Ctrl+c will generate true region clones with a new filename. The copy created can be edited separately from the source region (previously the copy would share the image file with its parent - changes in copied region would reflect in its parent region)
- "Open With..." functionality is implemented
- Image automatically loads when loading .sm workbook or on duplication (previously a blank file would be displayed - needed to click on image to reload)
- Region update on resizing was supressed to speed up re-rendering of SVG
- Implemented in-memory image rotation. Mildly useful when you need to fit landscape image to a portrait page without altering the source file
- Native rendering of PNG, SVG, PDF and PSD allows for display of ANY file format that can export to these four, by hand, to either the TEMP folder in appdata or to the .sm workbook root directory folder.

Support of new file formats:

- Workflow of blank file format selection: select extension with right click; double click or "Open With..." - this will create a blank file of your choice on the fly.

Formats supported:

- PNG

- SVG

- PSD - New File Type
Native Photoshop file format - outstanding for quick sketches in Paint.NET, if layer support is preferred (image markup). Blank PSD file is created from static Base64 string.

- PDF - New File Type
Surprisingly good for markup / sketches using Bluebeam Revu

- DXF - New File Type - CAD standard
Partial support. DXF file can be saved within SMath workbook like any other format. However the ImageRegion cannot render the DXF. To display sketch in SMath one must export either PNG SVG or PDF file with filename identical to DXF file to the .sm workbook root directory, or Temp directory where DXF is located while .sm workbook is open. Blank DXF file is created from static Base64 string.

- DWG - New File Type - CAD standard
Partial support. DWG file can be saved within SMath workbook like any other format. However the ImageRegion cannot render the DWG. To display sketch in SMath one must export either PNG SVG or PDF file with filename identical to DXF file to the .sm workbook root directory, or Temp directory where DWG is located while .sm workbook is open. Blank DWG file is created from static Base64 string.

- SKP - New File Type - Trimble SketchUp Make 3D file type
Partial support. SKP file can be saved within SMath workbook like any other format. However the ImageRegion cannot render the SKP. To display the sketch in SMath one must export either PNG SVG or PDF file with filename identical to SKP file to the .sm workbook root directory, or Temp directory where SKP is located while .sm workbook is open. Blank SKP file is created from static Base64 string.

- CDR - New File Type - CorelDRAW
Partial support. CDR file can be saved within SMath workbook like any other format. However the ImageRegion cannot render the CDR. To display the sketch in SMath one must export either PNG SVG or PDF file with filename identical to CDR file to the .sm workbook root directory, or Temp directory where CDR is located while .sm workbook is open. Blank CDR file is created from static Base64 string.

Some examples of plugin use:
ImageTestFile.sm (3,925kb) downloaded 183 time(s).
ImageTestFile.pt.2.sm (3,418kb) downloaded 134 time(s).
balloon.jpg

Edited by user 24 May 2016 00:34:18(UTC)  | Reason: Not specified

thanks 5 users thanked Alex M. for this useful post.
on 14/02/2016(UTC),  on 14/02/2016(UTC),  on 15/02/2016(UTC),  on 15/02/2016(UTC),  on 21/04/2016(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline kilele  
#2 Posted : 14 February 2016 21:23:28(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Possible offtopic:
Have you thought of converting pdf to png internally by means of some component like imagemagick: http://www.imagemagick.o...ary-releases.php#windows
Offline Alex M.  
#3 Posted : 14 February 2016 23:06:51(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: kilele Go to Quoted Post
Possible offtopic:
Have you thought of converting pdf to png internally by means of some component like imagemagick: http://www.imagemagick.o...ary-releases.php#windows


Actually using imagemagick was my first choice for all the file formats. Unfortunately after the first trial run I ran into a dependency error (Microsoft Visual C++ Redistributable). Downloading 2008 package did not fix it. After digging through forums I got it to work by downloading more packages.

That killed imagemagick for me right there. I see more than a few unhappy folks, if every SMath user will have to download bunch-o-stuff (and dig through forums) just to get Image Region to work again.

Right now I use seprate libraries for .svg, .psd, and .pdf - they need no dependencies and are guaranteed to work. The plugin size is larger than optimal but it is a small price to pay for stability and consistency I would think.

Offline kilele  
#4 Posted : 15 February 2016 01:12:32(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
I thought the dll would suffice. Oh I see there is a wrapper of the library called Magic.NET : https://magick.codeplex.com
Thanks for the plugin!
Offline kilele  
#5 Posted : 15 February 2016 01:29:23(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
According to the documentation: https://magick.codeplex.com/documentation
It seems that there is no need to install the entire software but only a few .dll and referencing them in magick.net
Offline Alex M.  
#6 Posted : 15 February 2016 01:49:16(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: kilele Go to Quoted Post
According to the documentation: https://magick.codeplex.com/documentation
It seems that there is no need to install the entire software but only a few .dll and referencing them in magick.net


That is exactly what I used. Hey, if you are interested you can try to get imagemagic to work (using the latest source files of Image Region). If you get it to properly load or convert a file - send me your code - if it works on my PC as well I will look into getting it implemented.

Don't get me wrong - I have already had a go at this, and ended up using something different because it did not work reliably.
Offline kilele  
#7 Posted : 15 February 2016 02:25:23(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Alex,
I thought you might have discarded the pdf option soon. There are more alternatives on sourceforge like PDFsharp.
I really appreciate your posts explaining the process on how to develop plugins. Now I should follow your steps and see if I can get the hang of it to achieve basic things. After all, the Visual Studio IDE must be quite friendly explaining what's what and what things do what. Regards Good
Offline kilele  
#8 Posted : 15 February 2016 04:56:52(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Jean
What do you mean by PP conference? Good
Now that you mention pdf reports, PDFsharp comes along with another component called MigraDoc which seems useful to improve pdf generation in SMath.

Offline Jean Giraud  
#9 Posted : 15 February 2016 06:39:03(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: kilele Go to Quoted Post
Jean
What do you mean by PP conference?
Now that you mention pdf reports, PDFsharp comes along with another component called MigraDoc which seems useful to improve pdf generation in SMath


"PP Conference": read as "Smath forum Category of Pain & Prestige"
i.e: Editable Image Region category.
Since I made Smath work and working so well most of my projects,
one thing puzzles me: What ?
In the registry, there is no trace of "Smath", just a little bit
vxMaxima, 3D plot and another one ? PDF ?

Does that explain Smath some sort of Windows Clone ? [my own words].
From any Windows applications ... [Wingrab, IrfanView, Paint, Kalkulator ...
I can paste image/graph canvas to Smath, but nothing from Smath can be
copy/paste in Paint. The Smath "Copy to clipboard" is between itself,
i.e: not shared with other Windows applications.

PDFsharp ? not familiar. At one point, I got fedup of freware PDF
[PDF Creator, Cute PDF, PDF 995 ... ] I purchased "Nuance PDF" [ScanSoft]
Works well for true Windows applications, but works crappy for Smath.

Jean


Offline kilele  
#10 Posted : 15 February 2016 07:29:38(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Good point about the 'copy to clipboard' issue.

PdfSharp and migradoc are not programs but .net libraries which may be useful for this plugin and also to make Smath generate pdf reports with bookmarks.

Pain and prestige. Excuse my thickness, it's late here and can't sleep due to fever.
I was thinking of figuring out interfaces, methods, overriding thingies.. Apologies for the offtopic.

EDIT:

Oops pdfsharp cannot open existing pdf files and needs ghostscript to do so.
However it could be useful to generate pdfs from smath worksheets. Maybe generating pdf bookmarks out of smath area regions.

Edited by user 15 February 2016 07:59:48(UTC)  | Reason: Not specified

Offline Alex M.  
#11 Posted : 17 February 2016 07:54:41(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: kilele Go to Quoted Post
Alex,
I thought you might have discarded the pdf option soon. There are more alternatives on sourceforge like PDFsharp.
I really appreciate your posts explaining the process on how to develop plugins. Now I should follow your steps and see if I can get the hang of it to achieve basic things. After all, the Visual Studio IDE must be quite friendly explaining what's what and what things do what. Regards Good


Kilele,

To make sure there is no confusion - my update to Image Region plugin fully supports PDF by utilizing ghostscript dll's. I am hesitant to post Image Region plugin with PDF support to extension manager because I had a lot of trouble in the past downloading another plugin that relies on ghostscript - Pdf Files plugin (likely due to its size). Full version of the Image Region plugin will be always located in this thread.

Also speaking of posting this to extension manager - currently I am checking the plugin for bugs (by using it at work), and I will upload it to the extension manager over the weekend.
Offline kilele  
#12 Posted : 17 February 2016 09:57:04(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
Alex,

Another approach could be let the user install Ghostscript.
When trying to open PDFs the user would be prompted to install Ghostscript. You might want to demand this portable version for the ease of installing, a package of 14mb: http://portableapps.com/...ies/ghostscript_portable Later this same installation could be easily found by other SMath plugins based on the use of Ghostscript.

Edited by user 17 February 2016 10:09:26(UTC)  | Reason: Not specified

Offline Alex M.  
#13 Posted : 21 February 2016 22:08:43(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Plugin uploaded to extension manager. I have decided to include PDF support to test it. File is large and takes good 5 minutes to download but seems to work - might leave it like that for now.

Let me know if download successful or not for you, or if you think that its best to remove PDF support to keep plugin file size small.

After two weeks of plugin use PDF + BlueBeam Revu turned out to be best environment for quick sketches / markup.

Edited by user 21 February 2016 22:17:21(UTC)  | Reason: Not specified

Offline Alex M.  
#14 Posted : 10 March 2016 08:33:29(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Plugin update - fixed broken Import of a file (context menu item). Creation of the image file by specifying its name in the placeholder now works as expected for all file types.

Edited by user 10 March 2016 19:06:52(UTC)  | Reason: Not specified

Offline Alex M.  
#15 Posted : 10 March 2016 09:12:20(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Hello Franco,

BTW I can't resize the image from the context menu of the Image region, an hard crash occours

2016-02-25 16_36_07-SMath Studio Desktop - [DISLIN.%20Example1.sm_].png
2016-02-25 16_36_31-SMath Studio Desktop - [DISLIN.%20Example1.sm_].png


There is something seriously wrong with .svg produced by DISLIN.

neither original image region's renderer SharpVectors - SVG, nor the current codeplex SVG rendering engine can properly display the image.
thanks 1 user thanked Alex M. for this useful post.
on 10/03/2016(UTC)
Offline Alex M.  
#16 Posted : 19 March 2016 19:52:29(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Hi All,

I have been toying with the idea of being able to load multiple image files into one region. Primarily this would allow to annotate a dynamic image file with a static editable image. Another use can be to load two or more dynamic files at the same time.. for whatever reasons you would like to do that.

What do you guys think? Would this be useful for anyone but myself (before I invest any time in this)?

There is a notable drawback - I can save only one file within SMath canvas easily, so the only data that would be saved within SMath file is the file that was created by hand (double click or open as), all other files that were loaded as a string will not be saved within workbook.

After giving it a thought I guess I could just overlay one region on top of another without all that extra hassle

Edited by user 19 March 2016 20:23:13(UTC)  | Reason: Not specified

Offline Alex M.  
#17 Posted : 19 March 2016 20:05:32(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: uni Go to Quoted Post
Originally Posted by: Alex.M Go to Quoted Post
Hi All,

I would love to make the Image Region handle DISLIN properly, however I was not able to come up with a fix myself.

From what I understood, the SVG engine (https://svg.codeplex.com/) has trouble reading Height/Width of the .svg produced by DISLIN. If any of you guys need the functionality enough to investigate and come up with a solution I would love to implement it in the code of the Image Region.


The svg file doesn't contain viewBox attribute. The ImageRegion plugin could check its availability and if it is not, then add your own:

Code:
<svg width="100%" height="100%" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg">


This is the code I have now to load SVG:

Code:

if (Path.GetExtension(loadFromPath).Equals(".svg") || Path.GetExtension(loadFromPath).Equals(".svgz"))
            {
                try
                {
                    var SVGdoc = SvgDocument.Open(loadFromPath);
                    if (select_rotation == "90°" || select_rotation == "270°")
                    {
                        SVGdoc.Height = Size.Width;
                        SVGdoc.Width = Size.Height;
                    }
                    else
                    {
                        SVGdoc.Height = Size.Height;
                        SVGdoc.Width = Size.Width;
                    }
                    OLDheight = Convert.ToInt32(SVGdoc.OwnerDocument.ViewBox.Height);
                    OLDwidht = Convert.ToInt32(SVGdoc.OwnerDocument.ViewBox.Width);
                    using (MemoryStream stream = new MemoryStream())
                    {
                        SVGdoc.Draw().Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        imageEo = System.Drawing.Image.FromStream(stream);
                        imageWasChanged = false;
                        imageXml = System.Drawing.Image.FromStream(stream);
                    }
                    rotateImage(imageEo, select_rotation);
                }
                catch
                {
                }
            }


The purpose of the code is to generate render of the SVG (imageEo), save its original height / width so "reset to original size" works (OLDheight OLDwidht), and rotate the image for presentation on the Smath page. Also imageXml is introduced for loading files like .DWG that must be rendered manually - imageXml stores the resulting render till a new one is produced.

Any suggested changes? Editing files from within .NET is a little bit beyond of what I can do without spending hours researching online..

Edited by user 19 March 2016 20:24:46(UTC)  | Reason: Not specified

Offline Davide Carpi  
#18 Posted : 19 March 2016 21:09:48(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Code:

if (SVGdoc.OwnerDocument.ViewBox.Width == 0 || SVGdoc.OwnerDocument.ViewBox.Height == 0)
{
    SVGdoc.OwnerDocument.ViewBox = new SvgViewBox(0, 0, baseWidth, baseHeight);
    // SVGdoc.ViewBox = new SvgViewBox(0, 0, baseWidth, baseHeight);
}


The values to use for baseWidth baseHeight are in your hands (not explored).
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline RFreund  
#19 Posted : 19 March 2016 21:15:21(UTC)
RFreund


Rank: Advanced Member

Groups: Registered
Joined: 25/09/2013(UTC)
Posts: 325
United States
Location: IL

Was thanked: 19 time(s) in 17 post(s)
Alex - Do you have an example(s) of how you typically use this plugin?

Thanks!
Offline Jean Giraud  
#20 Posted : 20 March 2016 03:09:39(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
... English Tea on Persian carpet.
IMHO, forget "Editable image region"
1. Does nto support RGB
2. All pixels are valued,
3. an SVG graph must have clear background.

Jean

Users browsing this topic
6 Pages123>»
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.