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

New Post: StackOverflowException

$
0
0
Hello, great product, thanks for it. I had to develop c# application using MagickImage. Application shows picture in winforms picturebox. Also there is a listbox in a form with images fileinfos, holded in current folder. All images are the same type, tipycally b/w 16bpp pgm. The images are quit small - 300-800px square and were captured by a b/w video camera.
The common situation is when there are thowsands of images in the list. Choosing the next file in list changes the image in picturebox. So, if I press and hold keyboard arrow button, the image in list and picturebox image changes very quickly, like in a movie. When hundreds of images are passed, MagickImage crashes with StackOverflowException. If I list some images and pause for a little, everythig works fine.
Any try catch blocks don't help. You can see this behavior in my application PGMania http://sourceforge.net/projects/pgmania/

Test files can be downloaded here https://yadi.sk/d/mjuOEKr4eGE69

A piece of code I used:

private void ShowImageFile(string fileName)
    {
            byte[] data = File.ReadAllBytes(fileName);
            using (MagickImage image = new MagickImage(data))
            {
                ColorSpace originalColorSpace = image.ColorSpace;
                format = originalColorSpace.ToString();
                bitDepth = image.BitDepth();
                pictureBox.Image = null;
                GC.Collect();     
                try
                {
                    panel1.AutoScroll = false;
                    pictureBox.Dock = DockStyle.Fill;
                    pictureBox.SizeMode = PictureBoxSizeMode.Zoom;

                    Bitmap bm = new Bitmap(image.ToBitmap());
                    pictureBox.Image = bm;

                    pictureBox.Height = pictureBox.Image.Height;
                    pictureBox.Width = pictureBox.Image.Width;

                    ColorSpace transformedColorSpace = image.ColorSpace;

                    double windowZoom = (double)pictureBox.Width / image.Width;
                    windowZoom = Math.Round(windowZoom * 100, 0);
                    GC.AddMemoryPressure(data.Length);
                }
                catch
                {
                }
            }
    }

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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