Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 22nd, 2006, 04:37 AM
Authorized User
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default Generic Error occured in GDI+


I want to do image processing with real-time image and I’m using C#. I got to grab the image from webcam and it runs smoothly. However, I got some error when I attach with other code for image processing. I cannot run more than one time in one execution debugging.
It gives exception: “Could not grab picture. A generic error occurred in GDI+.”

I just attach one class library to do threshold process for color image that I grabbed.

This is the original class to grab the image:

toolBarBtnGrab.Enabled = true;
            int hr;
            if( sampGrabber == null )
            hr = sampGrabber.SetCallback( null, 0 );

            int w = videoInfoHeader.BmiHeader.Width;
            int h = videoInfoHeader.BmiHeader.Height;
            int stride = w * 3;

            GCHandle handle = GCHandle.Alloc( savedArray, GCHandleType.Pinned );
            int scan0 = (int) handle.AddrOfPinnedObject();
            scan0 += (h - 1) * stride;
            Bitmap b = new Bitmap( w, h, -stride, PixelFormat.Format24bppRgb, (IntPtr) scan0 );
            savedArray = null;
            Image old = pictureBox.Image;
            pictureBox.Image = b;

and below is the code that I added after the last line of above code to call class library for threshold the image that was grabbed by above code:


pictureBox.Image.Save("1stImage.Jpeg", ImageFormat.Jpeg);

            Bitmap bp = new Bitmap("1stImage.Jpeg");
            ClassLibrary1.Class1 filter = new ClassLibrary1.Class1();
            System.Drawing.Bitmap binary = filter.Binary(bp);

            picClass1.Image = binary;
            picClass1.Image.Save("Binary.Jpeg", ImageFormat.Jpeg);
            picClass1.Width = binary.Width;
            picClass1.Height = binary.Height;
Could any body help me please to overcome this problem. Thanks.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop capturing image and generic error occured in labby C# 2005 0 December 22nd, 2006 02:55 AM
Generic error occured in GDI+ labby C# 0 December 19th, 2006 09:57 AM
A unidentified error has occured. malachany Dreamweaver (all versions) 6 February 4th, 2005 10:31 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.