Click here to Skip to main content
12,255,440 members (51,680 online)

Warning message "vshost.exe has stopped working"

gunkrr asked:

Open original thread
I have a problem with vshost.exe. At the beginning of my using this code, the program runs properly, but after I copy the program, now comes a warning like this: vshost.exe has stopped working
What makes this happen? code as follows:

YIQprocess2 YIQ2 = new YIQprocess2();
YIQ2.Image = EditImage;
YIQ2.YIQmethod2();
//this.Invalidate();
cetakgambar();

This is my class :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
 
namespace SkinCancerR01.BusinessRule
{
    public class YIQprocess2
    {
        public Bitmap Image { get; set; }
        public int seed, t, nilaikecil, nilaibesar, sementara;
 
        public void YIQmethod2()
        {
            Bitmap EditImage = this.Image;
            // GDI+ still lies to us - the return format is BGR, NOT RGB.
            BitmapData bmData = EditImage.LockBits(new Rectangle(0, 0, EditImage.Width, EditImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
 
            int stride = bmData.Stride;
            System.IntPtr Scan0 = bmData.Scan0;
 
            unsafe
            {
                byte* p = (byte*)(void*)Scan0;
 
                int nOffset = stride - EditImage.Width * 3;
 
                byte red, green, blue, Yx, Ix, Qx;
 
                for (int y = 0; y < EditImage.Height; ++y)
                {
                    for (int x = 0; x < EditImage.Width; ++x)
                    {
                        blue = p[x];
                        green = p[x + 1];
                        red = p[x + 2];
                        Yx = (byte)(.299 * red + .587 * green + .114 * blue);
                        Ix = (byte)(.596 * red - .275 * green - .321 * blue);
                        Qx = (byte)(.212 * red - .528 * green + .311 * blue);
 
                        if ((y == 0) && (x == 0))
                        {
                            nilaikecil = Yx;
                            nilaibesar = Yx;
                        }
                        else
                        {
                            if (Yx < nilaikecil)
                            {
                                nilaikecil = Yx;
                            }
                            else if (Yx > nilaibesar)
                            {
                                nilaibesar = Yx;
                            }
                        }
                        p += 3;
                    }
                    p += nOffset;
                }
            }
 
            t = (nilaibesar - nilaikecil) / 3;
 
            unsafe
            {
                byte* p = (byte*)(void*)Scan0;
 
                int nOffset = stride - EditImage.Width * 3;
 
                byte red, green, blue, Yx, Ix, Qx;
 
                for (int y = 0; y < EditImage.Height; ++y)
                {
                    for (int x = 0; x < EditImage.Width; ++x)
                    {
                        blue = p[x];
                        green = p[x + 1];
                        red = p[x + 2];
                        Yx = (byte)(.299 * red + .587 * green + .114 * blue);
                        Ix = (byte)(.596 * red - .275 * green - .321 * blue);
                        Qx = (byte)(.212 * red - .528 * green + .311 * blue);
 
                        //supaya setiap y baru seed juga baru
                        if ((x == 0) || (seed == 0))
                        {
                            //mengambil value seed
                            seed = Yx;
                        }
                        else
                        {
                            sementara = Yx - seed;
                            sementara = Math.Abs(sementara);
                            if (sementara >= t)
                            {
                                for (int i = 0; i < 2; ++i)
                                {
                                    p[x] = p[x + 1] = p[x + 2] = 255;
                                    ++x;
                                }
 
                                seed = 0;
                            }
                        }
 
                        p += 3;
                    }
                    p += nOffset;
                }
            }
 
            EditImage.UnlockBits(bmData);
        }
    }
}
Tags: C#

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100