picturebox

C# Threading Bitmap objects/PictureBox

烈酒焚心 提交于 2019-12-08 08:06:14
问题 I have some code to display video-like graphics of points moving around. I am writing the points to a bitmap, and placing it on a picturebox. The graphics computation has to be done on its own thread. The graphics work fine as long as you don't move the window around "too" much. I'm using winforms. When I run the code, and move the window around wildly, I SOMETIMES get the following errors: @ this.Invoke(d, new object[ ] { bmp }); "Cannot access a disposed object. Object name: 'Form1'." @ gfx

Paint Drawline Image into Picturebox Image

北战南征 提交于 2019-12-08 08:01:27
In my Form, I have 2 picturebox controls. I loaded a blue background image on pictureBox1 and left pictureBox2 control alone. With the code below I'm able to draw arrows on top of my picturebox1 image. Goal: On my pictureBox1_MouseUp event I want to add all the arrows which I drew on pictureBox1 to pictureBox2 . Issue: The problem is on my pictureBox1_MouseUp event when I wrote pictureBox2.Image = pictureBox1.Image it doesn't add the painted arrow which I drew on pictureBox1. It only adds the pictureBox1 image that I assigned in my form load event. private bool isMoving = false; private Point

Save Image in PictureBox with overlapping Controls

拟墨画扇 提交于 2019-12-08 07:50:29
问题 I am developing an application in which user can select an image in a picture box. After that he can right click on the image and add a user control which will again display an Image along with some text. This user control can be added any number of times. User can also re-position the user controls as per need. All this functionality has been implemented and is working fine. Now, the requirement is to save the Image along with the user control. Above you can see the complete image which

Accessing an image resource by name and assigning it to a PictureBox

本小妞迷上赌 提交于 2019-12-08 06:33:45
问题 I have this list: List<string> list = new List<string>(); list.Add("dog.jpg"); list.Add("cat.jpg"); list.Add("horse.jpg"); In my resources, I have 3 images named: dog, cat, and horse. I want to display them in a picture box using the list. I have tried something like this: pictureBox1.Image = project.Properties.Resources.list[2]; // should display the horse image The problem is that it displays the error: 'Resources' does not contain a definition for 'list' ` How can I get the image using the

Scale components in FlowLayout as big as possible

妖精的绣舞 提交于 2019-12-08 06:11:20
问题 How can I scale PictureBox components to best fit the given space on the screen while keeping their aspect ratio (interdependent of the actual image or its SizeMode) ? I tested setting the Dock of the FlowLayout and the PictureBox to Fill. I also tested using a Panel as a wrapper and tested different settings for AutoSize and AutoSizeMode. To give more information about the background: I want to dynamically add and remove images in the viewport of the application, so a TableLayout is in the

Paint Drawline Image into Picturebox Image

徘徊边缘 提交于 2019-12-08 05:45:03
问题 In my Form, I have 2 picturebox controls. I loaded a blue background image on pictureBox1 and left pictureBox2 control alone. With the code below I'm able to draw arrows on top of my picturebox1 image. Goal: On my pictureBox1_MouseUp event I want to add all the arrows which I drew on pictureBox1 to pictureBox2 . Issue: The problem is on my pictureBox1_MouseUp event when I wrote pictureBox2.Image = pictureBox1.Image it doesn't add the painted arrow which I drew on pictureBox1. It only adds the

Picture box transparency in vb

≡放荡痞女 提交于 2019-12-08 03:26:00
问题 When i run my code, the picture box has a background colour, even though I have set the background colour to transparent in the properties window. any ideas? 回答1: I assume you're overlapping a PictureBox over some other control and expecting to see through the PictureBox . That's not how it works - controls with transparent backgrounds are only transparent relative to their parent, not other controls. You could draw them using GDI+ by overriding the OnPaint method of your form: Private Shared

Windows Forms: How to directly bind a Bitmap to a PictureBox?

江枫思渺然 提交于 2019-12-08 01:41:21
问题 I'm just trying to build a small C# .Net 4.0 application using Windows Forms (WPF I don't know at all, Windows Forms at least a little :-) ). Is it possible to directly bind a System.Drawing.Bitmap object to the Image property of a PictureBox ? I tried to use PictureBox.DataBindings.Add(...) but this doesn't seem to work. How can I do this? Thanks and best regards, Oliver 回答1: This works for me: Bitmap bitmapFromFile = new Bitmap("C:\\temp\\test.bmp"); pictureBox1.Image = bitmapFromFile; or,

Simple and fast real-time graphics for C# computer game (WinForms)

落爺英雄遲暮 提交于 2019-12-07 23:57:34
I'm trying to make an integer array and Bitmap work in harmony as part of a C# winforms project for fast PictureBox editing (avoiding the slow SetPixel command). I added a Button and a PictureBox, a click event on the aformentioned Button and a closing event on the Form. The code for the Form is now like so: public partial class Form1 : Form { uint[] _Pixels { get; set; } Bitmap _Bitmap { get; set; } GCHandle _Handle { get; set; } IntPtr _Addr { get; set; } public Form1() { InitializeComponent(); int imageWidth = 100; //1920; int imageHeight = 100; // 1080; PixelFormat fmt = PixelFormat

C# Threading Bitmap objects/PictureBox

China☆狼群 提交于 2019-12-07 23:57:34
I have some code to display video-like graphics of points moving around. I am writing the points to a bitmap, and placing it on a picturebox. The graphics computation has to be done on its own thread. The graphics work fine as long as you don't move the window around "too" much. I'm using winforms. When I run the code, and move the window around wildly, I SOMETIMES get the following errors: @ this.Invoke(d, new object[ ] { bmp }); "Cannot access a disposed object. Object name: 'Form1'." @ gfx.DrawImage(bmpDestination, new Point()); "Object is currently in use elsewhere." Here is the code: