picturebox

The dispose of an OpenFileDialog in C#?

北城以北 提交于 2019-12-11 07:54:13
问题 I have searched throughout entire Stack Overflow, but I couldn't find an answer to the following: When I'm using my OpenFileDialog, the files I open get blocked for use out of my program until I close my program. So if I open an image, I am not allowed to replace that image in my Windows Explorer anymore. I think this is a problem with disposing my OpenFileDialog, but I'm not sure how to solve it... My code: using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Title = "Open Image"; ofd

Render 16 bits image in picturebox

怎甘沉沦 提交于 2019-12-11 07:54:00
问题 I have an array which consists in PixelData extracted from a Dicom Image. Here's the code: byte[] bytes = img.PixelData.GetFrame(0).Data; // img is the Dicom Image int count = bytes.Length / 2; ushort[] words = new ushort[count]; for (int i = 0, p = 0; i < count; i++, p += 2) { words[i] = BitConverter.ToUInt16(bytes, p); } pixels16 = words.ToList(); //pixels16 contains now the PixelData for the Grayscale image Now, here's my question, how do I render that into a Picturebox?? 回答1: My code for

PictureBox to Bitmap or Image?

坚强是说给别人听的谎言 提交于 2019-12-11 06:46:30
问题 I am trying to change the code http://sites.google.com/site/webcamlibrarydotnet/winfrom-and-csharp-sample-code-and-download from picture box to image or bitmap as I dont want to display any image or plan to display, all I want is that it will output the image to file. I have tried changing the webcam.cs from PictureBox _FrameImage to Bitmap _FrameImage and PictureBox ImageControl to Bitmap ImageControl and casting (Bitmap) at e.WebCamImage As well as changing it on the main form: private void

Get a image in data gridview to picturebox in c#

混江龙づ霸主 提交于 2019-12-11 06:45:54
问题 I need to get an image in data gridview to picturebox in c# This is my datagridview cord. if (e.RowIndex >= 0) { DataGridViewRow row = this.dataGridView3.Rows[e.RowIndex]; e_id.Text = row.Cells["emp_id"].Value.ToString(); e_Fname.Text = row.Cells["emp_Fname"].Value.ToString(); e_Lname.Text = row.Cells["emp_Lname"].Value.ToString(); } I need to click a row in datagridview then load image in picturebox. 回答1: Surprisingly but NOBODY above provided the correct answer. The request above was: "I

Visual studio image loading in for cycle from resources

Deadly 提交于 2019-12-11 06:40:56
问题 In my image resources I have pictures with following names: c1.png, c2.png, c3.png, ... Whereas referring to the first image works with My.Resources.c1 I would like to display them in the cycle like this For i = 1 To numberOfPictures Dim tmpPicture As New PictureBox tmpPicture.Image = cstr(My.Resources.c) & cstr(i) & ".png" next Now this of course doesn't work, because string cannot be converted to System.Drawing.Image. Any ideas how to solve this? I know it's really easy in VB where I did it

c# save System.Drawing.Graphics to file

社会主义新天地 提交于 2019-12-11 06:21:39
问题 I have a System.Drawing.Graphics took from a picturebox. basically I draw some lines over a background image stored into the picturebox now I wish save a png that contains the background image and everything is drawn over there... is there a way to do this? thanks in advance 回答1: If you are drawing these lines on the Paint event then you need to create a BitMap with the BackgroundImage and call your paint function with the Bitmap's Graphics, and then call Bitmap.Save(). Bitmap bmp = new

Picture Control background is gray and I want it white

浪子不回头ぞ 提交于 2019-12-11 04:54:37
问题 My application has a picture control, whose background is gray and I want it to be white. I already tried several things, like: derive a class and override OnPaint method; respond to WM_CTLCOLOR message (adding ON_WM_CTLCOLOR() and processing it), but no success. Entry on Message map: ON_WM_CTLCOLOR() Implementation: BOOL CMyDialog::OnInitDialog() { __super::OnInitDialog(); white.CreateSolidBrush(RGB(255,255,255)); //... return TRUE; // return TRUE unless you set the focus to a control }

C# Windows Forms. Moveable areas on the PictureBox

瘦欲@ 提交于 2019-12-11 04:45:59
问题 I'm working with images like: http://imgur.com/a2VKb I've managed to find a vertical line between pages on scanned image. But sometimes there are some errors and I need to make an option for user to change this line position and angle. I think this would be nice within a PictureBox. I need somehow to draw a line between two movable points on a picturebox with current image. When I move a point, position of line and it's angle have to be changed properly. 回答1: Here is a sample code you can use

Setting a picture from my Resources programmatically to a PictureBox

这一生的挚爱 提交于 2019-12-11 03:29:46
问题 How can I set a picture to a PictureBox in code? The code below gives me the error: Cannot implicitly convert Bitmap to String. private void ptbLocalidadAdd_MouseEnter(object sender, EventArgs e) { ptbLocalidadAdd.ImageLocation = Properties.Resources.addg; } 回答1: If the resource is a bitmap, this should work: ptbLocalidadAdd.Image = Properties.Resources.addg; 来源: https://stackoverflow.com/questions/3845500/setting-a-picture-from-my-resources-programmatically-to-a-picturebox

Get bitmap from PictureBox - new instance of an object

半腔热情 提交于 2019-12-11 02:17:09
问题 I have a "flawless" working code for putting a part of screen into square PictureBox. I have a "flawless" working code for drawing on the picturebox with a pen. I totally fail to understand, why I cannot get the pen draw on the bitmap in the PictureBox - it only draws on grey background. The solution (also as per google) is seemingly simple, but ANY way to attempt to get gg graphics from PictureBox.Image results in ("An error occurred creating the form. See Exception.InnerException for