Click here to Skip to main content
15,905,316 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Insert Into WebServer Using WCF Pin
Eddy Vluggen7-Sep-15 23:58
professionalEddy Vluggen7-Sep-15 23:58 
QuestionFormatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 3:52
Ashfaque Hussain7-Sep-15 3:52 
AnswerRe: Formatting the RDL report tablix Pin
Afzaal Ahmad Zeeshan7-Sep-15 9:32
professionalAfzaal Ahmad Zeeshan7-Sep-15 9:32 
GeneralRe: Formatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 21:00
Ashfaque Hussain7-Sep-15 21:00 
QuestionCapturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 17:35
Sultan Uz Zaman6-Sep-15 17:35 
AnswerRe: Capturing from Webcam without preview to the user Pin
Wendelius6-Sep-15 17:43
mentorWendelius6-Sep-15 17:43 
AnswerRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 21:30
mveRichard MacCutchan6-Sep-15 21:30 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:13
Sultan Uz Zaman6-Sep-15 22:13 
GeneralRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 22:34
mveRichard MacCutchan6-Sep-15 22:34 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:43
Sultan Uz Zaman6-Sep-15 22:43 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:11
mvePete O'Hanlon6-Sep-15 23:11 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:15
Sultan Uz Zaman6-Sep-15 23:15 
GeneralRe: Capturing from Webcam without preview to the user Pin
Eddy Vluggen6-Sep-15 23:18
professionalEddy Vluggen6-Sep-15 23:18 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:26
Sultan Uz Zaman6-Sep-15 23:26 
GeneralRe: Capturing from Webcam without preview to the user Pin
Paul Conrad7-Sep-15 7:21
professionalPaul Conrad7-Sep-15 7:21 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:23
mvePete O'Hanlon6-Sep-15 23:23 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:32
Sultan Uz Zaman6-Sep-15 23:32 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:37
mvePete O'Hanlon6-Sep-15 23:37 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:47
Sultan Uz Zaman6-Sep-15 23:47 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon7-Sep-15 0:12
mvePete O'Hanlon7-Sep-15 0:12 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman7-Sep-15 4:43
Sultan Uz Zaman7-Sep-15 4:43 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:38
Sultan Uz Zaman6-Sep-15 23:38 
Please find below the extarct of my application where the stream is stored in an image control named frameHolder and function SavePic grabs the current frame and save it to disk. frameHolder is shown on the Main Window. Making it invisible captures blank picture.

MainWindow.xaml.cs

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
LoaclWebCamsCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
LocalWebCam = new VideoCaptureDevice(LoaclWebCamsCollection[0].MonikerString);
LocalWebCam.DesiredFrameSize = new System.Drawing.Size(320, 240);

//MessageBox.Show(LocalWebCam.DesiredFrameSize.ToString());
LocalWebCam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);

LocalWebCam.Start();


}

void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
BitmapImage bi = new BitmapImage();
try
{
img = (Bitmap)eventArgs.Frame.Clone();

MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);


bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();

bi.Freeze();
Dispatcher.BeginInvoke(new ThreadStart(delegate
{
frameHolder.Source = bi;
}));

}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "NW CDM Test of Image Capture Failed");
}
}
Sultan Uz Zaman at 4 hrs ago
Reply Modify the comment. Delete the comment.
A button click event does the follwoing to save the pic:

public static void SavePic(string imageFile)
{
//Cam_NewFrame(null,null);
//image1.Source = frameHolder.Source;
//Image frame = frameHolder.Cam_NewFrame(null,null);
// Release any previous buffer


MainWindow myWin = Application.Current.MainWindow as MainWindow;
RenderTargetBitmap bitmap = new RenderTargetBitmap(320, 240, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(myWin.frameHolder);


using (FileStream stream = File.Create(Global.xImageLocation+"\\"+imageFile)) // or .png
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.QualityLevel = 90;
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(stream);
}
}
QuestionRe: Capturing from Webcam without preview to the user Pin
Paul Conrad7-Sep-15 7:19
professionalPaul Conrad7-Sep-15 7:19 
Questionsystem.drawing.image.fromstream ......... Pin
Member 119583516-Sep-15 9:08
Member 119583516-Sep-15 9:08 
AnswerRe: system.drawing.image.fromstream ......... Pin
Pete O'Hanlon6-Sep-15 10:32
mvePete O'Hanlon6-Sep-15 10:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.