picturebox

How to move PictureBox in C#?

空扰寡人 提交于 2019-12-06 06:16:01
问题 i have used this code to move picture box on the pictureBox_MouseMove event pictureBox.Location = new System.Drawing.Point(e.Location); but when i try to execute the picture box flickers and the exact position cannot be identified. can you guys help me with it. I want the picture box to be steady... 回答1: You want to move the control by the amount that the mouse moved: Point mousePos; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mousePos = e.Location; } private void

GIF Animation not working in Windows Form

一笑奈何 提交于 2019-12-06 04:38:18
问题 I have 2 WinForms Form2 uses Infragistics ultraTabControl. On Tab Changing im Showing Form1. In Form1 I have a PictureBox assigned with animated GIF In Form2 I am displaying Form1 like this. Form1 frmOne=new Form1(); frmOne.Show(); Problem GIF is not playing animation. 回答1: Make sure you have your image in the image property NOT THE BACKGROUND IMAGE PROPERTY . That's the mistake I made 回答2: It is working fine for me. I have just dragged a new pictureBox on form and setting image property at

Shuffle random picture from resources on button click

依然范特西╮ 提交于 2019-12-06 01:19:44
I have 1 picture box, named studPic . What I want to get is, when I click "shuffle" button, to get random image from resources. private void button2_Click(object sender, EventArgs e) { ... } After research I've found following http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/38d36fa4-1f5f-43e9-80f6-3c9a4edc7705/ I'm newbie to C#.. Is there easier way to achieve this result? For example, without adding picture names? UPDATE List<string> pictureNames = new List<string>(); pictureNames.Add("1"); pictureNames.Add("2"); pictureNames.Add("3"); int randomPictureIndex = new Random()

how to put an Iplimage on a picturebox?

大兔子大兔子 提交于 2019-12-05 21:06:50
Is there a way to show an IplImage in a picturebox? I'd like to not save the image and reload it into the picturebox since I need my program to be fast. I'm using opencv 2.1 in C++. I'm working with Visual Studio 2008. Thank you. This was already discussed here : IplImage* img=cvLoadImage("sample.jpg",3); // for example HDC hdc = picturebox.GetDC()->m_hDC; char m_chBmpBuf[2048]; BITMAPINFO *m_pBmpInfo =0; m_pBmpInfo = (BITMAPINFO *)m_chBmpBuf; m_pBmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); m_pBmpInfo->bmiHeader.biWidth = img->width; m_pBmpInfo->bmiHeader.biHeight = -img->height; m

Move PictureBox using Arrow Keys - Handle keyboard events in PictureBox

十年热恋 提交于 2019-12-05 21:01:13
I have a PictureBox where I use the code below to move my object. I need to add a few buttons in the form, however when I start the program the arrow keys navigate through the buttons instead of my input keypresses. I've tried many ways like PictureBox.Focus() and PictureBox.Select() on Form.Load() , and disabling the arrow key navigation completely on this answer here , but my object will not move anymore. private void UpdateScreen(object sender, EventArgs e) { if (Input.KeyPressed(Keys.Right) && Settings.direction != Direction.Left) { Settings.direction = Direction.Right; } else if (Input

Resize an image in a PictureBox to as large as it can go, while maintaining aspect ratio?

怎甘沉沦 提交于 2019-12-05 15:57:38
问题 I'm trying to make it so that an image in a PictureBox control will adjust its size automatically depending on the size of the window, but maintain the aspect ratio. So far just setting SizeMode to StretchImage causes the image to stretch to fit the entire PictureBox control. This ignores the aspect ratio, which isn't what I want. Is it possible to maintain the aspect ratio, but still stretch the image to the largest it can go dynamically as the form's size changes? Is it possible to do this

Can I create a transparent background on a PictureBox in WinForms?

不羁的心 提交于 2019-12-05 04:30:45
I want to make the background of a PictureBox control transparent. In the PictureBox (rectangular shape), I placed an icon (circular in shape). I want to make the icon transparent so that the other portion underneath the icon is visible. I have tried setting the PictureBox.BackColor property to "Transparent", but it doesn't work. I also tried to set it during runtime with the Color.FromArgb method, but it doesn't work either. Is there any solution to this problem? Setting pictureBox.BackColor = Color.Transparent; definitely should work. Also verify if you are setting alpha channel of color

Picture box to byte array

耗尽温柔 提交于 2019-12-05 00:51:40
问题 I have a program to select an image and to set that selected image in a picture box then convert the image in the image box to byte array and save sql server data base in a image type column. In browse button click event I'm selecting the image file like this. OpenFileDialog fop = new OpenFileDialog(); fop.InitialDirectory = @"Desktop"; fop.Filter = "image files|*.jpg;*.png;*.gif"; if (fop.ShowDialog() == DialogResult.OK) { FileStream FS = new FileStream(@fop.FileName, FileMode.Open,

Boost the Performance when Advancing to the Next Page Using .tif Images

倾然丶 夕夏残阳落幕 提交于 2019-12-05 00:11:32
问题 I'm using WinForms. In my forms I have an open and a next button. My application opens .tif images into a picturebox. All the .tif images I work with have multiple pages. The next button is for going to the next page in the tif image. These .tif images I work with are very large. Example: Dimensions: 2600 x 3300 ( .tif images) Question: How do I optimize the performance of my application? I've read/researched that I might have to load the images directly from the computers memory and some

How to draw an image onto a PictureBox Image [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-04 22:04:57
I need to know how to draw more than one Image on a PictureBox's Image. I have used this code but it doesn't work: private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox2.Image); Graphics g = Graphics.FromImage(bmp); g.DrawImage(new Bitmap(@"C:\Users\Mena\Desktop\1.png"), new Point(182, 213)); pictureBox2.Image = bmp; } With a few changes your code will work fine: private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox2.Image); // whatever your plans where, we don't know ;-) // RectangleF rectf = new RectangleF(640F,