Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: System.AccessViolationException when combining two images

$
0
0
I am using the Q16-x64 nuget package.

I am trying to overlay one image on top of another image.
(I am printing out checks and need to take the check detail and be able to print it over top of a few different styles of check stock).

Here is some test code I wrote that causes the error:
 using (var collection = new MagickImageCollection())
            {
                var settingsBottom = new MagickReadSettings();
                var settingsTop = new MagickReadSettings();;

                using (MagickImage bottomLayer = new MagickImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "checkStock.gif"), settingsBottom),
                                      topLayer = new MagickImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "1.png"), settingsTop))
                {
                    collection.Add(bottomLayer);
                    // replace white with transparency
                    topLayer.Transparent(new MagickColor("#FFFFFF"));
                    topLayer.Lower(2);
                    collection.Add(topLayer);

                    var finalImage = collection.Mosaic(); 

                    finalImage.Write(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output.png"));
                }
            }
On the line
var finalImage = collection.Mosaic(); 
I receive the error:
System.AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Stack Trace:
at std.list<Magick::Image,std::allocator<Magick::Image> >.clear(list<Magick::Image\,std::allocator<Magick::Image> > )
at ImageMagick.MagickImageCollection.Merge(Image
image, LayerMethod method)
at ImageMagick.MagickImageCollection.Mosaic()
at MagickTester.Program.Main(String[] args) in c:\Users\jeffn\Documents\Visual Studio 2013\Projects\MagickTest\MagickTester\Program.cs:line 41


The odd thing is, if I continue past the error, the code seems to still work. The image "output.png" is still created and the overlay functions correctly.

Any idea what is going on?

ps:
I would include the MagickNET Log output, but when I attempt to turn on the logging, I receive the error:
"System.TypeInitializationException"
"The type initializer for 'ImageMagick.MagickNET' threw an exception."
Stack Trace:
at Magick.EnableOpenCL(Boolean )
at ImageMagick.MagickNET.SetUseOpenCL(Boolean value)
at ImageMagick.MagickNET..cctor()

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>