save Bitmap from stream

Posts 14 of 4 · Page 1 of 1
save Bitmap from stream
hye everyone , i need some help where executing below codes result in crash (exception handler ).ive tried filewritepermission but failed.any suggestion ?

Code:
void CaptureTimer_Tick(object sender, EventArgs e)
        {
            CaptureTimer.Stop();
            Bitmap bitmapImage = new Bitmap((int)this.ActualWidth, (int)this.ActualHeight);
            Graphics gr1 = Graphics.FromImage(bitmapImage);
            IntPtr dc1 = gr1.GetHdc();
            IntPtr dc2 = NativeMethods.GetWindowDC(NativeMethods.GetForegroundWindow());
            NativeMethods.BitBlt(dc1, (int)20, (int)20, (int)this.ActualWidth, (int)this.ActualHeight, dc2, 20, 20, 13369376);
            gr1.ReleaseHdc(dc1);
            Random rnd = new Random();
            bitmapImage.Save(string.Format(".\\Captures\\Capture{0}.jpg", rnd.Next().ToString()), ImageFormat.Jpeg);
            PlaySoundOnButton(ButtonTypes.CaptureBtn);
            CommandManager.InvalidateRequerySuggested();
        }
Could you please provide more details about that crash?
stacktrace etc.
Just debug the code and see what the exception says..
Posts 14 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?