picturebox

c# Resize parent control when a child pictureBox changes the Image

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 01:47:00
问题 I have a UserControl that contains a PictureBox and a Label. The Control loads three different images in PictureBox on different events (fore example onMouseEnter, OnMouseLeave). As the images can have different sizes, I neet to resize the pictureBox and the control itself. Below is provided the control's OnPaint event but this does not work. protected override void OnPaint(PaintEventArgs pe) { if (pictureBox.Image != null) { this.Width = this.pictureBox.Image.Size.Width; this.Height = this

Sending PictureBox Contents to MsPaint

时光总嘲笑我的痴心妄想 提交于 2019-12-11 01:34:22
问题 How do i go about sending the contents of a picturebox to be edited in paint? I've thought of quickly saving it temporarily then sending the temp address to be loaded, but i'd think that would cause some minor saving issues. 回答1: Unfortunately I'm providing the answer in C# at this time. Luckily, just syntax and not content will have to change. Assuming this is your picturebox control, take the contents (as a bitmap) and put it on the clipboard. Now you can paste it into MSPaint however you'd

Load a picturebox from a WIA ImageFile?

左心房为你撑大大i 提交于 2019-12-10 23:43:50
问题 I've taken over a poorly designed project from a co-worker and am looking to load a picture box directly from the WIA command that just completed to take a picture from an attached USB camera. The current implementation waits until the file has been written to disk, then displays it from there probably re-reading the file from disk. Item item = d.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); WIA.ImageFile imagefile = item.Transfer(FormatID.wiaFormatJPEG) as WIA.ImageFile; I tried

How to stretch a Bitmap to fill a PictureBox

守給你的承諾、 提交于 2019-12-10 22:09:15
问题 I need to stretch various sized bitmaps to fill a PictureBox. PictureBoxSizeMode.StretchImage sort of does what I need but can't think of a way to properly add text or lines to the image using this method. The image below is a 5x5 pixel Bitmap stretched to a 380x150 PictureBox. pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.Image = bmp; I tried adapting this example and this example this way using (var bmp2 = new Bitmap(pictureBox.Width, pictureBox.Height)) using (var g =

How to select a region in a Windows Forms PictureBox?

百般思念 提交于 2019-12-10 20:50:08
问题 I want to get a part of picture in a PictureBox by allowing the user to select a rectangular region (similar to how it can be done in Photoshop with selection tool). How I can do this? 回答1: You would have to draw a rectangle or lines based on where they clicked and dragged. Your starting point would be the mouse x, y and then you would get the last point from mouse release x, y. 回答2: Catch the mouse events on the Picture Box to define your selection rectangle and use Graphics.DrawRectangle to

WinForms performance mystery: derived PictureBox control slower than the original?

流过昼夜 提交于 2019-12-10 18:25:22
问题 In my .NET 2.0 project, I made an empty derived class of System.Windows.Forms.PictureBox : public class NewPictureBox : PictureBox { //absolutely nothing } Then I did the following: set both the derived control's and the base control's Image property to a rather large image (800x600), SizeMode is Normal (only the upper-left portion is displayed); hooked up several of the NewPictureBox 's and PictureBox 's events so a selection box can be drawn when dragging the mouse on the surface; set it up

How to remove white background color from Bitmap

与世无争的帅哥 提交于 2019-12-10 16:29:13
问题 I want to remove the white background color in a bitmap Bitmap capcha = new Bitmap("C:/image.jpg"); pictureBox1.Image = capcha; but I want to display in my pictureBox1 just the image without white that exists in the background 回答1: try to set transparency in capcha like this: Bitmap capcha = new Bitmap(@"C:/image.jpg"); capcha.MakeTransparent(Color.White); pictureBox1.Image = capcha; I hope it is what u need. 来源: https://stackoverflow.com/questions/15375453/how-to-remove-white-background

Load picturebox image in C# from file in relative path

余生长醉 提交于 2019-12-10 14:32:55
问题 I have a picturebox image in a Windows Form Solution. After user selects an item from a database, I want to load an image into this picturebox. The filename of the image will come from the database and all images must be stored in a subfolder of the application folder (\Images). I don't want to include all these (2000-3000 images) in my solution, besides, more images will be added by users as the database grows. Also, I don't want to code an absolute path. So this is not what I want:

Clickable Image Map c#

 ̄綄美尐妖づ 提交于 2019-12-10 13:48:34
问题 I'm making a C# inventory application. However, I want there to be a map where the user can click several areas and interact with the inventory on that certain area. Currently I photoshopped the map and made it the background of the form. I'm planning on putting pictureboxes over the different areas and code manually the mouse over, click, and mouse down events to give the button appearance. Anyway, my question is, is this a good idea? Should I just load the map into a picturebox, get rid of

Load picture from FTP to PictureBox with WinSCP .NET assembly

前提是你 提交于 2019-12-10 12:33:33
问题 I am using WinSCP .NET assembly to transfer files by FTP. Couple days ago I developed new module to show pictures in PictureBox control. What I would like to achieve is to list picture's paths inside listbox or whatever else and then when click on this path to be able to open the picture in PictureBox . The point is pictures are on remote location on my FTP and I have no idea is it possible using WinSCP (FTP) to use get their path and then using the paths to show up given picture inside