├── .gitignore
├── ImageMagickCommands.xlsx
├── ImageMagickDiagram.cd
├── ImageMagickSharp.Tests
├── BaseTest.cs
├── CORE_RL_Magick++_.dll
├── CORE_RL_bzlib_.dll
├── CORE_RL_cairo_.dll
├── CORE_RL_exr_.dll
├── CORE_RL_glib_.dll
├── CORE_RL_jbig_.dll
├── CORE_RL_jp2_.dll
├── CORE_RL_jpeg_.dll
├── CORE_RL_lcms_.dll
├── CORE_RL_librsvg_.dll
├── CORE_RL_libxml_.dll
├── CORE_RL_lqr_.dll
├── CORE_RL_magick_.dll
├── CORE_RL_openjpeg_.dll
├── CORE_RL_pango_.dll
├── CORE_RL_png_.dll
├── CORE_RL_tiff_.dll
├── CORE_RL_ttf_.dll
├── CORE_RL_wand_.dll
├── CORE_RL_webp_.dll
├── CORE_RL_zlib_.dll
├── Drawing
│ └── DrawingWandTests.cs
├── Extensions
│ ├── CoverArtWandTests.cs
│ └── MediaBrowserWandTests.cs
├── Fonts
│ ├── CustomFonts.cs
│ ├── DKCrayonCrumble.ttf
│ └── WedgieRegular.ttf
├── IM_MOD_RL_bgr_.dll
├── IM_MOD_RL_bmp_.dll
├── IM_MOD_RL_clipboard_.dll
├── IM_MOD_RL_cmyk_.dll
├── IM_MOD_RL_cut_.dll
├── IM_MOD_RL_dib_.dll
├── IM_MOD_RL_emf_.dll
├── IM_MOD_RL_gif_.dll
├── IM_MOD_RL_gradient_.dll
├── IM_MOD_RL_hdr_.dll
├── IM_MOD_RL_icon_.dll
├── IM_MOD_RL_jpeg_.dll
├── IM_MOD_RL_json_.dll
├── IM_MOD_RL_magick_.dll
├── IM_MOD_RL_map_.dll
├── IM_MOD_RL_mat_.dll
├── IM_MOD_RL_miff_.dll
├── IM_MOD_RL_mono_.dll
├── IM_MOD_RL_null_.dll
├── IM_MOD_RL_pdf_.dll
├── IM_MOD_RL_png_.dll
├── IM_MOD_RL_ps2_.dll
├── IM_MOD_RL_ps3_.dll
├── IM_MOD_RL_ps_.dll
├── IM_MOD_RL_psd_.dll
├── IM_MOD_RL_raw_.dll
├── IM_MOD_RL_rgb_.dll
├── IM_MOD_RL_screenshot_.dll
├── IM_MOD_RL_tiff_.dll
├── IM_MOD_RL_txt_.dll
├── IM_MOD_RL_uyvy_.dll
├── IM_MOD_RL_wbmp_.dll
├── IM_MOD_RL_webp_.dll
├── IM_MOD_RL_xc_.dll
├── IM_MOD_RL_yuv_.dll
├── Image
│ └── ImageWandTests.cs
├── ImageMagickSharp.Tests.csproj
├── ImageMagickSharp.Tests.csproj.user
├── ImageMagickSharp.Tests.csproj.vs10x
├── Magick
│ └── MagickWandTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── ResourceImages
│ ├── MontserratLight.otf
│ ├── MontserratRegular.ttf
│ ├── backdrop.jpg
│ ├── folder1.jpg
│ ├── folder2.jpg
│ ├── folder3.jpg
│ ├── folder4.jpg
│ ├── folder5.webp
│ ├── logo.png
│ ├── robotoregular.ttf
│ └── thumb.jpg
├── Wand
│ ├── WandNativeStringTests.cs
│ └── WandTests.cs
└── backdrop.jpg
├── ImageMagickSharp.sln
├── ImageMagickSharp
├── Drawing
│ ├── DrawingWand.cs
│ └── DrawingWandInterop.cs
├── Extensions
│ ├── CoverArtWandExtension.cs
│ └── MediaBrowserWandExtension.cs
├── Global
│ ├── AlphaChannelType.cs
│ ├── ColorConstants.cs
│ ├── CompositeOperator.cs
│ ├── Constants.cs
│ ├── DistortImageMethodType.cs
│ ├── DitherMethod.cs
│ ├── FilterTypes.cs
│ ├── FontMetrics.cs
│ ├── FontStretchType.cs
│ ├── FontStyleType.cs
│ ├── FontWeightType.cs
│ ├── GravityType.cs
│ ├── ImageColorspaceType.cs
│ ├── ImageLayerType.cs
│ ├── MagickCommandType.cs
│ ├── PaintMethodType.cs
│ ├── TextAlignType.cs
│ ├── TextDecorationType.cs
│ ├── VirtualPixelType.cs
│ └── WandStruct.cs
├── Image
│ ├── ImageWand.cs
│ └── ImageWandInterop.cs
├── ImageMagickSharp.csproj
├── InteropMarshaler
│ └── Utf8Marshaler.cs
├── LICENSE.md
├── Magick
│ ├── MagickWand.cs
│ └── MagickWandInterop.cs
├── MagickCore
│ ├── MagickCore.cs
│ └── MagickCoreInterop.cs
├── Pixel
│ ├── PixelIterator.cs
│ ├── PixelIteratorInterop.cs
│ ├── PixelWand.cs
│ └── PixelWandInterop.cs
└── Wand
│ ├── Wand.cs
│ ├── WandBase.cs
│ ├── WandCore.cs
│ ├── WandException.cs
│ ├── WandInterop.cs
│ └── WandNativeString.cs
├── LICENSE
├── Nuget
└── ImageMagickSharp.nuspec
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | !*
2 |
3 | #################
4 | ## Eclipse
5 | #################
6 |
7 | *.pydevproject
8 | .project
9 | .metadata
10 | bin/
11 | tmp/
12 | *.tmp
13 | *.bak
14 | *.swp
15 | *.suo
16 | *~.nib
17 | local.properties
18 | .classpath
19 | .settings/
20 | .loadpath
21 |
22 | # External tool builders
23 | .externalToolBuilders/
24 |
25 | # Locally stored "Eclipse launch configurations"
26 | *.launch
27 |
28 | # CDT-specific
29 | .cproject
30 |
31 | # PDT-specific
32 | .buildpath
33 |
34 | #################
35 | ## Media Browser
36 | #################
37 | ProgramData*/
38 | CorePlugins*/
39 | ProgramData-Server*/
40 | ProgramData-UI*/
41 |
42 | #################
43 | ## Visual Studio
44 | #################
45 |
46 | ## Ignore Visual Studio temporary files, build results, and
47 | ## files generated by popular Visual Studio add-ons.
48 |
49 | # User-specific files
50 | *.suo
51 | *.user
52 | *.sln.docstates
53 |
54 | # Build results
55 |
56 | [Dd]ebug/
57 | [Rr]elease/
58 | build/
59 | [Bb]in/
60 | [Oo]bj/
61 |
62 | # MSTest test Results
63 | [Tt]est[Rr]esult*/
64 | [Bb]uild[Ll]og.*
65 |
66 | *_i.c
67 | *_p.c
68 | *.ilk
69 | *.meta
70 | *.obj
71 | *.pch
72 | *.pdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *.log
83 | *.vspscc
84 | *.vssscc
85 | .builds
86 | *.pidb
87 | *.log
88 | *.scc
89 | *.scc
90 | *.psess
91 | *.vsp
92 | *.vspx
93 | *.orig
94 | *.rej
95 | *.sdf
96 | *.opensdf
97 | *.ipch
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opensdf
104 | *.sdf
105 | *.cachefile
106 |
107 | # Visual Studio profiler
108 | *.psess
109 | *.vsp
110 | *.vspx
111 |
112 | # Guidance Automation Toolkit
113 | *.gpState
114 |
115 | # ReSharper is a .NET coding add-in
116 | _ReSharper*/
117 | *.[Rr]e[Ss]harper
118 |
119 | # TeamCity is a build add-in
120 | _TeamCity*
121 |
122 | # DotCover is a Code Coverage Tool
123 | *.dotCover
124 |
125 | # NCrunch
126 | *.ncrunch*
127 | .*crunch*.local.xml
128 |
129 | # Installshield output folder
130 | [Ee]xpress/
131 |
132 | # DocProject is a documentation generator add-in
133 | DocProject/buildhelp/
134 | DocProject/Help/*.HxT
135 | DocProject/Help/*.HxC
136 | DocProject/Help/*.hhc
137 | DocProject/Help/*.hhk
138 | DocProject/Help/*.hhp
139 | DocProject/Help/Html2
140 | DocProject/Help/html
141 |
142 | # Click-Once directory
143 | publish/
144 |
145 | # Publish Web Output
146 | *.Publish.xml
147 | *.pubxml
148 |
149 | # NuGet Packages Directory
150 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
151 | # packages/
152 | dlls/
153 | dllssigned/
154 |
155 | # Windows Azure Build Output
156 | csx
157 | *.build.csdef
158 |
159 | # Windows Store app package directory
160 | AppPackages/
161 |
162 | # Others
163 | sql/
164 | *.Cache
165 | ClientBin/
166 | [Ss]tyle[Cc]op.*
167 | ~$*
168 | *~
169 | *.dbmdl
170 | *.[Pp]ublish.xml
171 | *.publishsettings
172 |
173 | # RIA/Silverlight projects
174 | Generated_Code/
175 |
176 | # Backup & report files from converting an old project file to a newer
177 | # Visual Studio version. Backup files are not needed, because we have git ;-)
178 | _UpgradeReport_Files/
179 | Backup*/
180 | UpgradeLog*.XML
181 | UpgradeLog*.htm
182 |
183 | # SQL Server files
184 | App_Data/*.mdf
185 | App_Data/*.ldf
186 |
187 | #############
188 | ## Windows detritus
189 | #############
190 |
191 | # Windows image file caches
192 | Thumbs.db
193 | ehthumbs.db
194 |
195 | # Folder config file
196 | Desktop.ini
197 |
198 | # Recycle Bin used on file shares
199 | $RECYCLE.BIN/
200 |
201 | # Mac crap
202 | .DS_Store
203 |
204 |
205 | #############
206 | ## Python
207 | #############
208 |
209 | *.py[co]
210 |
211 | # Packages
212 | *.egg
213 | *.egg-info
214 | dist/
215 | build/
216 | eggs/
217 | parts/
218 | var/
219 | sdist/
220 | develop-eggs/
221 | .installed.cfg
222 |
223 | # Installer logs
224 | pip-log.txt
225 |
226 | # Unit test / coverage reports
227 | .coverage
228 | .tox
229 |
230 | #Translations
231 | *.mo
232 |
233 | #Mr Developer
234 | .mr.developer.cfg
235 | MediaBrowser.WebDashboard/dashboard-ui/.idea/
236 |
--------------------------------------------------------------------------------
/ImageMagickCommands.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickCommands.xlsx
--------------------------------------------------------------------------------
/ImageMagickDiagram.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AAAAAAAAAAAAAAAAAAAgAAAAAABAAAAAAAAAIAAAAAA=
7 | Global\Constants.cs
8 |
9 |
10 |
11 |
12 |
13 | AAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
14 | Wand\WandBase.cs
15 |
16 |
17 |
18 |
19 |
20 | AAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAA=
21 | Wand\WandException.cs
22 |
23 |
24 |
25 |
26 |
27 | AAAAgAIAACAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAA=
28 | Wand\WandNativeString.cs
29 |
30 |
31 |
32 |
33 |
34 |
35 | AAICEAAAACAAAgAAAAAAAAAAAAEAABAAAAAAgBAgAAg=
36 | Pixel\PixelWand.cs
37 |
38 |
39 |
40 |
41 |
42 |
43 | AAAAQBAAEAAABAAAAAAAAEMAAgAAAAAAAQAAQAAAAAA=
44 | Pixel\PixelWandInterop.cs
45 |
46 |
47 |
48 |
49 |
50 | AIIAAEAAACAAQAAAABBgAACAAAgACBQAAAQAAMQAABA=
51 | Magick\MagickWand.cs
52 |
53 |
54 |
55 |
56 |
57 |
58 | QAQEIACAAAAAAUAAggggAAAADhgAAAAAgAAYAAACAAA=
59 | Magick\MagickWandInterop.cs
60 |
61 |
62 |
63 |
64 |
65 | AAAAAEAABAAAAACAAAAAAEAAAAgAAAAAAAAAAAAAAAA=
66 | Image\ImageWand.cs
67 |
68 |
69 |
70 |
71 |
72 | AIACEEIgAAEAAEAAiAAQEARSECQAAwQEAQAMQAgASCA=
73 | Image\ImageWandInterop.cs
74 |
75 |
76 |
77 |
78 |
79 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
80 | Drawing\DrawingWand.cs
81 |
82 |
83 |
84 |
85 |
86 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
87 | Drawing\DrawingWandInterop.cs
88 |
89 |
90 |
91 |
92 |
93 | AQAAAAAAAAAAAEAAAAAEAAAAAAADACkAQBAABAAAAAA=
94 | Wand\Wand.cs
95 |
96 |
97 |
98 |
99 |
100 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAQAIAAAAAAA=
101 | Wand\WandInterop.cs
102 |
103 |
104 |
105 |
106 |
107 | AAAAAAAAAAAAAAAAAAAAAAACAAAAAAIAAAAAAAAAAAA=
108 | Wand\WandCore.cs
109 |
110 |
111 |
112 |
113 |
114 | QIAAiAgAIIBAgAARIAAAAgACAAIIIgEATACQAEEIQAA=
115 | Global\FilterTypes.cs
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/BaseTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 | using System.IO;
8 |
9 | namespace ImageMagickSharp.Tests
10 | {
11 | public abstract class BaseTest
12 | {
13 | #region [Public Properties]
14 |
15 | ///
16 | ///Gets or sets the test context which provides
17 | ///information about and functionality for the current test run.
18 | ///
19 | public TestContext TestContext { get; set; }
20 |
21 | #endregion
22 |
23 | #region [Protected Properties]
24 |
25 | //[AssemblyInitialize]
26 | //public static void AssemblyInit(TestContext testContext)
27 | //{
28 | // DirectoryInfo dir = new DirectoryInfo(testContext.DeploymentDirectory);
29 | // testContext.Properties["DeploymentDirectory"] = dir.Parent.Parent.FullName;
30 | //}
31 |
32 | protected string UnitTestPath { get { return this.GetType().Name; } }
33 |
34 | protected string SaveDirectory
35 | {
36 | get
37 | {
38 | //var path = Path.Combine(TestContext.TestDir, TestContext.TestName);
39 | //var path = Path.Combine("..\\..\\..\\TestResults\\Deploy " + DateTime.Now.ToString("yyyy-MM-dd hh_mm"), this.UnitTestPath, TestContext.TestName);
40 | var path = Path.Combine("..\\..\\..\\TestResults\\Deploy", this.UnitTestPath, TestContext.TestName, "ø");
41 | Directory.CreateDirectory(path);
42 | return path;
43 | }
44 | }
45 |
46 | protected string TestImageLogo
47 | {
48 | get { return CreateImageResource("logo.png"); }
49 | }
50 |
51 | protected string TestImageThumb
52 | {
53 | get { return CreateImageResource("thumb.jpg"); }
54 | }
55 |
56 | protected string TestImageBackdrop
57 | {
58 | get { return CreateImageResource("backdrop.jpg"); }
59 | }
60 |
61 | protected string TestImageFolder1
62 | {
63 | get { return CreateImageResource("folder1.jpg"); }
64 | }
65 |
66 | protected string TestImageFolder2
67 | {
68 | get { return CreateImageResource("folder2.jpg"); }
69 | }
70 |
71 | protected string TestImageFolder3
72 | {
73 | get { return CreateImageResource("folder3.jpg"); }
74 | }
75 |
76 | protected string TestImageFolder4
77 | {
78 | get { return CreateImageResource("folder4.jpg"); }
79 | }
80 | protected string TestImageFolder5
81 | {
82 | get { return CreateImageResource("folder5.webp"); }
83 | }
84 |
85 | protected string RobotoFont
86 | {
87 | get { return CreateImageResource("robotoregular.ttf"); }
88 | }
89 |
90 | protected string MontserratFont
91 | {
92 | get { return CreateImageResource("MontserratRegular.ttf"); }
93 | }
94 |
95 | protected string MontserratLightFont
96 | {
97 | get { return CreateImageResource("MontserratLight.otf"); }
98 | }
99 |
100 | private string CreateImageResource(string fileName)
101 | {
102 | var path = Path.Combine(SaveDirectory, fileName);
103 |
104 | if (!File.Exists(path))
105 | {
106 | using (var stream = GetType().Assembly.GetManifestResourceStream(string.Format("{0}.ResourceImages.{1}", GetType().Namespace, fileName)))
107 | {
108 | using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
109 | {
110 | stream.CopyTo(fs);
111 | }
112 | }
113 | }
114 | return path;
115 | }
116 |
117 | #endregion
118 |
119 | #region [Public Methods]
120 |
121 | [TestCleanup]
122 | public void TestCleanup()
123 | {
124 | //WandInitializer.DisposeEnvironment();
125 |
126 | // Ensure finalizers run to catch some memory errors early
127 | GC.Collect(2);
128 | GC.Collect(2);
129 | GC.WaitForPendingFinalizers();
130 | GC.Collect(2);
131 | GC.Collect(2);
132 | }
133 |
134 | [TestInitialize]
135 | public void TestInitialize()
136 | {
137 | Wand.SetMagickCoderModulePath("Libraries\\x86\\Coders");
138 | Wand.SetMagickConfigurePath("MagickConfig");
139 | Wand.SetMagickFontPath("Fonts");
140 | }
141 |
142 | #endregion
143 |
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_Magick++_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_Magick++_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_bzlib_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_bzlib_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_cairo_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_cairo_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_exr_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_exr_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_glib_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_glib_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_jbig_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_jbig_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_jp2_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_jp2_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_jpeg_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_jpeg_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_lcms_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_lcms_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_librsvg_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_librsvg_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_libxml_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_libxml_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_lqr_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_lqr_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_magick_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_magick_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_openjpeg_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_openjpeg_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_pango_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_pango_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_png_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_png_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_tiff_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_tiff_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_ttf_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_ttf_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_wand_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_wand_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_webp_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_webp_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/CORE_RL_zlib_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/CORE_RL_zlib_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Drawing/DrawingWandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using System.IO;
9 | using System.Diagnostics;
10 | namespace ImageMagickSharp.Tests
11 | {
12 | [TestClass()]
13 | public class DrawingWandTests : BaseTest
14 | {
15 | [TestMethod()]
16 | public void DrawingWandCustomFontTest()
17 | {
18 | //using (var wand = new MagickWand(TestImageBackdrop))
19 | using (var wand = new MagickWand(600, 200, "#ffffff"))
20 | {
21 | //wand.NewImage(400, 200, new PixelWand("white"));
22 | //wand.OpenImage(TestImageBackdrop);
23 | using (var draw = new DrawingWand())
24 | {
25 | using (PixelWand pixel = new PixelWand("red"))
26 | {
27 | draw.FillColor = pixel;
28 | draw.Font = CustomFonts.WedgieRegular;
29 | draw.FontSize = 40;
30 | draw.FontStyle = FontStyleType.NormalStyle;
31 | draw.TextAlignment = TextAlignType.LeftAlign;
32 | draw.FontWeight = FontWeightType.BoldStyle;
33 | draw.TextAntialias = true;
34 | draw.DrawAnnotation(0, 40, "Media Browser");
35 | draw.BorderColor = new PixelWand("red");
36 | //draw.Font = "Times-New-Roman";
37 | //pixel.Color = "Red";
38 | //pixel.Opacity = 0.8;
39 | //draw.FillColor = pixel;
40 | //draw.DrawAnnotation(60, 120, "Tavares");
41 | Debug.WriteLine(draw);
42 | wand.CurrentImage.DrawImage(draw);
43 | }
44 |
45 | }
46 | //Debug.WriteLine(wand.GetNumberImages());
47 | //wand.Image.TrimImage(10);
48 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
49 |
50 | }
51 | }
52 |
53 | [TestMethod()]
54 | public void DrawingWandAnnotationTest()
55 | {
56 | //using (var wand = new MagickWand(TestImageBackdrop))
57 | using (var wand = new MagickWand(400, 100, "#ffffff"))
58 | {
59 | //wand.NewImage(400, 200, new PixelWand("white"));
60 | //wand.OpenImage(TestImageBackdrop);
61 | using (var draw = new DrawingWand())
62 | {
63 | using (PixelWand pixel = new PixelWand("black"))
64 | {
65 | draw.FillColor = pixel;
66 | draw.Font = "Arial";
67 | draw.FontSize = 20;
68 | draw.FontStyle = FontStyleType.NormalStyle;
69 | draw.TextAlignment = TextAlignType.LeftAlign;
70 | draw.FontWeight = FontWeightType.BoldStyle;
71 | draw.TextAntialias = true;
72 | draw.DrawAnnotation(0, 20, "Media Browser");
73 | draw.BorderColor = new PixelWand("red");
74 | //draw.Font = "Times-New-Roman";
75 | //pixel.Color = "Red";
76 | //pixel.Opacity = 0.8;
77 | //draw.FillColor = pixel;
78 | //draw.DrawAnnotation(60, 120, "Tavares");
79 | Debug.WriteLine(draw);
80 | wand.CurrentImage.DrawImage(draw);
81 | }
82 |
83 | }
84 | //Debug.WriteLine(wand.GetNumberImages());
85 | //wand.Image.TrimImage(10);
86 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
87 |
88 | }
89 | }
90 |
91 | [TestMethod()]
92 | public void DrawingWandRectangleTest()
93 | {
94 | using (var wand = new MagickWand(TestImageBackdrop))
95 | {
96 | //wand.NewImage(400, 200, new PixelWand("white"));
97 | //wand.OpenImage(TestImageBackdrop);
98 | using (var draw = new DrawingWand())
99 | {
100 | using (PixelWand pixel = new PixelWand())
101 | {
102 |
103 | pixel.Color = "red";
104 | draw.StrokeColor = pixel;
105 | pixel.Color = "black";
106 | pixel.Opacity = 0.5;
107 | draw.FillColor = pixel;
108 | draw.DrawRectangle(0, 0, wand.CurrentImage.Width - 1, 120);
109 |
110 | pixel.Color = "transparent";
111 | draw.StrokeColor = pixel;
112 | pixel.Color = "white";
113 | draw.FillColor = pixel;
114 | draw.Font = "Verdana";
115 | draw.FontSize = 120;
116 | draw.FontStyle = FontStyleType.NormalStyle;
117 | draw.TextAlignment = TextAlignType.LeftAlign;
118 | draw.FontWeight = FontWeightType.BoldStyle;
119 | draw.TextAntialias = true;
120 | draw.DrawAnnotation(10, 100, "Media Browser");
121 |
122 |
123 |
124 |
125 | draw.FillColor = pixel;
126 | wand.CurrentImage.DrawImage(draw);
127 | }
128 |
129 | }
130 | //Debug.WriteLine(wand.GetNumberImages());
131 | //wand.Image.TrimImage(10);
132 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
133 |
134 | }
135 | }
136 |
137 | [TestMethod()]
138 | public void DrawingWandCircleTest()
139 | {
140 | using (var wand = new MagickWand(TestImageBackdrop))
141 | {
142 | //wand.NewImage(400, 200, new PixelWand("white"));
143 | //wand.OpenImage(TestImageBackdrop);
144 | using (var draw = new DrawingWand())
145 | {
146 | using (PixelWand pixel = new PixelWand())
147 | {
148 |
149 | pixel.Color = "red";
150 | draw.StrokeColor = pixel;
151 | pixel.Color = "black";
152 | pixel.Opacity = 0.3;
153 | draw.FillColor = pixel;
154 | draw.DrawCircle(400, 400, 300, 300);
155 |
156 | pixel.Color = "transparent";
157 | draw.StrokeColor = pixel;
158 | pixel.Color = "white";
159 | draw.FillColor = pixel;
160 | draw.Font = "Verdana";
161 | draw.FontSize = 120;
162 | draw.FontStyle = FontStyleType.NormalStyle;
163 | draw.TextAlignment = TextAlignType.LeftAlign;
164 | draw.FontWeight = FontWeightType.BoldStyle;
165 | draw.TextAntialias = true;
166 | draw.DrawAnnotation(10, 100, "Media Browser");
167 |
168 |
169 |
170 |
171 | draw.FillColor = pixel;
172 | wand.CurrentImage.DrawImage(draw);
173 | }
174 |
175 | }
176 | //Debug.WriteLine(wand.GetNumberImages());
177 | //wand.Image.TrimImage(10);
178 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
179 |
180 | }
181 | }
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Extensions/CoverArtWandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using ImageMagickSharp.Extensions;
8 | using Microsoft.VisualStudio.TestTools.UnitTesting;
9 | using System.IO;
10 | using System.Diagnostics;
11 | namespace ImageMagickSharp.Tests
12 | {
13 | [TestClass()]
14 | public class CoverArtWandTests : BaseTest
15 | {
16 |
17 | [TestMethod()]
18 | public void CoverArtWandRotateTests()
19 | {
20 | using (var wand = new MagickWand(this.TestImageFolder1))
21 | {
22 | wand.CurrentImage.RotateImage(new PixelWand("transparent", 1), 30);
23 | //wand.CurrentImage.TrimImage(10);
24 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
25 | }
26 | }
27 |
28 | //Todo
29 | [TestMethod()]
30 | public void CoverArtWand3DTests()
31 | {
32 | using (var wand = new MagickWand(TestImageFolder1))
33 | {
34 | var t = wand.CloneMagickWand();
35 | t.CurrentImage.ShearImage(new PixelWand(ColorHEX.None, 1), 0, 10);
36 | t.CurrentImage.ExtentImage(t.CurrentImage.Width + 50, t.CurrentImage.Height + 50, -25, -25);
37 | //RaiseImage
38 | //wand.CurrentImage.ShadeImage(true, 5, 6);
39 | //
40 | wand.CurrentImage.TrimImage(100);
41 | t.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
42 |
43 | }
44 | }
45 |
46 | [TestMethod()]
47 | public void CoverArtWandShadowTests()
48 | {
49 | using (var wand = new MagickWand(TestImageFolder1))
50 | {
51 | using (MagickWand nailclone = wand.CloneMagickWand())
52 | using (var blackPixelWand = new PixelWand(ColorName.Black))
53 | {
54 | nailclone.CurrentImage.BackgroundColor = blackPixelWand;
55 | nailclone.CurrentImage.ShadowImage(80, 5, 5, 5);
56 | nailclone.CurrentImage.CompositeImage(wand, CompositeOperator.CopyCompositeOp, 0, 0);
57 | nailclone.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
58 | }
59 | }
60 | }
61 |
62 | /*[TestMethod()]
63 | public void CoverArtWandStackTests()
64 | {
65 | using (var wand = new MagickWand(1000, 1500, "White"))
66 | {
67 | wand.CoverArtStack(60, 60, 0, 0, this.TestImageFolder1, this.TestImageFolder2, this.TestImageFolder3);
68 | wand.SaveImage(Path.Combine(SaveDirectory, "StackOutput.png"));
69 | }
70 | }*/
71 |
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Extensions/MediaBrowserWandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using System.IO;
9 | using ImageMagickSharp.Extensions;
10 | using System.Diagnostics;
11 | namespace ImageMagickSharp.Tests
12 | {
13 | [TestClass()]
14 | public class MediaBrowserWandTests : BaseTest
15 | {
16 | //Todo
17 | [TestMethod()]
18 | public void MediaBrowserCollectionImageTest()
19 | {
20 | using (var wand = new MagickWand(TestImageBackdrop))
21 | {
22 | var w = wand.CurrentImage.Width;
23 | var h = wand.CurrentImage.Height;
24 |
25 | wand.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
26 | using (var mwr = wand.CloneMagickWand())
27 | {
28 | mwr.CurrentImage.ResizeImage(w, h / 2, FilterTypes.LanczosFilter, 1);
29 | using (var mwg = new MagickWand(w, h / 2))
30 | {
31 | mwg.OpenImage(TestImageBackdrop);
32 | mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, 0);
33 | wand.AddImage(mwr);
34 | var t = wand.AppendImages(true);
35 | t.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
36 | }
37 | }
38 | }
39 |
40 | }
41 |
42 | [TestMethod()]
43 | public void MediaBrowserScaleImageTest()
44 | {
45 | using (var wand = new MagickWand(TestImageBackdrop))
46 | {
47 | var w = wand.CurrentImage.Width;
48 | var h = wand.CurrentImage.Height;
49 |
50 | using (var mwr = wand.CloneMagickWand())
51 | {
52 | var newW = 1280;
53 | var newH = 720;
54 | mwr.CurrentImage.ScaleImage(newW, newH);
55 | mwr.CurrentImage.StripImage();
56 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
57 | }
58 | }
59 |
60 | }
61 |
62 | [TestMethod()]
63 | public void MediaBrowserResizeImageTest()
64 | {
65 | using (var wand = new MagickWand(TestImageBackdrop))
66 | {
67 | var w = wand.CurrentImage.Width;
68 | var h = wand.CurrentImage.Height;
69 |
70 | using (var mwr = wand.CloneMagickWand())
71 | {
72 | var newW = 1280;
73 | var newH = 720;
74 | mwr.CurrentImage.ResizeImage(newW, newH);
75 | mwr.CurrentImage.StripImage();
76 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
77 | }
78 | }
79 |
80 | }
81 |
82 | [TestMethod()]
83 | public void MediaBrowserThumbnailImageTest()
84 | {
85 | using (var wand = new MagickWand(TestImageBackdrop))
86 | {
87 | var w = wand.CurrentImage.Width;
88 | var h = wand.CurrentImage.Height;
89 |
90 | using (var mwr = wand.CloneMagickWand())
91 | {
92 | var newW = 1280;
93 | var newH = 720;
94 | mwr.CurrentImage.MagickThumbnailImage(newW, newH, true, false);
95 | mwr.CurrentImage.StripImage();
96 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
97 | }
98 | }
99 |
100 | }
101 |
102 | [TestMethod()]
103 | public void MediaBrowserResizePerformanceImageTest()
104 | {
105 | for (var i = 0; i < 100; i++)
106 | {
107 | using (var wand = new MagickWand(TestImageBackdrop))
108 | {
109 | var w = wand.CurrentImage.Width;
110 | var h = wand.CurrentImage.Height;
111 |
112 | using (var mwr = wand.CloneMagickWand())
113 | {
114 | var newW = 1280;
115 | var newH = 720;
116 | mwr.CurrentImage.ResizeImage(newW, newH, FilterTypes.CatromFilter);
117 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
118 | }
119 | }
120 | }
121 | }
122 |
123 | [TestMethod()]
124 | public void MediaBrowserScalePerformanceImageTest()
125 | {
126 | for (var i = 0; i < 100; i++)
127 | {
128 | using (var wand = new MagickWand(TestImageBackdrop))
129 | {
130 | var w = wand.CurrentImage.Width;
131 | var h = wand.CurrentImage.Height;
132 |
133 | using (var mwr = wand.CloneMagickWand())
134 | {
135 | var newW = 1280;
136 | var newH = 720;
137 | mwr.CurrentImage.ScaleImage(newW, newH);
138 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
139 | }
140 | }
141 | }
142 | }
143 |
144 | [TestMethod()]
145 | public void MediaBrowserThumbnailPerformanceImageTest()
146 | {
147 | for (var i = 0; i < 100; i++)
148 | {
149 | using (var wand = new MagickWand(TestImageBackdrop))
150 | {
151 | var w = wand.CurrentImage.Width;
152 | var h = wand.CurrentImage.Height;
153 |
154 | using (var mwr = wand.CloneMagickWand())
155 | {
156 | var newW = 1280;
157 | var newH = 720;
158 | mwr.CurrentImage.MagickThumbnailImage(newW, newH, true, true);
159 | mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
160 | }
161 | }
162 | }
163 | }
164 |
165 | [TestMethod()]
166 | public void MediaBrowserClipMaskTest()
167 | {
168 |
169 | var dest = new MagickWand(100, 100);
170 | var mask = new MagickWand();
171 | var src = new MagickWand(100, 100);
172 |
173 | dest.OpenImage(this.TestImageFolder1);
174 | mask.OpenImage(this.TestImageFolder2);
175 | mask.CurrentImage.NegateImage(false);
176 | mask.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdropMask.png"));
177 | dest.CurrentImage.SetImageClipMask(mask);
178 | src.OpenImage(this.TestImageBackdrop);
179 | dest.CurrentImage.CompositeImage(src, CompositeOperator.OverCompositeOp, 0, 0);
180 | dest.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.png"));
181 |
182 | }
183 |
184 |
185 | [TestMethod()]
186 | public void MediaBrowserWandRoundCornersTest()
187 | {
188 | var cofactor = 15;
189 | using (var wand = new MagickWand(TestImageBackdrop).RoundCorners(cofactor))
190 | wand.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.png"));
191 |
192 | }
193 |
194 | [TestMethod()]
195 | public void MediaBrowserWandTextTests()
196 | {
197 | using (var wand = new MagickWand(TestImageBackdrop))
198 | using (var yellowPixelWand = new PixelWand("yellow"))
199 | using (var whitePixelWand = new PixelWand("white"))
200 | using (var blackPixelWand = new PixelWand("black", 0.5))
201 | {
202 |
203 | wand.CurrentImage.DrawRoundRectangle(10, 10, wand.CurrentImage.Width - 10, 70, 5, 5, yellowPixelWand, blackPixelWand);
204 |
205 | wand.CurrentImage.DrawCircle(400, 300, 500, 400, yellowPixelWand, blackPixelWand);
206 | wand.CurrentImage.DrawCircle(400, 400, 60, yellowPixelWand, blackPixelWand);
207 |
208 | wand.CurrentImage.DrawRectangle(0, wand.CurrentImage.Height - 70, wand.CurrentImage.Width - 1, wand.CurrentImage.Height, yellowPixelWand, blackPixelWand);
209 | wand.CurrentImage.DrawText("Media Browser", 10, wand.CurrentImage.Height - 10, "Arial", 60, whitePixelWand, FontWeightType.BoldStyle);
210 |
211 | wand.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.jpg"));
212 | }
213 | }
214 |
215 | [TestMethod()]
216 | public void MediaBrowserWandOverlayTests()
217 | {
218 | using (var wand = new MagickWand(TestImageBackdrop))
219 | {
220 | using (MagickWand wandComposit = new MagickWand(TestImageLogo))
221 | {
222 | //draw.FillOpacity = 0.5;
223 | wand.CurrentImage.OverlayImage(CompositeOperator.AtopCompositeOp, 560, 660, wandComposit.CurrentImage.Width, wandComposit.CurrentImage.Height, wandComposit);
224 | }
225 |
226 | wand.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.jpg"));
227 | }
228 | }
229 |
230 | [TestMethod()]
231 | public void MediaBrowserWandCropWhitespaceTests()
232 | {
233 | using (var wand = new MagickWand(TestImageLogo))
234 | {
235 | wand.CurrentImage.TrimImage(10);
236 | wand.SaveImage(Path.Combine(SaveDirectory, "TestImageBackdrop.png"));
237 | }
238 | }
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Fonts/CustomFonts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp.Tests
8 | {
9 | public class CustomFonts
10 | {
11 | public const string DKCrayonCrumble = "Fonts/DKCrayonCrumble.ttf";
12 | public const string WedgieRegular = "Fonts/WedgieRegular.ttf";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Fonts/DKCrayonCrumble.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/Fonts/DKCrayonCrumble.ttf
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Fonts/WedgieRegular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/Fonts/WedgieRegular.ttf
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_bgr_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_bgr_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_bmp_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_bmp_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_clipboard_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_clipboard_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_cmyk_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_cmyk_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_cut_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_cut_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_dib_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_dib_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_emf_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_emf_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_gif_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_gif_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_gradient_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_gradient_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_hdr_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_hdr_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_icon_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_icon_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_jpeg_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_jpeg_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_json_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_json_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_magick_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_magick_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_map_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_map_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_mat_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_mat_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_miff_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_miff_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_mono_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_mono_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_null_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_null_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_pdf_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_pdf_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_png_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_png_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_ps2_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_ps2_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_ps3_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_ps3_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_ps_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_ps_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_psd_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_psd_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_raw_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_raw_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_rgb_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_rgb_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_screenshot_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_screenshot_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_tiff_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_tiff_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_txt_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_txt_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_uyvy_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_uyvy_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_wbmp_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_wbmp_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_webp_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_webp_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_xc_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_xc_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/IM_MOD_RL_yuv_.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/IM_MOD_RL_yuv_.dll
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Image/ImageWandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using System.IO;
9 | using ImageMagickSharp.Extensions;
10 | using System.Diagnostics;
11 |
12 | namespace ImageMagickSharp.Tests
13 | {
14 | [TestClass()]
15 | public class ImageWandTests : BaseTest
16 | {
17 | [TestMethod()]
18 | public void MediaBrowserPosterCollectionImageTest()
19 | {
20 | string imageOut = "TestCollectionImages.png";
21 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
22 | {
23 | var wandReturn = MediaBrowserWandExtension.MediaBrowserPosterCollectionImage(wandImages);
24 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
25 | }
26 | }
27 |
28 | [TestMethod()]
29 | public void MediaBrowserPosterCollectionImageWithText()
30 | {
31 | string imageOut = "TestCollectionImages.png";
32 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
33 | {
34 | var wandReturn = MediaBrowserWandExtension.MediaBrowserPosterCollectionImageWithText(wandImages, "Collectionsø", MontserratLightFont);
35 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
36 | }
37 | }
38 |
39 | [TestMethod()]
40 | public void MediaBrowserSquareCollectionImageTest()
41 | {
42 | string imageOut = "TestCollectionImages.png";
43 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
44 | {
45 | var wandReturn = MediaBrowserWandExtension.MediaBrowserSquareCollectionImage(wandImages);
46 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
47 | }
48 | }
49 |
50 | [TestMethod()]
51 | public void MediaBrowserSquareCollectionImageWithTextTest()
52 | {
53 | string imageOut = "TestCollectionImages.png";
54 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
55 | {
56 | var wandReturn = MediaBrowserWandExtension.MediaBrowserSquareCollectionImageWithText(wandImages, "Collections", MontserratLightFont);
57 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
58 | }
59 | }
60 |
61 | [TestMethod()]
62 | public void MediaBrowserCollectionImageTest()
63 | {
64 | string imageOut = "TestCollectionImages.png";
65 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4, TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
66 | {
67 | var wandReturn = MediaBrowserWandExtension.MediaBrowserCollectionImage(wandImages);
68 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
69 | }
70 | }
71 |
72 | [TestMethod()]
73 | public void MediaBrowserCollectionImageWithTextTest()
74 | {
75 | string imageOut = "TestCollectionImages.png";
76 | using (var wandImages = new MagickWand(TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4, TestImageFolder1, TestImageFolder2, TestImageFolder3, TestImageFolder4))
77 | {
78 | var wandReturn = MediaBrowserWandExtension.MediaBrowserCollectionImageWithText(wandImages, "Collections", MontserratLightFont);
79 | wandReturn.SaveImage(Path.Combine(SaveDirectory, imageOut));
80 | }
81 | }
82 |
83 | [TestMethod()]
84 | public void ResizeImageTestDir()
85 | {
86 | var path = @"D:\Video\TV\Carnivàle\Season 2\Carnivàle - 2x09 - Lincoln Highway DVD.jpg";
87 |
88 | Assert.IsTrue(File.Exists(path));
89 |
90 | using (var wand = new MagickWand(path))
91 | {
92 | wand.CurrentImage.ResizeImage(400, 150);
93 |
94 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.jpg"));
95 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.png"));
96 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.webp"));
97 | }
98 | }
99 |
100 | [TestMethod()]
101 | public void ResizeImageTest()
102 | {
103 | var path = TestImageLogo;
104 |
105 | Assert.IsTrue(File.Exists(path));
106 |
107 | using (var wand = new MagickWand(path))
108 | {
109 | wand.CurrentImage.ResizeImage(400, 150);
110 |
111 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.jpg"));
112 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.png"));
113 | wand.SaveImage(Path.Combine(SaveDirectory, "TestResize.webp"));
114 | }
115 | }
116 |
117 | [TestMethod()]
118 | public void ExtendcanvasaroundimageTest()
119 | {
120 |
121 | var path = TestImageThumb;
122 |
123 | Assert.IsTrue(File.Exists(path));
124 |
125 | using (var wand = new MagickWand(path))
126 | {
127 | wand.OpenImage(path);
128 | var w = wand.CurrentImage.Width;
129 | var h = wand.CurrentImage.Height;
130 |
131 | using (PixelWand newPixelWand = new PixelWand("blue"))
132 | {
133 | wand.CurrentImage.BackgroundColor = newPixelWand;
134 | }
135 | wand.CurrentImage.ExtentImage(1024, 768, -(1024 - w) / 2, -(768 - h) / 2);
136 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg"));
137 |
138 | }
139 | }
140 |
141 | [TestMethod()]
142 | public void ImageWandCreateManyTest()
143 | {
144 |
145 | using (var wand = new MagickWand())
146 | using (var yellowPixelWand = new PixelWand("yellow"))
147 | using (var blackPixelWand = new PixelWand("black", 0.5))
148 | {
149 | wand.NewImage(200, 200, "Blue");
150 | wand.CurrentImage.DrawRoundRectangle(10, 10, wand.CurrentImage.Width - 10, 70, 5, 5, yellowPixelWand, blackPixelWand);
151 | wand.NewImage(200, 200, "red");
152 | wand.CurrentImage.DrawRoundRectangle(10, 10, wand.CurrentImage.Width - 10, 70, 5, 5, yellowPixelWand, blackPixelWand);
153 | wand.NewImage(200, 200, "green");
154 | wand.CurrentImage.DrawRoundRectangle(10, 10, wand.CurrentImage.Width - 10, 70, 5, 5, yellowPixelWand, blackPixelWand);
155 | wand.SaveImages(Path.Combine(SaveDirectory, "logo_extent.jpg"));
156 |
157 | }
158 | }
159 |
160 | [TestMethod()]
161 | public void ImageWandImageClassTest()
162 | {
163 |
164 | using (var wand = new MagickWand())
165 | using (var yellowPixelWand = new PixelWand("yellow"))
166 | using (var blackPixelWand = new PixelWand("black", 0.5))
167 | {
168 | wand.NewImage(200, 200, "Blue");
169 | wand.CurrentImage.DrawRoundRectangle(10, 10, wand.CurrentImage.Width - 10, 70, 5, 5, yellowPixelWand, blackPixelWand);
170 | var t = wand.GetImage();
171 | //wand.Image.RotateImage("red", 45);
172 | //t.RotateImage("red", 45);
173 | t.SaveImages(Path.Combine(SaveDirectory, "logo_extent.jpg"));
174 | wand.SaveImages(Path.Combine(SaveDirectory, "logo_extent.jpg"));
175 |
176 | }
177 | }
178 |
179 | //Todo
180 | /*[TestMethod()]
181 | public void ImageWandLabelImageTests()
182 | {
183 | using (var wand = new MagickWand(200, 200, "lightblue"))
184 | using (var maroonPixelWand = new PixelWand(ColorName.Maroon))
185 | {
186 | wand.BackgroundColor = maroonPixelWand;
187 |
188 | wand.Font = "Arial";
189 | Debug.Print(wand.Font);
190 | wand.Pointsize = 72;
191 | wand.CurrentImage.LabelImage("Media Browser");
192 | wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
193 |
194 | }
195 | }*/
196 |
197 | /*[TestMethod()]
198 | public void GetImagePixelColorTest()
199 | {
200 | var path = TestImageFolder1;
201 |
202 | Assert.IsTrue(File.Exists(path));
203 |
204 | using (var wand = new MagickWand(path))
205 | {
206 | var pi = wand.CurrentImage.GetImagePixelColor(1, 1);
207 | Debug.Print(pi.Color);
208 | }
209 | }*/
210 |
211 | /* //Todo
212 | [TestMethod()]
213 | public void ColorMatrixTests()
214 | {
215 | using (var wand = new MagickWand(TestImageFolder1))
216 | {
217 | double[,] m =
218 | {
219 | {0.5, 0.5, 0.5, 0, 0} ,
220 | {0.5, 1, 0.5, 0, 0 },
221 | { 0.5, 0.5,1, 0, 0 },
222 | { 0.5, 0.5, 0.5, 1, 1 } ,
223 | { 0.5, 0.5, 0.5, 1, 0 }
224 | };
225 | //wand.CurrentImage.ImageVirtualPixel = VirtualPixelType.Black;
226 | bool t = wand.CurrentImage.ColorMatrixImage(m);
227 | wand.SaveImage(Path.Combine(SaveDirectory, "ColorMatrix_Out.png"));
228 | }
229 | }
230 | */
231 | }
232 | }
233 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ImageMagickSharp.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {83CA83DF-0403-44B9-811B-02ED9B368D33}
7 | Library
8 | Properties
9 | ImageMagickSharp.Tests
10 | ImageMagickSharp.Tests
11 | v4.5
12 | 512
13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 10.0
15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
17 | False
18 | UnitTest
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | true
30 | full
31 | false
32 | bin\Debug\
33 | DEBUG;TRACE
34 | prompt
35 | 4
36 | AnyCPU
37 |
38 |
39 | pdbonly
40 | true
41 | bin\Release\
42 | TRACE
43 | prompt
44 | 4
45 |
46 |
47 | true
48 | bin\x86\Debug\
49 | DEBUG;TRACE
50 | full
51 | x86
52 | prompt
53 | MinimumRecommendedRules.ruleset
54 |
55 |
56 | bin\x86\Release\
57 | TRACE
58 | true
59 | pdbonly
60 | x86
61 | prompt
62 | MinimumRecommendedRules.ruleset
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | {f4120950-9063-4a8c-95b3-039685f34d29}
103 | ImageMagickSharp
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | PreserveNewest
120 |
121 |
122 | PreserveNewest
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | PreserveNewest
131 |
132 |
133 | PreserveNewest
134 |
135 |
136 | PreserveNewest
137 |
138 |
139 | PreserveNewest
140 |
141 |
142 | PreserveNewest
143 |
144 |
145 | PreserveNewest
146 |
147 |
148 | PreserveNewest
149 |
150 |
151 | PreserveNewest
152 |
153 |
154 | PreserveNewest
155 |
156 |
157 | PreserveNewest
158 |
159 |
160 | PreserveNewest
161 |
162 |
163 | PreserveNewest
164 |
165 |
166 | PreserveNewest
167 |
168 |
169 | PreserveNewest
170 |
171 |
172 | PreserveNewest
173 |
174 |
175 | PreserveNewest
176 |
177 |
178 | PreserveNewest
179 |
180 |
181 | PreserveNewest
182 |
183 |
184 | PreserveNewest
185 |
186 |
187 | PreserveNewest
188 |
189 |
190 | PreserveNewest
191 |
192 |
193 | PreserveNewest
194 |
195 |
196 | PreserveNewest
197 |
198 |
199 | PreserveNewest
200 |
201 |
202 | PreserveNewest
203 |
204 |
205 | PreserveNewest
206 |
207 |
208 | PreserveNewest
209 |
210 |
211 | PreserveNewest
212 |
213 |
214 | PreserveNewest
215 |
216 |
217 | PreserveNewest
218 |
219 |
220 | PreserveNewest
221 |
222 |
223 | PreserveNewest
224 |
225 |
226 | PreserveNewest
227 |
228 |
229 | PreserveNewest
230 |
231 |
232 | PreserveNewest
233 |
234 |
235 | PreserveNewest
236 |
237 |
238 | PreserveNewest
239 |
240 |
241 | PreserveNewest
242 |
243 |
244 | PreserveNewest
245 |
246 |
247 | PreserveNewest
248 |
249 |
250 | PreserveNewest
251 |
252 |
253 | PreserveNewest
254 |
255 |
256 | PreserveNewest
257 |
258 |
259 | PreserveNewest
260 |
261 |
262 | PreserveNewest
263 |
264 |
265 | PreserveNewest
266 |
267 |
268 | PreserveNewest
269 |
270 |
271 | PreserveNewest
272 |
273 |
274 | PreserveNewest
275 |
276 |
277 | PreserveNewest
278 |
279 |
280 | PreserveNewest
281 |
282 |
283 | PreserveNewest
284 |
285 |
286 | PreserveNewest
287 |
288 |
289 | PreserveNewest
290 |
291 |
292 | PreserveNewest
293 |
294 |
295 | PreserveNewest
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 | False
304 |
305 |
306 | False
307 |
308 |
309 | False
310 |
311 |
312 | False
313 |
314 |
315 |
316 |
317 |
318 |
319 |
326 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ImageMagickSharp.Tests.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ShowAllFiles
5 |
6 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ImageMagickSharp.Tests.csproj.vs10x:
--------------------------------------------------------------------------------
1 | This file contains Alternate Data Streams, storing configuration information used by CodeSMART and VS10x Extensions.
2 |
3 | PLEASE DO NOT DELETE.
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Magick/MagickWandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using System.IO;
9 | using System.Diagnostics;
10 | using System.Drawing;
11 |
12 | namespace ImageMagickSharp.Tests
13 | {
14 | [TestClass()]
15 | public class MagickWandTests : BaseTest
16 | {
17 |
18 | [TestMethod()]
19 | public void GetFontTest()
20 | {
21 | using (var wand = new MagickWand())
22 | {
23 | //wand.SetFont("Arial");
24 | //Debug.WriteLine(wand.GetFont());
25 | }
26 | }
27 |
28 | [TestMethod()]
29 | public void SetFontTest()
30 | {
31 | using (var wand = new MagickWand())
32 | {
33 | //wand.SetFont("Arial");
34 | //Debug.WriteLine(wand.GetFont());
35 | }
36 | }
37 |
38 | /*[TestMethod()]
39 | public void NewImageTest()
40 | {
41 | using (var wand = new MagickWand(100, 100, "#ffffff"))
42 | {
43 | wand.NewImage(100, 100, "#ffffff");
44 | wand.SaveImage(Path.Combine(SaveDirectory, "TestSetBackgroundColor.png"));
45 | }
46 | }*/
47 |
48 | [TestMethod()]
49 | public void NewImageTest2()
50 | {
51 | using (var wand = new MagickWand(100, 100, "#ffffff"))
52 | {
53 | //wand.NewImage(100, 100, "#ffffff");
54 |
55 | wand.SaveImage(Path.Combine(SaveDirectory, "TestSetBackgroundColor.png"));
56 | }
57 | }
58 |
59 | [TestMethod()]
60 | public void OpenImageTest()
61 | {
62 | var path = TestImageLogo;
63 |
64 | Assert.IsTrue(File.Exists(path));
65 |
66 | using (var wand = new MagickWand(path))
67 | {
68 | }
69 |
70 | using (var wand2 = new MagickWand())
71 | {
72 | Assert.IsTrue(wand2.OpenImage(path));
73 | }
74 | }
75 |
76 | [TestMethod()]
77 | public void OpenImageTestWebp()
78 | {
79 | var path = TestImageFolder5;
80 |
81 | Assert.IsTrue(File.Exists(path));
82 |
83 | using (var wand = new MagickWand(path))
84 | {
85 | wand.CurrentImage.AutoOrientImage();
86 | wand.SaveImage(Path.Combine(SaveDirectory, "test.png"));
87 | }
88 |
89 | }
90 |
91 | [TestMethod()]
92 | public void SaveImageTest()
93 | {
94 | var path = TestImageLogo;
95 |
96 | Assert.IsTrue(File.Exists(path));
97 |
98 | using (var wand = new MagickWand(path))
99 | {
100 |
101 | wand.SaveImage(Path.Combine(SaveDirectory, "test.jpg"));
102 | wand.SaveImage(Path.Combine(SaveDirectory, "test.png"));
103 | wand.SaveImage(Path.Combine(SaveDirectory, "test.webp"));
104 | }
105 | }
106 |
107 | [TestMethod()]
108 | public void SaveImageWithQualityTest()
109 | {
110 |
111 | var path = TestImageFolder3;
112 |
113 | Assert.IsTrue(File.Exists(path));
114 |
115 | using (var wand = new MagickWand(path))
116 | {
117 | wand.CurrentImage.CompressionQuality = 90;
118 | wand.SaveImage(Path.Combine(SaveDirectory, "test.jpg"));
119 |
120 | wand.CurrentImage.CompressionQuality = 90;
121 | wand.SaveImage(Path.Combine(SaveDirectory, "test.png"));
122 |
123 | wand.CurrentImage.CompressionQuality = 90;
124 | wand.SaveImage(Path.Combine(SaveDirectory, "test.webp"));
125 | }
126 | }
127 |
128 | [TestMethod()]
129 | public void SaveImagesTest()
130 | {
131 |
132 | var path = TestImageLogo;
133 |
134 | Assert.IsTrue(File.Exists(path));
135 |
136 | using (var wand = new MagickWand(path))
137 | {
138 | wand.SaveImages(Path.Combine(SaveDirectory, "logo.png"), true);
139 | }
140 | }
141 |
142 | /* [TestMethod()]
143 | public void PageSizeTest()
144 | {
145 | using (var wand = new MagickWand(100, 100, "#ffffff"))
146 | {
147 | wand.PageSize = new WandRectangle(100, 100, 0, 0);
148 | Console.WriteLine(wand.PageSize);
149 | }
150 | }
151 | */
152 |
153 | [TestMethod()]
154 | public void IteratorSetImageTest()
155 | {
156 | //Assert.Fail();
157 | }
158 |
159 | [TestMethod()]
160 | public void ImageSizeTest()
161 | {
162 | var path = TestImageLogo;
163 |
164 | Assert.IsTrue(File.Exists(path));
165 |
166 | using (var wand = new MagickWand(path))
167 | {
168 | Debug.WriteLine(wand.CurrentImage.Height);
169 | }
170 |
171 | using (var wand2 = new MagickWand())
172 | {
173 | Assert.IsTrue(wand2.OpenImage(path));
174 | }
175 | }
176 |
177 | /* [TestMethod()]
178 | public void ImageOverlayTest()
179 | {
180 | var path = TestImageLogo;
181 |
182 | Assert.IsTrue(File.Exists(path));
183 |
184 | using (var wand = new MagickWand(path))
185 | {
186 | //wand.NewImage(100, 100, "#ffffff");
187 | wand.OpenImage(TestImageThumb);
188 | Debug.WriteLine(wand.GetNumberImages());
189 | //wand.IteratorIndex = 0;
190 | wand.ResetIterator();
191 | using (var w = wand.AppendImages())
192 | {
193 | //w.SaveImage(Path.Combine(SaveDirectory, "test.png"));
194 | }
195 |
196 |
197 | wand.SaveImage(path);
198 | }
199 | }
200 | */
201 | [TestMethod()]
202 | public void ImageWandImageListTest()
203 | {
204 |
205 | using (var wand = new MagickWand(this.TestImageLogo, this.TestImageThumb, this.TestImageBackdrop, this.TestImageFolder1, this.TestImageFolder2, this.TestImageFolder3, this.TestImageFolder4))
206 | {
207 | foreach (ImageWand imageWand in wand.ImageList)
208 | {
209 | imageWand.RotateImage(new PixelWand("", 1), 45);
210 | imageWand.TrimImage(100);
211 | }
212 | wand.SaveImages(Path.Combine(SaveDirectory, "ListOutput.png"));
213 | }
214 | }
215 |
216 | /*[TestMethod()]
217 | public void ConvertImageCommandTest()
218 | {
219 | using (var wand = new MagickWand(TestImageFolder1))
220 | {
221 | using (var core = new MagickCore())
222 | {
223 | string[] args = { "convert", "-size", "100x100", "xc:red", "show:" };
224 | int args_count = 5;
225 |
226 | var image_info = core.AcquireImageInfo();
227 | var exception = core.AcquireExceptionInfo();
228 | bool status = core.ConvertImageCommand(image_info, args_count, args, null, exception);
229 | }
230 | }
231 |
232 | //using (var wand = new MagickWand(TestImageFolder1))
233 | //{
234 | // using (var core = new MagickCore())
235 | // {
236 | // string[] args = { "convert", "-size", "100x100", "xc:red", "show:" };
237 | // int args_count = 5;
238 |
239 | // var image_info = core.AcquireImageInfo();
240 | // var exception = core.AcquireExceptionInfo();
241 | // var metadate = IntPtr.Zero;
242 | // bool status = Wand.CommandGenesis(image_info, MagickCommandType.ConvertImageCommand, args_count, args, null, exception);
243 | // }
244 | //}
245 | }*/
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ImageMagickSharp.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ImageMagickSharp.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("be688e86-e1ab-4d24-87cb-eeefb846f20c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/MontserratLight.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/MontserratLight.otf
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/MontserratRegular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/MontserratRegular.ttf
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/backdrop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/backdrop.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/folder1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/folder1.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/folder2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/folder2.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/folder3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/folder3.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/folder4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/folder4.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/folder5.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/folder5.webp
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/logo.png
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/robotoregular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/robotoregular.ttf
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/ResourceImages/thumb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/ResourceImages/thumb.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Wand/WandNativeStringTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using System.Diagnostics;
9 | namespace ImageMagickSharp.Tests
10 | {
11 | [TestClass()]
12 | public class WandNativeStringTests : BaseTest
13 | {
14 | string stringTest = "WandNativeString";
15 |
16 | [TestMethod()]
17 | public void LoadTest()
18 | {
19 | string val = WandNativeString.Load(Wand.GetHandle(), false);
20 | Debug.WriteLine(val);
21 | Assert.IsNotNull(val);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/Wand/WandTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ImageMagickSharp;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | namespace ImageMagickSharp.Tests
9 | {
10 | [TestClass()]
11 | public class WandTests : BaseTest
12 | {
13 | [TestMethod()]
14 | public void QueryFormatsTest()
15 | {
16 | //Wand.QueryFonts("*");
17 | Wand.QueryFormats("*");
18 | }
19 |
20 | [TestMethod()]
21 | public void OpenEnvironmentTest()
22 | {
23 | Wand.OpenEnvironment();
24 |
25 | Assert.IsTrue(Wand.IsInitialized);
26 | }
27 |
28 | [TestMethod()]
29 | public void CloseEnvironmentTest()
30 | {
31 | Wand.CloseEnvironment();
32 |
33 | Assert.IsFalse(Wand.IsInitialized);
34 | }
35 |
36 | [TestMethod()]
37 | public void EnsureInitializedTest()
38 | {
39 | Wand.OpenEnvironment();
40 |
41 | Assert.IsTrue(Wand.IsInitialized);
42 | }
43 |
44 | [TestMethod()]
45 | public void IsMagickWandInstantiatedTest()
46 | {
47 | Wand.OpenEnvironment();
48 | Assert.IsTrue(Wand.IsWandInstantiated);
49 | Wand.CloseEnvironment();
50 | Assert.IsFalse(Wand.IsWandInstantiated);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ImageMagickSharp.Tests/backdrop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MediaBrowser/ImageMagickSharp/27aff3987068a952125154da454c351cb62a5321/ImageMagickSharp.Tests/backdrop.jpg
--------------------------------------------------------------------------------
/ImageMagickSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.3
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageMagickSharp", "ImageMagickSharp\ImageMagickSharp.csproj", "{56CA2F8E-4C17-4B2D-96FB-F404CA9BAA06}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {56CA2F8E-4C17-4B2D-96FB-F404CA9BAA06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {56CA2F8E-4C17-4B2D-96FB-F404CA9BAA06}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {56CA2F8E-4C17-4B2D-96FB-F404CA9BAA06}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {56CA2F8E-4C17-4B2D-96FB-F404CA9BAA06}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {40F1105B-B9EF-48B5-82F1-766434DBF712}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Drawing/DrawingWand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A drawing wand.
10 | ///
11 | ///
12 | public class DrawingWand : WandCore, IDisposable
13 | {
14 | #region [Constructors]
15 | ///
16 | /// Initializes a new instance of the ImageMagickSharp.DrawingWand<T> class.
17 | /// Thrown when an exception error condition occurs.
18 | public DrawingWand()
19 | {
20 | this.Handle = DrawingWandInterop.NewDrawingWand();
21 | if (this.Handle == IntPtr.Zero)
22 | {
23 | throw new Exception("Error acquiring wand.");
24 | }
25 | }
26 |
27 | /// Initializes a new instance of the ImageMagickSharp.DrawingWand class.
28 | /// Thrown when an exception error condition occurs.
29 | /// The fill color.
30 | internal DrawingWand(PixelWand fillColor)
31 | {
32 | this.Handle = DrawingWandInterop.NewDrawingWand();
33 | if (this.Handle == IntPtr.Zero)
34 | {
35 | throw new Exception("Error acquiring wand.");
36 | }
37 | this.FillColor = fillColor;
38 | }
39 |
40 | /// Initializes a new instance of the DrawingWand class.
41 | /// .
42 | private DrawingWand(IntPtr handle)
43 | : base(handle)
44 | {
45 |
46 | }
47 |
48 | #endregion
49 |
50 | #region [Drawing Wand]
51 |
52 | /// Clears the pixel wand.
53 | /*private void ClearPixelWand()
54 | {
55 | DrawingWandInterop.ClearDrawingWand(this);
56 | }
57 |
58 | /// Clone drawing wand.
59 | /// A DrawingWand.
60 | private DrawingWand CloneDrawingWand()
61 | {
62 | return new DrawingWand(DrawingWandInterop.CloneDrawingWand(this));
63 | }
64 |
65 | /// Destroys the drawing wand.
66 | private void DestroyDrawingWand()
67 | {
68 | DrawingWandInterop.DestroyDrawingWand(this);
69 | }
70 |
71 | /// Resets the vector graphics.
72 | private void ResetVectorGraphics()
73 | {
74 | DrawingWandInterop.DrawResetVectorGraphics(this);
75 | }*/
76 |
77 | #endregion
78 |
79 | #region [Drawing Wand Methods]
80 | /// Gets or sets the gravity.
81 | /// The gravity.
82 | public GravityType Gravity
83 | {
84 | get { return DrawingWandInterop.DrawGetGravity(this); }
85 | set { DrawingWandInterop.DrawSetGravity(this, value); }
86 | }
87 |
88 | /// Gets or sets a value indicating whether the stroke antialias.
89 | /// true if stroke antialias, false if not.
90 | /*private bool StrokeAntialias
91 | {
92 | get { return DrawingWandInterop.DrawGetStrokeAntialias(this); }
93 | set { DrawingWandInterop.DrawSetStrokeAntialias(this, value); }
94 | }
95 |
96 | /// Gets or sets the fill opacity.
97 | /// The fill opacity.
98 | private double FillOpacity
99 | {
100 | get { return DrawingWandInterop.DrawGetFillOpacity(this); }
101 | set { DrawingWandInterop.DrawSetFillOpacity(this, value); }
102 | }
103 |
104 | /// Gets or sets the opacity.
105 | /// The opacity.
106 | private double Opacity
107 | {
108 | get { return DrawingWandInterop.DrawGetOpacity(this); }
109 | set { DrawingWandInterop.DrawSetOpacity(this, value); }
110 | }
111 |
112 | /// Gets or sets the vector graphics.
113 | /// The vector graphics.
114 | private string VectorGraphics
115 | {
116 | get { return DrawingWandInterop.DrawGetVectorGraphics(this); }
117 | set { DrawingWandInterop.DrawSetVectorGraphics(this, value); }
118 | }*/
119 |
120 | /// Draw composite.
121 | /// The compose.
122 | /// The x coordinate.
123 | /// The y coordinate.
124 | /// The width.
125 | /// The height.
126 | /// The magickwand.
127 | /// true if it succeeds, false if it fails.
128 | internal bool DrawComposite(CompositeOperator compose, double x, double y, double width, double height, ImageWand imageWand)
129 | {
130 | return this.CheckErrorBool(DrawingWandInterop.DrawComposite(this, compose, x, y, width, height, imageWand.MagickWand.Handle));
131 | }
132 |
133 | /// Draw matte.
134 | /// The x coordinate.
135 | /// The y coordinate.
136 | /// The paint method.
137 | /*private void DrawMatte(double x, double y, PaintMethodType paint_method)
138 | {
139 | DrawingWandInterop.DrawMatte(this, x, y, paint_method);
140 | }
141 |
142 | /// Skew x coordinate.
143 | /// The degrees.
144 | private void SkewX(double degrees)
145 | {
146 | DrawingWandInterop.DrawSkewX(this, degrees);
147 | }
148 |
149 | /// Skew y coordinate.
150 | /// The degrees.
151 | private void SkewY(double degrees)
152 | {
153 | DrawingWandInterop.DrawSkewY(this, degrees);
154 | }
155 |
156 | /// Translates.
157 | /// The x coordinate.
158 | /// The y coordinate.
159 | private void Translate(double x, double y)
160 | {
161 | DrawingWandInterop.DrawTranslate(this, x, y);
162 | }
163 |
164 | /// Scales.
165 | /// The x coordinate.
166 | /// The y coordinate.
167 | private void Scale(double x, double y)
168 | {
169 | DrawingWandInterop.DrawScale(this, x, y);
170 | }
171 |
172 | /// Rotates.
173 | /// The degrees.
174 | private void Rotate(double degrees)
175 | {
176 | DrawingWandInterop.DrawRotate(this, degrees);
177 | }*/
178 |
179 | #endregion
180 |
181 | #region [Drawing Wand Methods - Text]
182 | /// Gets or sets the font.
183 | /// The font.
184 | public string Font
185 | {
186 | get { return WandNativeString.Load(DrawingWandInterop.DrawGetFont(this)); }
187 | set { DrawingWandInterop.DrawSetFont(this, value); }
188 | }
189 |
190 | /// Gets or sets the font family.
191 | /// The font family.
192 | /*private string FontFamily
193 | {
194 | get { return DrawingWandInterop.DrawGetFontFamily(this); }
195 | set { DrawingWandInterop.DrawSetFontFamily(this, value); }
196 | }*/
197 |
198 | /// Gets or sets the size of the font.
199 | /// The size of the font.
200 | public double FontSize
201 | {
202 | get { return DrawingWandInterop.DrawGetFontSize(this); }
203 | set { DrawingWandInterop.DrawSetFontSize(this, value); }
204 | }
205 |
206 | /// Gets or sets the font stretch.
207 | /// The font stretch.
208 | /*private FontStretchType FontStretch
209 | {
210 | get { return (FontStretchType)DrawingWandInterop.DrawGetFontStretch(this); }
211 | set { DrawingWandInterop.DrawSetFontStretch(this, (int)value); }
212 | }*/
213 |
214 | /// Gets or sets the font style.
215 | /// The font style.
216 | public FontStyleType FontStyle
217 | {
218 | get { return DrawingWandInterop.DrawGetFontStyle(this); }
219 | set { DrawingWandInterop.DrawSetFontStyle(this, value); }
220 | }
221 |
222 | /// Gets or sets the font weight.
223 | /// The font weight.
224 | public FontWeightType FontWeight
225 | {
226 | get { return DrawingWandInterop.DrawGetFontWeight(this); }
227 | set { DrawingWandInterop.DrawSetFontWeight(this, value); }
228 | }
229 |
230 | /// Gets or sets a value indicating whether the text antialias.
231 | /// true if text antialias, false if not.
232 | public bool TextAntialias
233 | {
234 | get { return DrawingWandInterop.DrawGetTextAntialias(this); }
235 | set { DrawingWandInterop.DrawSetTextAntialias(this, value); }
236 | }
237 |
238 | /// Gets or sets the text alignment.
239 | /// The text alignment.
240 | public TextAlignType TextAlignment
241 | {
242 | /* This doesn't work
243 | get { return DrawingWandInterop.DrawGetTextAlignment(this); }
244 | */
245 | set { DrawingWandInterop.DrawSetTextAlignment(this, value); }
246 | }
247 |
248 | /// Gets or sets the font resolution.
249 | /// The font resolution.
250 | public WandPointD FontResolution
251 | {
252 | get
253 | {
254 | double x;
255 | double y;
256 | DrawingWandInterop.DrawGetFontResolution(this, out x, out y);
257 | return new WandPointD(x, y);
258 | }
259 | set
260 | {
261 | CheckError(DrawingWandInterop.DrawSetFontResolution(this, value.X, value.Y));
262 | }
263 | }
264 |
265 | /// Draw annotation.
266 | /// The x coordinate.
267 | /// The y coordinate.
268 | /// The text.
269 | public void DrawAnnotation(double x, double y, string text)
270 | {
271 | DrawingWandInterop.DrawAnnotation(this, x, y, text);
272 | }
273 |
274 | #endregion
275 |
276 | #region [Drawing Wand Methods - Colors]
277 | /// Gets or sets the color of the fill.
278 | /// The color of the fill.
279 | public PixelWand FillColor
280 | {
281 | /* This doesn't work
282 | * get
283 | {
284 | IntPtr color;
285 | DrawingWandInterop.DrawGetFillColor(this, out color);
286 | return new PixelWand(color);
287 | }*/
288 | set { DrawingWandInterop.DrawSetFillColor(this, value); }
289 | }
290 |
291 | /// Gets or sets the color of the border.
292 | /// The color of the border.
293 | internal PixelWand BorderColor
294 | {
295 | /* NOT WORKINGget
296 | {
297 | IntPtr background;
298 | DrawingWandInterop.DrawGetBorderColor(this, out background);
299 | return new PixelWand(background);
300 | }*/
301 | set { DrawingWandInterop.DrawSetBorderColor(this, value); }
302 | }
303 |
304 | /// Gets or sets the color of the stroke.
305 | /// The color of the stroke.
306 |
307 | internal PixelWand StrokeColor
308 | {
309 | /*NOT WORKING
310 | * get
311 | {
312 | IntPtr background;
313 | DrawingWandInterop.DrawGetStrokeColor(this, out background);
314 | return new PixelWand(background);
315 | }*/
316 | set { DrawingWandInterop.DrawSetStrokeColor(this, value); }
317 | }
318 |
319 | /// Gets or sets the stroke opacity.
320 | /// The stroke opacity.
321 | /*private double StrokeOpacity
322 | {
323 | get { return DrawingWandInterop.DrawGetStrokeOpacity(this); }
324 | set { DrawingWandInterop.DrawSetStrokeOpacity(this, value); }
325 | }
326 |
327 | /// Gets or sets the width of the stroke.
328 | /// The width of the stroke.
329 | private double StrokeWidth
330 | {
331 | get { return DrawingWandInterop.DrawGetStrokeWidth(this); }
332 | set { DrawingWandInterop.DrawSetStrokeWidth(this, value); }
333 | }*/
334 |
335 | /// Gets or sets the color of the text under.
336 | /// The color of the text under.
337 | /*private PixelWand TextUnderColor
338 | {
339 | /* NOT WORKINGget
340 | {
341 | IntPtr background;
342 | DrawingWandInterop.DrawGetTextUnderColor(this, out background);
343 | return new PixelWand(background);
344 | }*/
345 | /*set { DrawingWandInterop.DrawSetTextUnderColor(this, value); }
346 | }
347 |
348 | /// Draw color.
349 | /// The x coordinate.
350 | /// The y coordinate.
351 | /// The paintmethod.
352 | private void DrawColor(double x, double y, PaintMethodType paintmethod)
353 | {
354 | DrawingWandInterop.DrawColor(this, x, y, paintmethod);
355 | }*/
356 |
357 | #endregion
358 |
359 | #region [Drawing Wand Methods - Geometry]
360 | /// Draw rectangle.
361 | /// The first x value.
362 | /// The first y value.
363 | /// The second x value.
364 | /// The second y value.
365 | public void DrawRectangle(double x1, double y1, double x2, double y2)
366 | {
367 | DrawingWandInterop.DrawRectangle(this, x1, y1, x2, y2);
368 | }
369 |
370 | /// Draw round rectangle.
371 | /// The first x value.
372 | /// The first y value.
373 | /// The second x value.
374 | /// The second y value.
375 | /// The radius of corner in horizontal direction.
376 | /// The radius of corner in vertical direction.
377 | internal void DrawRoundRectangle(double x1, double y1, double x2, double y2, double rx, double ry)
378 | {
379 | DrawingWandInterop.DrawRoundRectangle(this, x1, y1, x2, y2, rx, ry);
380 | }
381 |
382 | /// Draw circle.
383 | /// The origin x ordinate.
384 | /// The origin y ordinate.
385 | /// The perimeter x ordinate.
386 | /// The perimeter y ordinate.
387 | public void DrawCircle(double ox, double oy, double px, double py)
388 | {
389 | DrawingWandInterop.DrawCircle(this, ox, oy, px, py);
390 | }
391 |
392 | /// Draw ellipse.
393 | /// The origin x ordinate.
394 | /// The origin y ordinate.
395 | /// The radius of corner in horizontal direction.
396 | /// The radius of corner in vertical direction.
397 | /// starting rotation in degrees.
398 | /// ending rotation in degrees.
399 | /*private void DrawEllipse(double ox, double oy, double rx, double ry, double start, double end)
400 | {
401 | DrawingWandInterop.DrawEllipse(this, ox, oy, rx, ry, start, end);
402 | }
403 |
404 | /// Draw arc.
405 | /// The starting x ordinate of bounding rectangle.
406 | /// The starting y ordinate of bounding rectangle.
407 | /// The ending x ordinate of bounding rectangle.
408 | /// The ending y ordinate of bounding rectangle.
409 | /// The starting degrees of rotation.
410 | /// The ending degrees of rotation.
411 | private void DrawArc(double sx, double sy, double ex, double ey, double sd, double ed)
412 | {
413 | DrawingWandInterop.DrawArc(this, sx, sy, ex, ey, sd, ed);
414 | }
415 |
416 | /// Draw line.
417 | /// The starting x ordinate of bounding rectangle.
418 | /// The starting y ordinate of bounding rectangle.
419 | /// The ending x ordinate of bounding rectangle.
420 | /// The ending y ordinate of bounding rectangle.
421 | private void DrawLine(double sx, double sy, double ex, double ey)
422 | {
423 | DrawingWandInterop.DrawLine(this, sx, sy, ex, ey);
424 | }
425 |
426 | /// Draw affine.
427 | /// The affine.
428 | private void DrawAffine(double[] affine)
429 | {
430 | DrawingWandInterop.DrawAffine(this, affine);
431 | }*/
432 | #endregion
433 |
434 | #region [Wand Methods - Exception]
435 | /// Gets the exception.
436 | /// The exception severity.
437 | /// The exception.
438 | public override IntPtr GetException(out int exceptionSeverity)
439 | {
440 | IntPtr exceptionPtr = DrawingWandInterop.DrawGetException(this, out exceptionSeverity);
441 | return exceptionPtr;
442 | }
443 |
444 | /// Clears the exception.
445 | public override void ClearException()
446 | {
447 | DrawingWandInterop.DrawClearException(this);
448 | }
449 |
450 | #endregion
451 |
452 | #region [IDisposable]
453 | /// Finalizes an instance of the ImageMagickSharp.DrawingWand class.
454 | ~DrawingWand()
455 | {
456 | this.Dispose(false);
457 | }
458 |
459 | ///
460 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
461 | /// resources.
462 | ///
463 | public void Dispose()
464 | {
465 | Dispose(true);
466 | GC.SuppressFinalize(this);
467 | }
468 |
469 | ///
470 | /// Releases the unmanaged resources used by the ImageMagickSharp.PixelWand and optionally
471 | /// releases the managed resources.
472 | /// true to release both managed and unmanaged resources; false to
473 | /// release only unmanaged resources.
474 | protected virtual void Dispose(bool disposing)
475 | {
476 | if (this.Handle != IntPtr.Zero)
477 | {
478 | DrawingWandInterop.DestroyDrawingWand(this);
479 | this.Handle = IntPtr.Zero;
480 | }
481 | }
482 |
483 | #endregion
484 | }
485 | }
486 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Extensions/CoverArtWandExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp.Extensions
8 | {
9 | internal static class CoverArtWandExtension
10 | {
11 | /// A MagickWand extension method that cover art stack.
12 | /// The wand.
13 | /// Amount to increment by.
14 | /// Amount to increment by.
15 | /// The width.
16 | /// The height.
17 | /// A variable-length parameters list containing images.
18 | private static void CoverArtStack(this MagickWand wand, double xIncrement, double yIncrement, double width, double height, params string[] images)
19 | {
20 | using (var draw = new DrawingWand())
21 | {
22 | double x = 0;
23 | double y = 0;
24 | using (var wandimages = new MagickWand(images))
25 | {
26 | foreach (ImageWand imageWand in wandimages.ImageList)
27 | {
28 | using (var blackPixelWand = new PixelWand("black"))
29 | {
30 | imageWand.BorderImage(blackPixelWand, 2, 2);
31 | draw.DrawComposite(CompositeOperator.AtopCompositeOp, x, y, width, height, imageWand);
32 | x += xIncrement;
33 | y += yIncrement;
34 | }
35 | }
36 | }
37 | wand.CurrentImage.DrawImage(draw);
38 | }
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/AlphaChannelType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | public enum AlphaChannelType : int
7 | {
8 | ActivateAlphaChannel,
9 | DeactivateAlphaChannel,
10 | OpaqueAlphaChannel,
11 | SetAlphaChannel
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/CompositeOperator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ImageMagickSharp
7 | {
8 | public enum CompositeOperator : int
9 | {
10 | UndefinedCompositeOp,
11 | NoCompositeOp,
12 | ModulusAddCompositeOp,
13 | AtopCompositeOp,
14 | BlendCompositeOp,
15 | BumpmapCompositeOp,
16 | ChangeMaskCompositeOp,
17 | ClearCompositeOp,
18 | ColorBurnCompositeOp,
19 | ColorDodgeCompositeOp,
20 | ColorizeCompositeOp,
21 | CopyBlackCompositeOp,
22 | CopyBlueCompositeOp,
23 | CopyCompositeOp,
24 | CopyCyanCompositeOp,
25 | CopyGreenCompositeOp,
26 | CopyMagentaCompositeOp,
27 | CopyOpacityCompositeOp,
28 | CopyRedCompositeOp,
29 | CopyYellowCompositeOp,
30 | DarkenCompositeOp,
31 | DstAtopCompositeOp,
32 | DstCompositeOp,
33 | DstInCompositeOp,
34 | DstOutCompositeOp,
35 | DstOverCompositeOp,
36 | DifferenceCompositeOp,
37 | DisplaceCompositeOp,
38 | DissolveCompositeOp,
39 | ExclusionCompositeOp,
40 | HardLightCompositeOp,
41 | HueCompositeOp,
42 | InCompositeOp,
43 | LightenCompositeOp,
44 | LinearLightCompositeOp,
45 | LuminizeCompositeOp,
46 | MinusDstCompositeOp,
47 | ModulateCompositeOp,
48 | MultiplyCompositeOp,
49 | OutCompositeOp,
50 | OverCompositeOp,
51 | OverlayCompositeOp,
52 | PlusCompositeOp,
53 | ReplaceCompositeOp,
54 | SaturateCompositeOp,
55 | ScreenCompositeOp,
56 | SoftLightCompositeOp,
57 | SrcAtopCompositeOp,
58 | SrcCompositeOp,
59 | SrcInCompositeOp,
60 | SrcOutCompositeOp,
61 | SrcOverCompositeOp,
62 | ModulusSubtractCompositeOp,
63 | ThresholdCompositeOp,
64 | XorCompositeOp,
65 | /* These are new operators, added after the above was last sorted.
66 | * The list should be re-sorted only when a new library version is
67 | * created.
68 | */
69 | DivideDstCompositeOp,
70 | DistortCompositeOp,
71 | BlurCompositeOp,
72 | PegtopLightCompositeOp,
73 | VividLightCompositeOp,
74 | PinLightCompositeOp,
75 | LinearDodgeCompositeOp,
76 | LinearBurnCompositeOp,
77 | MathematicsCompositeOp,
78 | DivideSrcCompositeOp,
79 | MinusSrcCompositeOp,
80 | DarkenIntensityCompositeOp,
81 | LightenIntensityCompositeOp
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp
9 | {
10 | internal class Constants
11 | {
12 |
13 | #region [Constants]
14 |
15 |
16 | /// The wand calling convention.
17 | internal const CallingConvention WandCallingConvention = CallingConvention.Cdecl;
18 |
19 | /// The wand library.
20 | internal const string WandLibrary = @"CORE_RL_Wand_";
21 |
22 | /// The magick false.
23 | internal const int MagickFalse = 0;
24 |
25 | #endregion
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/DistortImageMethodType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | public enum DistortImageMethodType : int
5 | {
6 | UndefinedDistortion,
7 | AffineDistortion,
8 | AffineProjectionDistortion,
9 | ScaleRotateTranslateDistortion,
10 | PerspectiveDistortion,
11 | PerspectiveProjectionDistortion,
12 | BilinearForwardDistortion,
13 | BilinearDistortion,
14 | BilinearReverseDistortion,
15 | PolynomialDistortion,
16 | ArcDistortion,
17 | PolarDistortion,
18 | DePolarDistortion,
19 | Cylinder2PlaneDistortion,
20 | Plane2CylinderDistortion,
21 | BarrelDistortion,
22 | BarrelInverseDistortion,
23 | ShepardsDistortion,
24 | ResizeDistortion,
25 | SentinelDistortion
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/DitherMethod.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | internal enum ImageMagickSharp
7 | {
8 | UndefinedColorspace,
9 | NoDitherMethod,
10 | RiemersmaDitherMethod,
11 | FloydSteinbertDitherMethod
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/FilterTypes.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | public enum FilterTypes : int
5 | {
6 | UndefinedFilter = 0,
7 | PointFilter,
8 | BoxFilter,
9 | TriangleFilter,
10 | HermiteFilter,
11 | HannFilter,
12 | HammingFilter,
13 | BlackmanFilter,
14 | GaussianFilter,
15 | QuadraticFilter,
16 | CubicFilter,
17 | CatromFilter,
18 | MitchellFilter,
19 | JincFilter,
20 | SincFilter,
21 | SincFastFilter,
22 | KaiserFilter,
23 | WelchFilter,
24 | ParzenFilter,
25 | BohmanFilter,
26 | BartlettFilter,
27 | LagrangeFilter,
28 | LanczosFilter,
29 | LanczosSharpFilter,
30 | Lanczos2Filter,
31 | Lanczos2SharpFilter,
32 | RobidouxFilter,
33 | RobidouxSharpFilter,
34 | CosineFilter,
35 | SplineFilter,
36 | LanczosRadiusFilter
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/FontMetrics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A font metrics.
10 | public class FontMetrics
11 | {
12 | #region [Constructors]
13 | /// Initializes a new instance of the ImageMagickSharp.FontMetrics class.
14 | /// The matrix.
15 | internal FontMetrics(double[] matrix)
16 | {
17 | CharacterWidth = matrix[0];
18 | CharacterHeight = matrix[1];
19 | Ascender = matrix[2];
20 | Descender = matrix[3];
21 | TextWidth = matrix[4];
22 | TextHeight = matrix[5];
23 | HorizontalAdvance = matrix[6];
24 | BoundingBoxX1 = matrix[7];
25 | BoundingBoxY2 = matrix[8];
26 | BoundingBoxX1 = matrix[9];
27 | BoundingBoxY2 = matrix[10];
28 | OriginX = matrix[11];
29 | OriginY = matrix[12];
30 | }
31 |
32 | /// Initializes a new instance of the ImageMagickSharp.FontMetrics class.
33 | private FontMetrics()
34 | {
35 | }
36 |
37 | #endregion
38 |
39 | #region [Properties]
40 |
41 | /// Gets or sets the width of the character.
42 | /// The width of the character.
43 | private double CharacterWidth { get; set; }
44 |
45 | /// Gets or sets the height of the character.
46 | /// The height of the character.
47 | private double CharacterHeight { get; set; }
48 |
49 | /// Gets or sets the ascender.
50 | /// The ascender.
51 | private double Ascender { get; set; }
52 |
53 | /// Gets or sets the descender.
54 | /// The descender.
55 | private double Descender { get; set; }
56 |
57 | /// Gets or sets the width of the text.
58 | /// The width of the text.
59 | public double TextWidth { get; set; }
60 |
61 | /// Gets or sets the height of the text.
62 | /// The height of the text.
63 | private double TextHeight { get; set; }
64 |
65 | /// Gets or sets the horizontal advance.
66 | /// The horizontal advance.
67 | private double HorizontalAdvance { get; set; }
68 |
69 | /// Gets or sets the bounding box x coordinate 1.
70 | /// The bounding box x coordinate 1.
71 | private double BoundingBoxX1 { get; set; }
72 |
73 | /// Gets or sets the bounding box y coordinate 1.
74 | /// The bounding box y coordinate 1.
75 | private double BoundingBoxY1 { get; set; }
76 |
77 | /// Gets or sets the bounding box x coordinate 2.
78 | /// The bounding box x coordinate 2.
79 | private double BoundingBoxX2 { get; set; }
80 |
81 | /// Gets or sets the bounding box y coordinate 2.
82 | /// The bounding box y coordinate 2.
83 | private double BoundingBoxY2 { get; set; }
84 |
85 | /// Gets or sets the origin x coordinate.
86 | /// The origin x coordinate.
87 | private double OriginX { get; set; }
88 |
89 | /// Gets or sets the origin y coordinate.
90 | /// The origin y coordinate.
91 | private double OriginY { get; set; }
92 |
93 | #endregion
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/FontStretchType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | internal enum FontStretchType : int
7 | {
8 | NormalStretch = 100,
9 | UltraCondensedStretch = 50,
10 | CondensedStretch = 75,
11 | SemiCondensedStretch = 87,
12 | SemiExpandedStretch = 113,
13 | ExpandedStretch = 150,
14 | ExtraExpandedStretch = 150,
15 | UltraExpandedStretch = 200,
16 | AnyStretch
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/FontStyleType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | public enum FontStyleType:int
7 | {
8 | NormalStyle,
9 | ItalicStyle,
10 | ObliqueStyle,
11 | AnyStyle
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/FontWeightType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | public enum FontWeightType : int
7 | {
8 | ThinStyle = 0,
9 | ExtraLightStyle = 40,
10 | UltraLightStyle = ExtraLightStyle,
11 | LightStyle = 50,
12 | BookStyle = 75,
13 | RegularStyle = 80,
14 | NormalStyle = RegularStyle,
15 | MediumStyle = 100,
16 | DemiBoldStyle = 180,
17 | SemiBoldStyle = DemiBoldStyle,
18 | BoldStyle = 200,
19 | ExtraBoldStyle = 205,
20 | UltraBoldStyle = ExtraBoldStyle,
21 | BlackStyle = 210,
22 | HeavyStyle = BlackStyle
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/GravityType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | public enum GravityType : int
5 | {
6 | NorthWestGravity,
7 | NorthGravity,
8 | NorthEastGravity,
9 | WestGravity,
10 | CenterGravity,
11 | EastGravity,
12 | SouthWestGravity,
13 | SouthGravity,
14 | SouthEastGravity
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/ImageColorspaceType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | internal enum ImageColorspaceType : int
5 | {
6 | UndefinedColorspace,
7 | sRGBColorspace,
8 | RGBColorspace,
9 | GRAYColorspace,
10 | OHTAColorspace,
11 | XYZColorspace,
12 | YCbCrColorspace,
13 | YCCColorspace,
14 | YIQColorspace,
15 | YPbPrColorspace,
16 | YUVColorspace,
17 | CMYKColorspace,
18 | HSLColorspace,
19 | HWBColorspace
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/ImageLayerType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | internal enum ImageLayerType
7 | {
8 | MergeLayer,
9 | FlattenLayer,
10 | MosaicLayer
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/MagickCommandType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | internal enum MagickCommandType : int
5 | {
6 | ConvertImageCommand,
7 | IdentifyImageCommand,
8 | MogrifyImageCommand,
9 | CompositeImageCommand,
10 | CompareImageCommand,
11 | ConjureImageCommand,
12 | StreamImageCommand,
13 | ImportImageCommand,
14 | DisplayImageCommand,
15 | AnimateImageCommand
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/PaintMethodType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | internal enum PaintMethodType
7 | {
8 | PointMethod,
9 | ReplaceMethod,
10 | FloodfillMethod,
11 | ResetMethod
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/TextAlignType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | public enum TextAlignType: int
5 | {
6 | UndefinedAlign,
7 | LeftAlign,
8 | CenterAlign,
9 | RightAlign
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/TextDecorationType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace ImageMagickSharp
3 | {
4 | internal enum TextDecorationType : int
5 | {
6 | UndefinedDecoration,
7 | NoDecoration,
8 | UnderlineDecoration,
9 | OverlineDecoration,
10 | LineThroughDecoration
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/VirtualPixelType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | public enum VirtualPixelType : int
7 | {
8 | Undefined = 0,
9 | Background = 1,
10 | Constant = 2, /* deprecated */
11 | Dither = 3,
12 | Edge = 4,
13 | Mirror = 5,
14 | Random = 6,
15 | Tile = 7,
16 | Transparent =8 ,
17 | Mask = 9,
18 | Black = 10,
19 | Gray = 11,
20 | White = 12,
21 | HorizontalTile =13 ,
22 | VerticalTile = 14,
23 | HorizontalTileEdge = 15,
24 | VerticalTileEdge = 16,
25 | CheckerTile = 17
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Global/WandStruct.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A wand size.
10 | internal struct WandSize
11 | {
12 | #region [Constructors]
13 |
14 | ///
15 | /// Initializes a new instance of the WandSize structure.
16 | ///
17 | ///
18 | ///
19 | internal WandSize(int width, int height)
20 | : this()
21 | {
22 | Width = width;
23 | Height = height;
24 | }
25 |
26 | #endregion
27 |
28 | #region [private Properties]
29 | /// Gets or sets the width.
30 | /// The width.
31 | internal int Width { get; set; }
32 |
33 | /// Gets or sets the height.
34 | /// The height.
35 | internal int Height { get; set; }
36 |
37 | #endregion
38 |
39 | }
40 |
41 | /// A wand size double.
42 | internal struct WandSizeD
43 | {
44 | #region [Constructors]
45 | ///
46 | /// Initializes a new instance of the WandSizeD structure.
47 | ///
48 | ///
49 | ///
50 | private WandSizeD(double width, double height)
51 | : this()
52 | {
53 | Width = width;
54 | Height = height;
55 | }
56 |
57 | #endregion
58 |
59 | #region [private Properties]
60 | /// Gets or sets the width.
61 | /// The width.
62 | private double Width { get; set; }
63 |
64 | /// Gets or sets the height.
65 | /// The height.
66 | private double Height { get; set; }
67 |
68 | #endregion
69 |
70 | }
71 |
72 | /// A wand point.
73 | internal struct WandPoint
74 | {
75 | #region [Constructors]
76 |
77 | /// Initializes a new instance of the WandPoint structure.
78 | /// The x coordinate.
79 | /// The y coordinate.
80 | private WandPoint(int x, int y)
81 | : this()
82 | {
83 | X = x;
84 | Y = y;
85 | }
86 |
87 | #endregion
88 |
89 | #region [Properties]
90 | /// Gets or sets the x coordinate.
91 | /// The x coordinate.
92 | private int X { get; set; }
93 |
94 | /// Gets or sets the y coordinate.
95 | /// The y coordinate.
96 | private int Y { get; set; }
97 |
98 | #endregion
99 |
100 | }
101 |
102 | /// A wand point double.
103 | public struct WandPointD
104 | {
105 | #region [Constructors]
106 |
107 | ///
108 | /// Initializes a new instance of the ImageMagickSharp.Global.WandPointD struct.
109 | /// The x coordinate.
110 | /// The y coordinate.
111 | public WandPointD(double x, double y)
112 | : this()
113 | {
114 | X = x;
115 | Y = y;
116 | }
117 |
118 | #endregion
119 |
120 | #region [Properties]
121 | /// Gets or sets the x coordinate.
122 | /// The x coordinate.
123 | internal double X { get; set; }
124 |
125 | /// Gets or sets the y coordinate.
126 | /// The y coordinate.
127 | internal double Y { get; set; }
128 |
129 | #endregion
130 |
131 | }
132 |
133 | internal struct WandRectangle
134 | {
135 | #region [Constructors]
136 |
137 | ///
138 | /// Initializes a new instance of the ImageMagickSharp.Global.WandRectangle struct.
139 | /// The x coordinate.
140 | /// The y coordinate.
141 | /// The width.
142 | /// The height.
143 | internal WandRectangle(int x, int y, int width, int height)
144 | : this()
145 | {
146 | X = x;
147 | Y = y;
148 | Width = width;
149 | Height = height;
150 | }
151 | #endregion
152 |
153 | #region [private Properties]
154 |
155 | /// Gets or sets the x coordinate.
156 | /// The x coordinate.
157 | internal int X { get; set; }
158 |
159 | /// Gets or sets the y coordinate.
160 | /// The y coordinate.
161 | internal int Y { get; set; }
162 |
163 | /// Gets or sets the width.
164 | /// The width.
165 | internal int Width { get; set; }
166 |
167 | /// Gets or sets the height.
168 | /// The height.
169 | internal int Height { get; set; }
170 | #endregion
171 | }
172 |
173 | internal struct WandRectangleD
174 | {
175 | #region [Constructors]
176 | ///
177 | /// Initializes a new instance of the ImageMagickSharp.Global.WandRectangleD struct.
178 | /// The x coordinate.
179 | /// The y coordinate.
180 | /// The width.
181 | /// The height.
182 | private WandRectangleD(double x, double y, double width, double height)
183 | : this()
184 | {
185 | X = x;
186 | Y = y;
187 | Width = width;
188 | Height = height;
189 | }
190 |
191 | #endregion
192 |
193 | #region [private Properties]
194 |
195 | /// Gets or sets the x coordinate.
196 | /// The x coordinate.
197 | private double X { get; set; }
198 |
199 | /// Gets or sets the y coordinate.
200 | /// The y coordinate.
201 | private double Y { get; set; }
202 |
203 | /// Gets or sets the width.
204 | /// The width.
205 | private double Width { get; set; }
206 |
207 | /// Gets or sets the height.
208 | /// The height.
209 | private double Height { get; set; }
210 |
211 | #endregion
212 | }
213 | }
214 |
--------------------------------------------------------------------------------
/ImageMagickSharp/ImageMagickSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net45;
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ImageMagickSharp/InteropMarshaler/Utf8Marshaler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp.InteropMarshaler
9 | {
10 | public class UTF8Marshaler : ICustomMarshaler
11 | {
12 | static UTF8Marshaler static_instance;
13 |
14 | public IntPtr MarshalManagedToNative(object managedObj)
15 | {
16 | if (managedObj == null)
17 | return IntPtr.Zero;
18 | if (!(managedObj is string))
19 | throw new MarshalDirectiveException(
20 | "UTF8Marshaler must be used on a string.");
21 |
22 | // not null terminated
23 | byte[] strbuf = Encoding.UTF8.GetBytes((string)managedObj);
24 | IntPtr buffer = Marshal.AllocHGlobal(strbuf.Length + 1);
25 | Marshal.Copy(strbuf, 0, buffer, strbuf.Length);
26 |
27 | // write the terminating null
28 | Marshal.WriteByte(buffer + strbuf.Length, 0);
29 | return buffer;
30 | }
31 |
32 | public object MarshalNativeToManaged(IntPtr pNativeData)
33 | {
34 | throw new NotImplementedException("MarshalNativeToManaged");
35 | }
36 |
37 | public void CleanUpNativeData(IntPtr pNativeData)
38 | {
39 | Marshal.FreeHGlobal(pNativeData);
40 | }
41 |
42 | public void CleanUpManagedData(object managedObj)
43 | {
44 | }
45 |
46 | public int GetNativeDataSize()
47 | {
48 | return -1;
49 | }
50 |
51 | public static ICustomMarshaler GetInstance(string cookie)
52 | {
53 | if (static_instance == null)
54 | {
55 | return static_instance = new UTF8Marshaler();
56 | }
57 | return static_instance;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ImageMagickSharp/LICENSE.md:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {{description}}
294 | Copyright (C) {{year}} {{fullname}}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/ImageMagickSharp/MagickCore/MagickCore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp
9 | {
10 | /// A magick core.
11 | ///
12 | ///
13 | /*internal class MagickCore : WandCore, IDisposable
14 | {
15 | /// Initializes a new instance of the ImageMagickSharp.MagickWand class.
16 | private MagickCore()
17 | {
18 | Wand.EnsureInitialized();
19 | }
20 |
21 | /// Initializes a new instance of the ImageMagickSharp.MagickWand class.
22 | /// The wand.
23 | private MagickCore(IntPtr wand)
24 | {
25 | Wand.EnsureInitialized();
26 | this.Handle = wand;
27 | }
28 |
29 | /// Acquires the image information.
30 | /// An IntPtr.
31 | private IntPtr AcquireImageInfo()
32 | {
33 | return MagickCoreInterop.AcquireImageInfo();
34 | }
35 |
36 | /// Acquires the exception information.
37 | /// An IntPtr.
38 | private IntPtr AcquireExceptionInfo()
39 | {
40 | return MagickCoreInterop.AcquireExceptionInfo();
41 | }
42 |
43 | /// Convert image command.
44 | /// Information describing the image.
45 | /// The argc.
46 | /// The argv.
47 | /// The metadata.
48 | /// The exception.
49 | /// true if it succeeds, false if it fails.
50 | private bool ConvertImageCommand(IntPtr image_info, int argc, string[] argv, byte[] metadata, IntPtr exception)
51 | {
52 | return this.CheckError(MagickCoreInterop.ConvertImageCommand(image_info, argc, argv, metadata,out exception));
53 | }
54 |
55 |
56 | #region [Wand Methods - Exception]
57 | /// Gets the exception.
58 | /// The exception severity.
59 | /// The exception.
60 | public override IntPtr GetException(out int exceptionSeverity)
61 | {
62 | IntPtr exceptionPtr = MagickWandInterop.MagickGetException(this, out exceptionSeverity);
63 | return exceptionPtr;
64 | }
65 |
66 | /// Clears the exception.
67 | ///
68 | /// ### An IntPtr.
69 | public override void ClearException()
70 | {
71 | MagickWandInterop.MagickClearException(this);
72 | }
73 |
74 | #endregion
75 |
76 | #region [IDisposable]
77 |
78 | /// List of images.
79 | private List _ImageList = new List();
80 |
81 | /// Finalizes an instance of the ImageMagickSharp.MagickWand class.
82 | ~MagickCore()
83 | {
84 | this.Dispose(false);
85 | }
86 |
87 | ///
88 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
89 | /// resources.
90 | ///
91 | public void Dispose()
92 | {
93 | Dispose(true);
94 | GC.SuppressFinalize(this);
95 | }
96 |
97 | ///
98 | /// Releases the unmanaged resources used by the ImageMagickSharp.MagickWand and optionally
99 | /// releases the managed resources.
100 | /// true to release both managed and unmanaged resources; false to
101 | /// release only unmanaged resources.
102 | protected virtual void Dispose(bool disposing)
103 | {
104 | if (this.Handle != IntPtr.Zero)
105 | {
106 | this.Handle = MagickWandInterop.DestroyMagickWand(this);
107 | this.Handle = IntPtr.Zero;
108 | }
109 | }
110 |
111 | #endregion
112 |
113 | }*/
114 | }
115 |
--------------------------------------------------------------------------------
/ImageMagickSharp/MagickCore/MagickCoreInterop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp
9 | {
10 | /// A magick core interop.
11 | /*internal class MagickCoreInterop
12 | {
13 | /// Acquires the image information.
14 | /// An IntPtr.
15 | [DllImport("CORE_RL_magick_.dll", CallingConvention = Constants.WandCallingConvention)]
16 | private static extern IntPtr AcquireImageInfo();
17 |
18 | /// Acquires the exception information.
19 | /// An IntPtr.
20 | [DllImport("CORE_RL_magick_.dll", CallingConvention = Constants.WandCallingConvention)]
21 | private static extern IntPtr AcquireExceptionInfo();
22 |
23 | /// Convert image command.
24 | /// Information describing the image.
25 | /// The argc.
26 | /// The argv.
27 | /// The metadata.
28 | /// The exception.
29 | /// true if it succeeds, false if it fails.
30 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
31 | private static extern bool ConvertImageCommand(IntPtr image_info, int argc, string[] argv, byte[] metadata, out IntPtr exception);
32 | }*/
33 | }
34 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Pixel/PixelIterator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp
9 | {
10 | /// A pixel iterator.
11 | ///
12 | ///
13 | /*internal class PixelIterator : WandCore, IDisposable
14 | {
15 | #region [Constructors]
16 |
17 | ///
18 | /// Initializes a new instance of the ImageMagickSharp.PixelIterator class.
19 | /// Thrown when an exception error condition occurs.
20 | internal PixelIterator()
21 | {
22 | this.Handle = PixelIteratorInterop.NewPixelIterator();
23 | if (this.Handle == IntPtr.Zero)
24 | {
25 | throw new Exception("Error acquiring pixel iterator wand.");
26 | }
27 | }
28 |
29 | ///
30 | /// Initializes a new instance of the ImageMagickSharp.PixelIterator class.
31 | /// Thrown when an exception error condition occurs.
32 | /// The magick wand.
33 | internal PixelIterator(MagickWand magickWand)
34 | {
35 | this.Handle = PixelIteratorInterop.NewPixelIterator(magickWand);
36 | if (this.Handle == IntPtr.Zero)
37 | {
38 | throw new Exception("Error acquiring pixel iterator wand.");
39 | }
40 | }
41 |
42 | ///
43 | /// Initializes a new instance of the ImageMagickSharp.PixelIterator class.
44 | /// The handle.
45 | internal PixelIterator(IntPtr handle)
46 | : base(handle)
47 | {
48 |
49 | }
50 |
51 | ///
52 | /// Initializes a new instance of the ImageMagickSharp.PixelIterator class.
53 | /// Thrown when an exception error condition occurs.
54 | /// The magickWand.
55 | /// The x coordinate.
56 | /// The y coordinate.
57 | /// The width.
58 | /// The height.
59 | internal PixelIterator(IntPtr magickWand, int x, int y, int width, int height)
60 | {
61 | this.Handle = PixelIteratorInterop.NewPixelRegionIterator(magickWand, x, y, width, height);
62 | if (this.Handle == IntPtr.Zero)
63 | {
64 | throw new Exception("Error acquiring pixel iterator wand.");
65 | }
66 | }
67 |
68 | #endregion
69 |
70 | #region [PixelIterator Wand]
71 |
72 | /// Clears the pixel iterator.
73 | /*private void ClearPixelIterator()
74 | {
75 | PixelIteratorInterop.ClearPixelIterator(this);
76 | }
77 |
78 | /// Clone pixel iterator.
79 | /// A PixelIterator.
80 | private PixelIterator ClonePixelIterator()
81 | {
82 | return new PixelIterator(PixelIteratorInterop.ClonePixelIterator(this));
83 | }*/
84 |
85 | /*#endregion
86 |
87 | #region [PixelIterator Wand - Properties]
88 | /// Gets or sets the iterator row.
89 | /// The iterator row.
90 | /*private int IteratorRow
91 | {
92 | get { return PixelIteratorInterop.PixelGetIteratorRow(this); }
93 | set { this.CheckError(PixelIteratorInterop.PixelSetIteratorRow(this, value)); }
94 | }
95 |
96 | #endregion
97 |
98 | #region [PixelIterator Wand - Methods]
99 |
100 | /// Query if this object is pixel iterator.
101 | /// true if pixel iterator, false if not.
102 | private bool IsPixelIterator()
103 | {
104 | return this.CheckError(PixelIteratorInterop.IsPixelIterator(this));
105 | }
106 |
107 | /// Current iterator row.
108 | /// A PixelWand.
109 | private IntPtr[] GetCurrentIteratorRow()
110 | {
111 | int number_wands;
112 | IntPtr iteratorRow = PixelIteratorInterop.PixelGetCurrentIteratorRow(this, out number_wands);
113 | IntPtr[] rowArray = new IntPtr[number_wands];
114 | Marshal.Copy(iteratorRow, rowArray, 0, number_wands);
115 | return rowArray;
116 | }
117 |
118 | /// Gets current pixel iterator row.
119 | /// An array of pixel wand.
120 | /* NOT WORKING
121 | *
122 | * internal PixelWand[] GetCurrentPixelIteratorRow()
123 | {
124 | IntPtr[] rowArray = this.GetCurrentIteratorRow();
125 | PixelWand[] pixelArray = rowArray.Select(n => new PixelWand(n)).ToArray();
126 | return pixelArray;
127 | } */
128 | /*
129 | /// Gets the next iterator row.
130 | /// An array of int pointer.
131 | private IntPtr[] GetNextIteratorRow()
132 | {
133 | int number_wands;
134 | IntPtr iteratorRow = PixelIteratorInterop.PixelGetNextIteratorRow(this, out number_wands);
135 | IntPtr[] rowArray = new IntPtr[number_wands];
136 | Marshal.Copy(iteratorRow, rowArray, 0, number_wands);
137 | return rowArray;
138 | }
139 |
140 | /// Gets the next pixel iterator row.
141 | /// An array of pixel wand.
142 | /* NOT WORKING
143 | internal PixelWand[] GetNextPixelIteratorRow()
144 | {
145 | IntPtr[] rowArray = this.GetNextIteratorRow();
146 | PixelWand[] pixelArray = rowArray.Select(n=> new PixelWand(n)).ToArray();
147 | return pixelArray;
148 | }*/
149 |
150 | /// Previous iterator row.
151 | /// A PixelWand.
152 | /*private IntPtr[] GetPreviousIteratorRow()
153 | {
154 | int number_wands;
155 | IntPtr iteratorRow = PixelIteratorInterop.PixelGetPreviousIteratorRow(this, out number_wands);
156 | IntPtr[] rowArray = new IntPtr[number_wands];
157 | Marshal.Copy(iteratorRow, rowArray, 0, number_wands);
158 | return rowArray;
159 | }
160 |
161 | /// Gets the previous pixel iterator row.
162 | /// An array of pixel wand.
163 | /* NOT WORKING
164 | internal PixelWand[] GetPreviousPixelIteratorRow()
165 | {
166 | IntPtr[] rowArray = this.GetPreviousIteratorRow();
167 | PixelWand[] pixelArray = rowArray.Select(n => new PixelWand(n)).ToArray();
168 | return pixelArray;
169 | }*/
170 |
171 | /// Resets the iterator.
172 | /*private void ResetIterator()
173 | {
174 | PixelIteratorInterop.PixelResetIterator(this);
175 | }
176 |
177 |
178 | /// Pixel set first iterator row.
179 | private void PixelSetFirstIteratorRow()
180 | {
181 | PixelIteratorInterop.PixelSetFirstIteratorRow(this);
182 | }
183 |
184 | /// Pixel set last iterator row.
185 | private void PixelSetLastIteratorRow()
186 | {
187 | PixelIteratorInterop.PixelSetLastIteratorRow(this);
188 | }
189 |
190 | /// Determines if we can pixel synchronise iterator.
191 | /// true if it succeeds, false if it fails.
192 | private bool PixelSyncIterator()
193 | {
194 | return this.CheckError(PixelIteratorInterop.PixelSyncIterator(this));
195 | }*/
196 |
197 | /*#endregion
198 |
199 | #region [Wand Methods - Exception]
200 | /// Gets the exception.
201 | /// The exception severity.
202 | /// The exception.
203 | public override IntPtr GetException(out int exceptionSeverity)
204 | {
205 | IntPtr exceptionPtr = PixelIteratorInterop.PixelGetIteratorException(this, out exceptionSeverity);
206 | return exceptionPtr;
207 | }
208 |
209 | /// Clears the exception.
210 | public override void ClearException()
211 | {
212 | PixelIteratorInterop.PixelClearIteratorException(this);
213 | }
214 |
215 | #endregion
216 |
217 | #region [IDisposable]
218 |
219 | ///
220 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
221 | /// resources.
222 | ///
223 | public void Dispose()
224 | {
225 | Dispose(true);
226 | GC.SuppressFinalize(this);
227 | }
228 |
229 | ///
230 | /// Releases the unmanaged resources used by the ImageMagickSharp.PixelWand and optionally
231 | /// releases the managed resources.
232 | /// true to release both managed and unmanaged resources; false to
233 | /// release only unmanaged resources.
234 | protected virtual void Dispose(bool disposing)
235 | {
236 | if (this.Handle != IntPtr.Zero)
237 | {
238 | PixelIteratorInterop.DestroyPixelIterator(this);
239 | this.Handle = IntPtr.Zero;
240 | }
241 | }
242 | #endregion
243 |
244 | }*/
245 | }
246 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Pixel/PixelIteratorInterop.cs:
--------------------------------------------------------------------------------
1 | /*using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ImageMagickSharp
9 | {
10 | /// A pixel iterator interop.
11 | internal class PixelIteratorInterop
12 | {
13 | #region [PixelIterator Wand]
14 |
15 | /// Creates a new pixel iterator.
16 | /// An IntPtr.
17 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
18 | internal static extern IntPtr NewPixelIterator();
19 |
20 | /// Creates a new pixel iterator.
21 | /// The wand.
22 | /// An IntPtr.
23 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
24 | internal static extern IntPtr NewPixelIterator(IntPtr wand);
25 |
26 | /// Clears the pixel iterator described by wand.
27 | /// The wand.
28 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
29 | private static extern void ClearPixelIterator(IntPtr wand);
30 |
31 | /// Clone pixel iterator.
32 | /// The wand.
33 | /// An IntPtr.
34 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
35 | private static extern IntPtr ClonePixelIterator(IntPtr wand);
36 |
37 | /// Destroys the pixel iterator described by wand.
38 | /// The wand.
39 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
40 | private static extern void DestroyPixelIterator(IntPtr wand);
41 |
42 | #endregion
43 |
44 | #region [PixelIterator Wand - Properties]
45 | /// Pixel get iterator row.
46 | /// The wand.
47 | /// An int.
48 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
49 | private static extern int PixelGetIteratorRow(IntPtr wand);
50 |
51 | /// Pixel set iterator row.
52 | /// The wand.
53 | /// The row.
54 | /// true if it succeeds, false if it fails.
55 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
56 | private static extern bool PixelSetIteratorRow(IntPtr wand, int row);
57 |
58 | #endregion
59 |
60 | #region [PixelIterator Wand - Methods]
61 | /// Query if 'wand' is pixel iterator.
62 | /// The wand.
63 | /// true if pixel iterator, false if not.
64 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
65 | private static extern bool IsPixelIterator(IntPtr wand);
66 |
67 | /// Creates a new pixel region iterator.
68 | /// The wand.
69 | /// The x coordinate.
70 | /// The y coordinate.
71 | /// The width.
72 | /// The height.
73 | /// An IntPtr.
74 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
75 | internal static extern IntPtr NewPixelRegionIterator(IntPtr wand, int x, int y, int width, int height);
76 |
77 | /// Pixel get current iterator row.
78 | /// The wand.
79 | /// Number of wands.
80 | /// An IntPtr.
81 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
82 | private static extern IntPtr PixelGetCurrentIteratorRow(IntPtr wand, out int number_wands);
83 |
84 | /// Pixel get next iterator row.
85 | /// The wand.
86 | /// Number of wands.
87 | /// An IntPtr.
88 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
89 | private static extern IntPtr PixelGetNextIteratorRow(IntPtr wand, out int number_wands);
90 |
91 | /// Pixel get previous iterator row.
92 | /// The wand.
93 | /// Number of wands.
94 | /// An IntPtr.
95 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
96 | private static extern IntPtr PixelGetPreviousIteratorRow(IntPtr wand,out int number_wands);
97 |
98 | /// Pixel reset iterator.
99 | /// The wand.
100 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
101 | private static extern void PixelResetIterator(IntPtr wand);
102 |
103 | /// Pixel set first iterator row.
104 | /// The wand.
105 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
106 | private static extern void PixelSetFirstIteratorRow(IntPtr wand);
107 |
108 | /// Pixel set last iterator row.
109 | /// The wand.
110 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
111 | private static extern void PixelSetLastIteratorRow(IntPtr wand);
112 |
113 | /// Pixel synchronise iterator.
114 | /// The wand.
115 | /// true if it succeeds, false if it fails.
116 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
117 | private static extern bool PixelSyncIterator(IntPtr wand);
118 |
119 | #endregion
120 |
121 | #region [Wand Methods - Exception]
122 | /// Pixel clear iterator exception.
123 | /// The wand.
124 | /// An int.
125 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
126 | private static extern int PixelClearIteratorException(IntPtr wand);
127 |
128 | /// Pixel get iterator exception.
129 | /// The wand.
130 | /// Type of the exception.
131 | /// An IntPtr.
132 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
133 | private static extern IntPtr PixelGetIteratorException(IntPtr wand, out int exceptionType);
134 |
135 | /// Pixel get iterator exception type.
136 | /// The wand.
137 | /// An int.
138 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
139 | private static extern int PixelGetIteratorExceptionType(IntPtr wand);
140 |
141 | #endregion
142 |
143 | }
144 | }
145 | */
--------------------------------------------------------------------------------
/ImageMagickSharp/Pixel/PixelWand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A pixel wand.
10 | ///
11 | ///
12 | public class PixelWand : WandCore, IDisposable
13 | {
14 | #region [Constructors]
15 |
16 | /// Initializes a new instance of the ImageMagickSharp.PixelWand class.
17 | /// The color.
18 | public PixelWand(string color, double opacity = 0)
19 | : this()
20 | {
21 | this.Color = color;
22 | this.Opacity = opacity;
23 | }
24 |
25 | /// Initializes a new instance of the ImageMagickSharp.PixelWand class.
26 | /// Thrown when an exception error condition occurs.
27 | public PixelWand()
28 | {
29 | this.Handle = PixelWandInterop.NewPixelWand();
30 | if (this.Handle == IntPtr.Zero)
31 | {
32 | throw new Exception("Error acquiring pixel wand.");
33 | }
34 | }
35 | ///
36 | /// Initializes a new instance of the PixelWand class.
37 | ///
38 | ///
39 | private PixelWand(IntPtr handle)
40 | : base(handle)
41 | {
42 |
43 | }
44 |
45 | #endregion
46 |
47 | #region [Properties]
48 | /// Gets or sets the color.
49 | /// The color.
50 | public string Color
51 | {
52 | get { return WandNativeString.Load(PixelWandInterop.PixelGetColorAsString(this)); }
53 | set { this.CheckError(PixelWandInterop.PixelSetColor(this, value)); }
54 | }
55 |
56 | /// Gets the color of the normalized.
57 | /// The color of the normalized.
58 | private string NormalizedColor
59 | {
60 | get
61 | {
62 | return WandNativeString.Load(PixelWandInterop.PixelGetColorAsNormalizedString(this));
63 | }
64 | }
65 |
66 | #endregion
67 |
68 | #region [Methods]
69 | /// From a RGB.
70 | /// The alpha.
71 | /// The red.
72 | /// The green.
73 | /// The blue.
74 | /// A PixelWand.
75 | /*private static PixelWand FromARGB(double alpha, double red, double green, double blue)
76 | {
77 | return new PixelWand()
78 | {
79 | Alpha = alpha,
80 | Red = red,
81 | Green = green,
82 | Blue = blue,
83 | };
84 | }
85 |
86 | /// From RGB.
87 | /// The red.
88 | /// The green.
89 | /// The blue.
90 | /// A PixelWand.
91 | private static PixelWand FromRGB(double red, double green, double blue)
92 | {
93 | return new PixelWand()
94 | {
95 | Red = red,
96 | Green = green,
97 | Blue = blue,
98 | };
99 | }*/
100 |
101 | #endregion
102 |
103 | #region [Pixel Wand]
104 |
105 | /// Clears the pixel wand.
106 | /* private void ClearPixelWand()
107 | {
108 | PixelWandInterop.ClearPixelWand(this);
109 | }
110 |
111 | /// Clone pixel wand.
112 | /// A PixelWand.
113 | private PixelWand ClonePixelWand()
114 | {
115 | return new PixelWand(PixelWandInterop.ClonePixelWand(this));
116 | }*/
117 |
118 | /// Destroys the pixel wand.
119 | private void DestroyPixelWand()
120 | {
121 | PixelWandInterop.DestroyPixelWand(this);
122 | }
123 |
124 | #endregion
125 |
126 | #region [Pixel Wand Properties - RGB]
127 | /// Gets or sets the alpha.
128 | /// The alpha.
129 | private double Alpha
130 | {
131 | get { return PixelWandInterop.PixelGetAlpha(this); }
132 | set { PixelWandInterop.PixelSetAlpha(this, value); }
133 | }
134 |
135 | /// Gets or sets the opacity.
136 | /// The opacity.
137 | public double Opacity
138 | {
139 | get { return PixelWandInterop.PixelGetOpacity(this); }
140 | set { PixelWandInterop.PixelSetOpacity(this, value); }
141 | }
142 |
143 | /// Gets or sets the red.
144 | /// The red.
145 | /*private double Red
146 | {
147 | get { return PixelWandInterop.PixelGetRed(this); }
148 | set { PixelWandInterop.PixelSetRed(this, value); }
149 | }
150 |
151 | /// Gets or sets the green.
152 | /// The green.
153 | private double Green
154 | {
155 | get { return PixelWandInterop.PixelGetGreen(this); }
156 | set { PixelWandInterop.PixelSetGreen(this, value); }
157 | }
158 |
159 | /// Gets or sets the blue.
160 | /// The blue.
161 | private double Blue
162 | {
163 | get { return PixelWandInterop.PixelGetBlue(this); }
164 | set { PixelWandInterop.PixelSetBlue(this, value); }
165 | }*/
166 | #endregion
167 |
168 | #region [Wand Methods - Exception]
169 |
170 | /// Gets the exception.
171 | /// The exception.
172 | public override IntPtr GetException(out int exceptionSeverity)
173 | {
174 | IntPtr exceptionPtr = PixelWandInterop.PixelGetException(this, out exceptionSeverity);
175 | return exceptionPtr;
176 | }
177 |
178 | /// Clears the exception.
179 | /// An IntPtr.
180 | public override void ClearException()
181 | {
182 | PixelWandInterop.PixelClearException(this);
183 | }
184 |
185 | #endregion
186 |
187 | #region [Pixel Wand Operators]
188 |
189 | /// Implicit cast that converts the given PixelWand to a string.
190 | /// The wand.
191 | /// The result of the operation.
192 | public static implicit operator string(PixelWand wand)
193 | {
194 | return wand.Color;
195 | }
196 |
197 | #endregion
198 |
199 | #region [IDisposable]
200 | /// Finalizes an instance of the ImageMagickSharp.MagickWand class.
201 | ~PixelWand()
202 | {
203 | this.Dispose(false);
204 | }
205 |
206 | ///
207 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged
208 | /// resources.
209 | ///
210 | public void Dispose()
211 | {
212 | Dispose(true);
213 | GC.SuppressFinalize(this);
214 | }
215 |
216 | ///
217 | /// Releases the unmanaged resources used by the ImageMagickSharp.PixelWand and optionally
218 | /// releases the managed resources.
219 | /// true to release both managed and unmanaged resources; false to
220 | /// release only unmanaged resources.
221 | protected virtual void Dispose(bool disposing)
222 | {
223 | if (this.Handle != IntPtr.Zero)
224 | {
225 | PixelWandInterop.DestroyPixelWand(this);
226 | this.Handle = IntPtr.Zero;
227 |
228 | }
229 | }
230 | #endregion
231 |
232 | }
233 | }
234 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Pixel/PixelWandInterop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ImageMagickSharp.InteropMarshaler;
8 |
9 | namespace ImageMagickSharp
10 | {
11 | /// A pixel wand interop.
12 | internal static class PixelWandInterop
13 | {
14 |
15 | #region [Pixel Wand]
16 | /// Creates a new pixel wand.
17 | ///
18 | /// WandExport PixelWand *NewPixelWand(void)
19 | ///
20 | ///
21 | /// An IntPtr.
22 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
23 | internal static extern IntPtr NewPixelWand();
24 |
25 | /// Destroys the pixel wand described by wand.
26 | /// Handle of the wand.
27 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
28 | private static extern void ClearPixelWand(IntPtr wand);
29 |
30 | /// Clone pixel wand.
31 | /// Handle of the wand.
32 | /// An IntPtr.
33 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
34 | private static extern IntPtr ClonePixelWand(IntPtr wand);
35 |
36 | /// Destroys the pixel wand described by wand.
37 | ///
38 | /// WandExport PixelWand *DestroyPixelWand(PixelWand *wand)
39 | ///
40 | ///
41 | /// Handle of the wand.
42 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
43 | internal static extern IntPtr DestroyPixelWand(IntPtr wand);
44 |
45 | #endregion
46 |
47 | #region [Pixel Wand Color]
48 | /// Pixel set color.
49 | ///
50 | /// WandExport MagickBooleanType PixelSetColor(PixelWand *wand,const char *color)
51 | ///
52 | ///
53 | /// Handle of the wand.
54 | /// The color.
55 | /// An int.
56 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
57 | internal static extern bool PixelSetColor(IntPtr wand,
58 | [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))] string color);
59 |
60 | /// Pixel get color as string.
61 | ///
62 | /// WandExport char *PixelGetColorAsString(const PixelWand *wand)
63 | ///
64 | ///
65 | /// Handle of the wand.
66 | /// An IntPtr.
67 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
68 | internal static extern IntPtr PixelGetColorAsString(IntPtr wand);
69 |
70 | /// Pixel get color as normalized string.
71 | ///
72 | /// WandExport char *PixelGetColorAsNormalizedString(const PixelWand *wand)
73 | ///
74 | ///
75 | /// Handle of the wand.
76 | /// An IntPtr.
77 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
78 | internal static extern IntPtr PixelGetColorAsNormalizedString(IntPtr wand);
79 |
80 | /// Pixel get alpha.
81 | ///
82 | /// WandExport double PixelGetAlpha(const PixelWand *wand)
83 | ///
84 | ///
85 | /// Handle of the wand.
86 | /// A double.
87 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
88 | internal static extern double PixelGetAlpha(IntPtr wand);
89 |
90 | /// Pixel set alpha.
91 | ///
92 | /// WandExport void PixelSetAlpha(PixelWand *wand,const double alpha)
93 | ///
94 | ///
95 | /// Handle of the wand.
96 | /// The value.
97 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
98 | internal static extern void PixelSetAlpha(IntPtr wand, double value);
99 |
100 | /// Pixel get opacity.
101 | ///
102 | /// WandExport double PixelGetOpacity(const PixelWand *wand)
103 | ///
104 | ///
105 | /// Handle of the wand.
106 | /// A double.
107 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
108 | internal static extern double PixelGetOpacity(IntPtr wand);
109 |
110 | /// Pixel set opacity.
111 | ///
112 | /// WandExport void PixelSetOpacity(PixelWand *wand,const double opacity)
113 | ///
114 | ///
115 | /// Handle of the wand.
116 | /// The value.
117 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
118 | internal static extern void PixelSetOpacity(IntPtr wand, double value);
119 |
120 | /// Pixel get red.
121 | /// Handle of the wand.
122 | /// A double.
123 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
124 | private static extern double PixelGetRed(IntPtr wand);
125 |
126 | /// Pixel set red.
127 | /// Handle of the wand.
128 | /// The value.
129 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
130 | private static extern void PixelSetRed(IntPtr wand, double value);
131 |
132 | /// Pixel get green.
133 | /// Handle of the wand.
134 | /// A double.
135 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
136 | private static extern double PixelGetGreen(IntPtr wand);
137 |
138 | /// Pixel set green.
139 | /// Handle of the wand.
140 | /// The value.
141 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
142 | private static extern void PixelSetGreen(IntPtr wand, double value);
143 |
144 | /// Pixel get blue.
145 | /// Handle of the wand.
146 | /// A double.
147 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
148 | private static extern double PixelGetBlue(IntPtr wand);
149 |
150 | /// Pixel set blue.
151 | /// Handle of the wand.
152 | /// The value.
153 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
154 | private static extern void PixelSetBlue(IntPtr wand, double value);
155 |
156 | #endregion
157 |
158 | #region [Wand Methods - Exception]
159 | /// Pixel clear exception.
160 | ///
161 | /// WandExport MagickBooleanType PixelClearException(PixelWand *wand)
162 | ///
163 | ///
164 | /// Handle of the wand.
165 | /// An int.
166 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
167 | internal static extern bool PixelClearException(IntPtr wand);
168 |
169 | /// Pixel get exception.
170 | ///
171 | /// WandExport char *PixelGetException(const PixelWand *wand,ExceptionType *severity)
172 | ///
173 | ///
174 | /// Handle of the wand.
175 | /// Type of the exception.
176 | /// An IntPtr.
177 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
178 | internal static extern IntPtr PixelGetException(IntPtr wand, out int exceptionType);
179 |
180 | /// Pixel get exception type.
181 | ///
182 | /// WandExport ExceptionType PixelGetExceptionType(const PixelWand *wand)
183 | ///
184 | ///
185 | /// Handle of the wand.
186 | /// An int.
187 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
188 | internal static extern int PixelGetExceptionType(IntPtr wand);
189 |
190 | #endregion
191 |
192 |
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/Wand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ImageMagickSharp
11 | {
12 | /// A wand.
13 | public class Wand
14 | {
15 |
16 | #region [Singleton]
17 |
18 | /// The instance.
19 | private static readonly Lazy _Instance = new Lazy(() => new Wand());
20 |
21 | /// Gets the instance.
22 | /// The instance.
23 | protected static Wand Instance
24 | {
25 | get
26 | {
27 | return _Instance.Value;
28 | }
29 | }
30 |
31 | #endregion
32 |
33 | #region [Wand Initializer]
34 |
35 | /// The is initialized.
36 | private static bool _IsInitialized = false;
37 |
38 | /// Initializes a new instance of the Wand class.
39 | private Wand()
40 | {
41 | this.InitializeEnvironment();
42 | }
43 |
44 | /// Sets magick coder module path.
45 | /// Full pathname of the file.
46 | public static void SetMagickCoderModulePath(string path)
47 | {
48 | Environment.SetEnvironmentVariable("MAGICK_CODER_MODULE_PATH", path);
49 | }
50 |
51 | ///
52 | /// Sets the magick coder module path.
53 | ///
54 | /// The thread count.
55 | public static void SetMagickThreadCount(int threadCount)
56 | {
57 | Environment.SetEnvironmentVariable("MAGICK_THREAD_LIMIT", threadCount.ToString(CultureInfo.InvariantCulture));
58 | }
59 |
60 | /// Sets magick configure path.
61 | /// Full pathname of the file.
62 | internal static void SetMagickConfigurePath(string path)
63 | {
64 | Environment.SetEnvironmentVariable("MAGICK_CONFIGURE_PATH", path);
65 | }
66 |
67 | /// Sets magick font path.
68 | /// Full pathname of the file.
69 | internal static void SetMagickFontPath(string path)
70 | {
71 | Environment.SetEnvironmentVariable("MAGICK_FONT_PATH", path);
72 | }
73 |
74 | /// Initializes the environment.
75 | protected void InitializeEnvironment()
76 | {
77 | if (!_IsInitialized)
78 | {
79 | WandInterop.MagickWandGenesis();
80 | _IsInitialized = WandInterop.IsMagickWandInstantiated();
81 | if (!_IsInitialized)
82 | throw new Exception("Cannot Instantiate Wand");
83 | }
84 | }
85 |
86 | /// Dispose environment.
87 | protected void DisposeEnvironment()
88 | {
89 | if (IsInitialized)
90 | {
91 | WandInterop.MagickWandTerminus();
92 | _IsInitialized = false;
93 | }
94 | }
95 |
96 | /// Finalizes an instance of the ImageMagickSharp.Wand class.
97 | ~Wand()
98 | {
99 | this.DisposeEnvironment();
100 | }
101 |
102 | #endregion
103 |
104 | #region [Wand Properties]
105 |
106 | /// Gets a value indicating whether this object is initialized.
107 | /// true if this object is initialized, false if not.
108 | internal static bool IsInitialized
109 | {
110 | get
111 | {
112 | return _IsInitialized;
113 | }
114 | }
115 |
116 | /// Gets a value indicating whether this object is wand instantiated.
117 | /// true if this object is wand instantiated, false if not.
118 | internal static bool IsWandInstantiated
119 | {
120 | get
121 | {
122 | return WandInterop.IsMagickWandInstantiated();
123 | }
124 | }
125 |
126 | /// Gets the version string.
127 | /// The version string.
128 | public static string VersionString
129 | {
130 | get
131 | {
132 | EnsureInitialized();
133 | IntPtr version;
134 | return WandNativeString.Load(WandInterop.MagickGetVersion(out version), false);
135 | }
136 | }
137 |
138 | /// Gets the version number.
139 | /// The version number.
140 | private static int VersionNumber
141 | {
142 | get
143 | {
144 | EnsureInitialized();
145 | IntPtr version;
146 | WandInterop.MagickGetVersion(out version);
147 | return (int)version;
148 | }
149 | }
150 |
151 | /// Gets the version number string.
152 | /// The version number string.
153 | private static string VersionNumberString
154 | {
155 | get
156 | {
157 | return string.Join(".", VersionNumber.ToString("x").ToArray());
158 | }
159 | }
160 |
161 | #endregion
162 |
163 | #region [Wand Methods]
164 |
165 | /// Opens the environment.
166 | internal static void OpenEnvironment()
167 | {
168 | Wand.Instance.InitializeEnvironment();
169 | }
170 |
171 | /// Closes the environment.
172 | public static void CloseEnvironment()
173 | {
174 | if (_Instance != null && _Instance.Value != null)
175 | {
176 | _Instance.Value.DisposeEnvironment();
177 | }
178 |
179 | }
180 |
181 | /// Ensures that initialized.
182 | internal static void EnsureInitialized()
183 | {
184 | if (!_IsInitialized)
185 | Wand.Instance.InitializeEnvironment();
186 | }
187 |
188 | /// Gets the handle.
189 | /// The handle.
190 | internal static IntPtr GetHandle()
191 | {
192 | IntPtr version;
193 | return WandInterop.MagickGetVersion(out version);
194 | }
195 |
196 | /// Query if 'wand' is magick wand.
197 | /// The wand.
198 | /// true if magick wand, false if not.
199 | /*private static bool IsMagickWand(IntPtr wand)
200 | {
201 | return WandInterop.IsMagickWand(wand);
202 | }*/
203 |
204 | /// Command genesis.
205 | /// Information describing the image.
206 | /// The command.
207 | /// The argc.
208 | /// The argv.
209 | /// The metadata.
210 | /// The exception.
211 | /// true if it succeeds, false if it fails.
212 | /*private static bool CommandGenesis(IntPtr image_info, MagickCommandType command, int argc, string[] argv, byte[] metadata, IntPtr exception)
213 | {
214 | return WandInterop.MagickCommandGenesis(image_info, command, argc, argv, metadata, ref exception);
215 | //return WandInterop.MagickCommandGenesis(image_info, command, argc, argv);
216 | }*/
217 |
218 | /// Queries the formats.
219 | /// Specifies the pattern.
220 | /// An array of string.
221 | internal static List QueryFormats(string pattern)
222 | {
223 | EnsureInitialized();
224 | IntPtr number_formats = IntPtr.Zero;
225 | IntPtr format = WandInterop.MagickQueryFormats("*", ref number_formats);
226 | IntPtr[] rowArray = new IntPtr[(int)number_formats];
227 | Marshal.Copy(format, rowArray, 0, (int)number_formats);
228 | List val = rowArray.Select(x => WandNativeString.Load(x)).ToList();
229 | if (pattern == "*")
230 | return val;
231 | return val.FindAll(x => x.Equals(pattern, StringComparison.OrdinalIgnoreCase));
232 | }
233 |
234 | /// Queries format from file.
235 | /// The file.
236 | /// true if it succeeds, false if it fails.
237 | /*private static bool QueryFormatFromFile(string file)
238 | {
239 | return QueryFormats(Path.GetExtension(file).Replace(".", "")).Count > 0;
240 | }*/
241 |
242 | /// Queries the fonts.
243 | /// Specifies the pattern.
244 | /// An array of string.
245 | /*private static List QueryFonts(string pattern)
246 | {
247 | EnsureInitialized();
248 | using (var stringFormat = new WandNativeString("*"))
249 | {
250 | int number_formats = 0;
251 | IntPtr format = WandInterop.MagickQueryFonts(stringFormat.Pointer, ref number_formats);
252 | IntPtr[] rowArray = new IntPtr[number_formats];
253 | Marshal.Copy(format, rowArray, 0, number_formats);
254 | List val = rowArray.Select(x => WandNativeString.Load(x)).ToList();
255 | if (pattern == "*")
256 | return val;
257 | return val.FindAll(x=> x.Equals(pattern, StringComparison.InvariantCultureIgnoreCase));
258 | }
259 | }*/
260 |
261 | #endregion
262 |
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/WandBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A wand base.
10 | public abstract class WandBase
11 | {
12 |
13 | #region [Constructors]
14 |
15 | /// Initializes a new instance of the MagickBase class.
16 | /// .
17 | protected WandBase(MagickWand magickWand)
18 | {
19 | _MagickWand = magickWand;
20 | }
21 |
22 | #endregion
23 |
24 | #region [Private Fields]
25 |
26 | /// The magick wand.
27 | private MagickWand _MagickWand;
28 |
29 | #endregion
30 |
31 | #region [private Properties]
32 |
33 | /// Gets the magick wand.
34 | /// The magick wand.
35 | internal MagickWand MagickWand
36 | {
37 | get { return _MagickWand; }
38 | }
39 |
40 | #endregion
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/WandCore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ImageMagickSharp
8 | {
9 |
10 | public interface IWandCore
11 | {
12 | /// Clears the exception.
13 | void ClearException();
14 |
15 | /// Gets an exception.
16 | /// The exception severity.
17 | /// The exception.
18 | IntPtr GetException(out int exceptionSeverity);
19 |
20 | /// Gets the handle of the wand.
21 | /// The wand handle.
22 | IntPtr Handle { get; }
23 | /// Check error.
24 | /// Thrown when a Wand error condition occurs.
25 | /// true to status.
26 | /// true if it succeeds, false if it fails.
27 | int CheckError(int status);
28 | /// Check error.
29 | /// Thrown when a Wand error condition occurs.
30 | /// true to status.
31 | /// true if it succeeds, false if it fails.
32 | bool CheckErrorBool(int status);
33 | /// Check error.
34 | /// Thrown when a Wand error condition occurs.
35 | /// true to status.
36 | /// true if it succeeds, false if it fails.
37 | bool CheckError(bool status);
38 | }
39 |
40 |
41 | public abstract class WandCore : IWandCore where T : class,IWandCore
42 | {
43 |
44 | #region [Wand Handle]
45 | /// Gets the handle of the wand.
46 | /// The wand handle.
47 | public IntPtr Handle { get; protected set; }
48 |
49 | ///
50 | /// Initializes a new instance of the ImageMagickSharp.WandCore<T> class.
51 | protected WandCore()
52 | {
53 | }
54 |
55 | ///
56 | /// Initializes a new instance of the WandCore class.
57 | ///
58 | ///
59 | protected WandCore(IntPtr handle)
60 | {
61 | Handle = handle;
62 | }
63 |
64 | public static implicit operator IntPtr(WandCore wand)
65 | {
66 | return wand.Handle;
67 | }
68 | #endregion
69 |
70 | #region [Wand Check Error]
71 |
72 | /// Check error.
73 | /// Thrown when a Wand error condition occurs.
74 | /// true to status.
75 | /// true if it succeeds, false if it fails.
76 | public int CheckError(int status)
77 | {
78 | if (status == Constants.MagickFalse)
79 | {
80 | throw new WandException(this);
81 | }
82 |
83 | return status;
84 | }
85 |
86 | /// Check error.
87 | /// Thrown when a Wand error condition occurs.
88 | /// true to status.
89 | /// true if it succeeds, false if it fails.
90 | public bool CheckErrorBool(int status)
91 | {
92 | if (status == Constants.MagickFalse)
93 | {
94 | throw new WandException(this);
95 | }
96 |
97 | return true;
98 | }
99 |
100 | public bool CheckErrorBool(bool status)
101 | {
102 | if (status == false)
103 | {
104 | throw new WandException(this);
105 | }
106 |
107 | return status;
108 | }
109 |
110 | /// Check error.
111 | /// Thrown when a Wand error condition occurs.
112 | /// true to status.
113 | /// true if it succeeds, false if it fails.
114 | public bool CheckError(bool status)
115 | {
116 | if (status == false)
117 | {
118 | throw new WandException(this);
119 | }
120 |
121 | return status;
122 | }
123 | public abstract IntPtr GetException(out int exceptionSeverity);
124 | public abstract void ClearException();
125 |
126 | #endregion
127 |
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/WandException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace ImageMagickSharp
5 | {
6 | /// Exception for signalling wand errors.
7 | ///
8 | internal class WandException : Exception
9 | {
10 | #region [Constructors]
11 |
12 | ///
13 | /// Initializes a new instance of the ImageMagickSharp.WandException class.
14 | /// Handle of the wand.
15 | internal WandException(IWandCore wand)
16 | : base(DecodeException(wand))
17 | {
18 | }
19 |
20 | #endregion
21 |
22 | #region [Private Methods]
23 |
24 | /// Decode exception.
25 | /// Handle of the wand.
26 | /// A string.
27 | private static string DecodeException(IWandCore wand)
28 | {
29 | int exceptionSeverity;
30 |
31 | IntPtr exceptionPtr = wand.GetException(out exceptionSeverity);
32 | wand.ClearException();
33 | return WandNativeString.Load(exceptionPtr);
34 | }
35 |
36 | #endregion
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/WandInterop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ImageMagickSharp.InteropMarshaler;
8 |
9 | namespace ImageMagickSharp
10 | {
11 | /// A wand interop.
12 | internal class WandInterop
13 | {
14 |
15 | #region [Wand Properties]
16 | /// Magick get version.
17 | ///
18 | /// WandExport const char *MagickGetVersion(size_t *version)
19 | ///
20 | ///
21 | /// The version.
22 | /// An IntPtr.
23 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
24 | internal static extern IntPtr MagickGetVersion(out IntPtr version);
25 |
26 | /// Query if this object is magick wand instantiated.
27 | ///
28 | /// MagickExport MagickBooleanType IsMagickWandInstantiated(void)
29 | ///
30 | ///
31 | /// true if magick wand instantiated, false if not.
32 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
33 | internal static extern bool IsMagickWandInstantiated();
34 |
35 | /// Query if 'wand' is magick wand.
36 | /// The wand.
37 | /// true if magick wand, false if not.
38 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
39 | private static extern bool IsMagickWand(IntPtr wand);
40 |
41 | #endregion
42 |
43 | #region [Wand Methods]
44 |
45 | /// Magick wand genesis.
46 | ///
47 | /// WandExport void MagickWandGenesis(void)
48 | ///
49 | ///
50 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
51 | internal static extern void MagickWandGenesis();
52 |
53 | /// Magick wand terminus.
54 | ///
55 | /// WandExport void MagickWandTerminus(void)
56 | ///
57 | ///
58 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
59 | internal static extern void MagickWandTerminus();
60 |
61 | /// Magick command genesis.
62 | /// Information describing the image.
63 | /// The command.
64 | /// The argc.
65 | /// The argv.
66 | /// The metadata.
67 | /// The exception.
68 | /// true if it succeeds, false if it fails.
69 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
70 | private static extern bool MagickCommandGenesis(IntPtr image_info, MagickCommandType command, int argc, string[] argv, byte[] metadata, ref IntPtr exception);
71 |
72 | /// Magick command genesis.
73 | /// Information describing the image.
74 | /// The command.
75 | /// The argc.
76 | /// The argv.
77 | /// true if it succeeds, false if it fails.
78 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
79 | private static extern bool MagickCommandGenesis(IntPtr image_info, MagickCommandType command, int argc, string[] argv);
80 |
81 | /// Magick query formats.
82 | ///
83 | /// WandExport char **MagickQueryFormats(const char *pattern,size_t *number_formats)\
84 |
85 | ///
86 | ///
87 | /// Specifies the pattern.
88 | /// Number of formats.
89 | /// An IntPtr.
90 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
91 | internal static extern IntPtr MagickQueryFormats(
92 | [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))] string pattern, ref IntPtr number_formats);
93 |
94 | /// Magick query fonts.
95 | /// Specifies the pattern.
96 | /// Number of formats.
97 | /// An IntPtr.
98 | [DllImport(Constants.WandLibrary, CallingConvention = Constants.WandCallingConvention)]
99 | private static extern IntPtr MagickQueryFonts(IntPtr pattern, ref int number_formats);
100 | #endregion
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/ImageMagickSharp/Wand/WandNativeString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace ImageMagickSharp
8 | {
9 | /// A wand native string.
10 | ///
11 | internal static class WandNativeString
12 | {
13 | #region [Methods]
14 |
15 | /// Loads.
16 | /// The pointer.
17 | /// true to relinquish.
18 | /// A string.
19 | internal static string Load(IntPtr pointer, bool relinquish = true)
20 | {
21 | List bytes = new List();
22 | byte[] buf = new byte[1];
23 | int index = 0;
24 | while (true)
25 | {
26 | Marshal.Copy(pointer + index, buf, 0, 1);
27 | if (buf[0] == 0)
28 | {
29 | break;
30 | }
31 | bytes.Add(buf[0]);
32 | ++index;
33 | }
34 | if (relinquish)
35 | {
36 | MagickWandInterop.MagickRelinquishMemory(pointer);
37 | }
38 | return Encoding.UTF8.GetString(bytes.ToArray());
39 | }
40 |
41 | #endregion
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Media Browser
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/Nuget/ImageMagickSharp.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ImageMagickSharp
5 | 1.0.0.20
6 | ImageMagickSharp
7 | Emby Team
8 | ebr,Luke,scottisafool
9 | https://github.com/MediaBrowser/ImageMagickSharp
10 | http://www.mb3admin.com/images/mb3icons1-1.png
11 | false
12 | A managed wrapper for ImageMagick that is designed for Mono use.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ImageMagickSharp
2 | ================
3 |
4 | This is a managed wrapper for ImageMagick that is designed for use with Mono.
5 |
6 | Documentation to come, for now see the unit test project for example usage.
7 |
8 |
9 | ## Available on Nuget ##
10 |
11 | https://www.nuget.org/packages/ImageMagickSharp
12 |
13 |
14 | ## Usage
15 |
16 | This is purely a managed wrapper for ImageMagick and does not include any native assemblies. It will be up to you to provide the native assemblies for the target operating system.
17 |
18 | If your application is embedding ImageMagick, you'll need to call Wand.SetMagickCoderModulePath to set the path to the delegate iibraries. If you're utilizing the installed version this won't be necessary.
19 |
20 | For mono use you'll also need to create an ImageMagickSharp.dll.config file. An example might look like
21 |
22 | ```xml
23 |
24 |
25 |
26 | ```
27 |
--------------------------------------------------------------------------------