private void UpdateScreenImage(Bitmap hBitmap) { // Do not change the state control during application closing. if (m_bExit) { return; } if (ImageClient.Dispatcher.Thread == Thread.CurrentThread) { MemoryStream ms = new MemoryStream(); hBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); BitmapImage image = new BitmapImage(); image.BeginInit(); ms.Seek(0, SeekOrigin.Begin); image.StreamSource = ms; image.EndInit(); ImageClient.Source = image; } else { SetImageCallback d = new SetImageCallback(this.UpdateScreenImage); ImageClient.Dispatcher.Invoke(d, new object[] { hBitmap }); } }
/// <summary> /// Sets new output image (async support). /// Not used yet. /// </summary> private void SetImage(Bitmap newImage) { if (pictureBoxMain.InvokeRequired) { SetImageCallback si = new SetImageCallback(SetImage); BeginInvoke(si, new object[] { newImage }); } else { lock (runLock) { // Finishing phase after a module has recomputed the output image. setImage(ref outputImage, newImage); checkBoxResult.Checked = newImage != null; setSaveButton(); // Display input or output image. displayImage(); // !!! TODO: this value could be set to Color.White or ColorBlack // for transparent images. Reflect it in API ??? pictureBoxMain.BackColor = BackColor; // Reset the 'running' item. running = null; setRecomputeGui(); } } }
/// <summary> /// Updates the active thumbnail image to the fingerprint template image gotten from capture /// </summary> /// <param name="hBitmap"></param> private void UpdateScreenImage(Bitmap hBitmap) { // Converting passed Bitmap to BitmapImage BitmapImage img = hBitmap.ToBitmapImage(); if (_activeImage == null || img == null) { return; } if (!Dispatcher.CheckAccess()) { var d = new SetImageCallback(UpdateScreenImage); Dispatcher.BeginInvoke(d, hBitmap); } else { // Change image source within active button to the generated template _activeImage.Source = img; // Change image source within active button to the generated template ThumbnailLarge.Height = 300; // Change image source of ThumbnailLarge UI Control to the generated template ThumbnailLarge.Source = img; } }
private void SetImage(Image img) { if (this.objectListView1.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, img); } else { var destRect = new Rectangle(0, 0, 40, 40); var destImage = new Bitmap(200, 200); destImage.SetResolution(img.HorizontalResolution, img.VerticalResolution); using (var graphics = Graphics.FromImage(destImage)) { graphics.CompositingMode = CompositingMode.SourceCopy; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; using (var wrapMode = new ImageAttributes()) { wrapMode.SetWrapMode(WrapMode.TileFlipXY); graphics.DrawImage(img, destRect, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, wrapMode); } Chat obj = new Chat("Hai inviato:", destImage); objectListView1.AddObject(obj); objectListView1.SelectedIndex = index; //objectListView1.FocusedItem = objectListView1.SelectedItems[0]; objectListView1.Select(); objectListView1.RowHeight = 40; objectListView1.Refresh(); //index++; } //Chat obj = new Chat("Hai inviato:", img); //objectListView1.AddObject(obj); //objectListView1.RowHeight = 256; //Saving image in a folder try { Bitmap b = new Bitmap(img); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Immagini\"); String percorso = path + "Image" + i + ".jpg"; b.Save(percorso, System.Drawing.Imaging.ImageFormat.Jpeg); i++; Console.WriteLine("immagine scritta" + path); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { try{ ImageSourceConverter isc = new ImageSourceConverter(); string strDir = @"C:\ProgramData\MyIPWebcamTimeLapse\MyIPWebcamTimeLapse\1.0.0.4\192.168.1.13\20130311\"; Action act = new Action(() => { try { foreach (string fil in System.IO.Directory.EnumerateFiles(strDir)) { if (!liss.ContainsKey(fil)) { ImageSource iss = isc.ConvertFromString(fil) as ImageSource; liss.Add(fil, iss); } } } catch (Exception ec) { string sdsldkfjsldkjf = ec.Message; } }); act.Invoke(); int i = 0; TimerCallback tc = new TimerCallback((a) => { act.Invoke(); try { SetImageCallback d = new SetImageCallback((ims, _i) => { image1.Source = ims; this.Title = _i + "." + System.DateTime.Now.ToString("HH:mm:ss"); }); this.Dispatcher.Invoke(d, liss.Select(x => x.Value).ToArray()[i], i); } catch (Exception ex) { string s = ex.Message; } i++; if (i == liss.Count) { i = 1; } }); System.Threading.Timer tim = new Timer(tc, null, 0, 50); } catch (Exception ec) { string sdsldkfjsldkjf = ec.Message; } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { try{ ImageSourceConverter isc = new ImageSourceConverter(); string strDir = @"C:\ProgramData\MyIPWebcamTimeLapse\MyIPWebcamTimeLapse\1.0.0.4\192.168.1.13\20130311\"; Action act = new Action(() => { try { foreach (string fil in System.IO.Directory.EnumerateFiles(strDir)) { if (!liss.ContainsKey(fil)) { ImageSource iss = isc.ConvertFromString(fil) as ImageSource; liss.Add(fil, iss); } } } catch (Exception ec) { string sdsldkfjsldkjf = ec.Message; } }); act.Invoke(); int i = 0; TimerCallback tc = new TimerCallback((a) => { act.Invoke(); try { SetImageCallback d = new SetImageCallback((ims,_i)=>{ image1.Source = ims; this.Title =_i+"."+ System.DateTime.Now.ToString("HH:mm:ss"); }); this.Dispatcher.Invoke(d,liss.Select(x => x.Value).ToArray()[i],i); } catch (Exception ex) { string s = ex.Message; } i++; if(i == liss.Count) i=1; }); System.Threading.Timer tim = new Timer(tc,null,0,50); } catch (Exception ec) { string sdsldkfjsldkjf = ec.Message; } }
private void SetImage(Image img, PictureBox pb) { if (pb.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { img, pb }); } else { pb.Image = img; } }
private void SetImage(Bitmap bitmap) { if (this.pictureBoxIpl1.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); pictureBoxIpl1.Invoke(d, new object[] { bitmap }); } else { pictureBoxIpl1.Image = bitmap; } }
private void SetOff() { if (picture.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetOff); picture.Parent.Invoke(d); } else { picture.Image = Properties.Resources.checkMarkRed; } }
//to make calls threadsafe public void setImage(PictureBox location, Image pic) { if (location.InvokeRequired) { SetImageCallback call = new SetImageCallback(setImage); this.Invoke(call, new object[] { location, pic }); } else { location.Image = pic; } }
public static void SetImage(Form form, PictureBox ctrl, Bitmap source) { if (ctrl.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); form.Invoke(d, new object[] { form, ctrl, source }); } else { ctrl.Image = source; } }
//PictureBox에 그림을 변경하기 위함 private void SetImage(PictureBox control, Bitmap bitmap) { if (control.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { control, bitmap }); } else { control.Image = bitmap; } }
public static void SetImage(Form form, Button ctrl, Bitmap image) { if (ctrl.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); form.Invoke(d, new object[] { form, ctrl, image }); } else { ctrl.Image = image; } }
private void SetImage(Image aPicture) { if (this.pictureBox1.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { aPicture }); } else { this.viewPort.Image = (Bitmap)aPicture; } }
private void SetImage(Image aPicture) { if (this.pictureBox1.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { aPicture }); } else { this.viewPort.Image = (Bitmap)aPicture; } }
private void SetOff() { if (picture.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetOff); picture.Parent.Invoke(d); } else { picture.Image = Properties.Resources.checkMarkRed; } }
private void putImage(Image image) { if (this.InvokeRequired) { SetImageCallback d = new SetImageCallback(putImage); this.Invoke(d, new object[] { image }); } else { panel2.BackgroundImage = image; } }
public void SetImage(Bitmap newImage) { if (pictureBox1.InvokeRequired) { SetImageCallback si = new SetImageCallback(SetImage); BeginInvoke(si, new object[] { newImage }); } else { setImage(ref outputImage, newImage); } }
protected void SetImage(Bitmap newImage) { if (pictureBox1.InvokeRequired) { SetImageCallback si = new SetImageCallback(SetImage); BeginInvoke(si, new object[] { newImage }); } else { pictureBox1.Image = newImage; pictureBox1.Invalidate(); } }
private void SetImage(Point p) { if (this.picBox.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); picBox.Invoke(d, new object[] { Model.Position }); } else { ChangePicture(); this.picBox.Location = p; } }
public void SetOff(PictureBox pb) { if (pb.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetOff); pb.Parent.Invoke(d, new object[] { pb }); } else { if (_green != null) pb.Image = _red; } }
private void setImage(Bitmap bm) { if (this.pictureBox1.InvokeRequired) { SetImageCallback sic = new SetImageCallback(setImage); this.Invoke(sic, new object[] { bm }); } else { pictureBox1.Image = bm; pictureBox1.Refresh(); } }
protected void SetImage(Bitmap newImage) { if (pictureBox1.InvokeRequired) { SetImageCallback si = new SetImageCallback(SetImage); BeginInvoke(si, new object[] { newImage }); } else { pictureBox1.Image = newImage; pictureBox1.BackColor = imageBoxBackground; setImage(ref outputImage, newImage); } }
protected void SetImage( Bitmap newImage ) { if ( pictureBox1.InvokeRequired ) { SetImageCallback si = new SetImageCallback( SetImage ); BeginInvoke( si, new object[] { newImage } ); } else if ( checkShow.Checked ) { pictureBox1.Image = newImage; pictureBox1.Invalidate(); } }
public static void SetImage(Form form, PictureBox control, Image image) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (control.InvokeRequired) { var setImageCallback = new SetImageCallback(SetImage); form.Invoke(setImageCallback, form, control, image); } else { control.Image = image; } }
public void SetOff(PictureBox pb) { if (pb.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetOff); pb.Parent.Invoke(d, new object[] { pb }); } else { if (_green != null) { pb.Image = _red; } } }
private void SetAltPic(Image img) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.pictureBox2.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetAltPic); this.Invoke(d, new object[] { img }); } else { this.pictureBox2.Image = img; } }
private void imagereload(Image img) { //text = text.Remove(text.Length); if (this.pictureBox1.InvokeRequired) { if (!this.pictureBox1.IsDisposed) { SetImageCallback d = new SetImageCallback(imagereload); this.Invoke(d, new object[] { img }); } } else { this.pictureBox1.Image = img; } }
private void setImage(Bitmap bmp) { try { if (this.display.InvokeRequired) { SetImageCallback sic = new SetImageCallback(setImage); this.Invoke(sic, new object[] { bmp }); } else { this.display.Image = bmp; } } catch { } }
private void SetImage(int i) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.pictureBox1.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { i }); } else { currentFileName = listFiles.Values[i]; this.pictureBox1.Image = Image.FromFile(currentFileName); } }
private void UpdateScreenImage(Bitmap hBitmap) { if (hBitmap is null) { throw new ArgumentNullException(nameof(hBitmap)); } // Do not change the state control during application closing. if (m_bExit) { return; } //if (PictureFingerPrint.InvokeRequired) //{ SetImageCallback d = new SetImageCallback(this.UpdateScreenImage); d.Invoke(hBitmap); // this.Invoke(d, new object[] { hBitmap }); //} //else //{ // PictureFingerPrint.Image = hBitmap; //} }
private void SetImage(string file) { if (pictureBoxImage.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { file }); } else { pictureBoxImage.Image = Image.FromFile(file); // int scaledWidth = Convert.ToInt32(Height / (float)pictureBoxImage.Image.Height * Width); int scaledWidth = Convert.ToInt32(pictureBoxImage.Image.Width * Height / (float)pictureBoxImage.Image.Height); pictureBoxImage.Location = new Point((Width - scaledWidth) / 2, 0); pictureBoxImage.Size = new Size(scaledWidth, Height); } }
private void SetImage(PictureBox picBox, Image image) { if (picBox.InvokeRequired) { SetImageCallback d = new SetImageCallback(SetImage); this.Invoke(d, new object[] { picBox, image }); } else { picBox.Image = image; } }