Questions tagged [picturebox]

The PictureBox is a control in the Windows Forms system that provides a way to display an image. It can handle many different image formats.

Summary

The PictureBox control provides a way to display images in a window constructed using the Windows Forms GUI framework. Like all other built-in controls, it inherits from System.Windows.Forms.Control and resides in the System.Windows.Forms namespace.

Important properties

In addition to all of the regular Control properties it inherits, the PictureBox also has a couple additional properties for its intended use.

Image

This property allows you to get or set an Image to be displayed in the PictureBox. Any image format supported by GDI+ can be used for this property. See the "Types of Bitmaps" article on MSDN for a list of supported formats.

SizeMode

This property determines how to display the Image within the PictureBox. It accepts a PictureBoxSizeMode value, which says whether the image should be centered, stretched, etc. (To change the size of the PictureBox control itself, use the ClientSize property.)

Links

2606 questions
14
votes
1 answer

C#: Simple and functional way to zoom picturebox images with scroll bars

Is there a simple and functional way to zoom an image in a picturebox including scroll bars? At the moment, I use a picture box in a panel with auto scroll activated. To zoom, I enlarge the picturebox and move it with the scroll bars on the panel.…
Marco Frost
  • 780
  • 3
  • 12
  • 25
14
votes
4 answers

Read picture box mouse coordinates on click

I have a Picture Box with a picture loaded and I want to read the location (as in x,y inside the Picture Box) when I click the image; is this possible ? Even more, can i read these coordinates (Points) when i mouse over ? I know i have to use the…
Razvan
  • 187
  • 1
  • 1
  • 8
13
votes
3 answers

How to refresh PictureBox

I've little question to ask. Let's say I've written an ellipse on pictureBox, then clicked a button. I want pictureBox to refresh itself. I've tried PictureBox.Invalidate(), but could'nt made it. My best regards...
unnamed
  • 840
  • 9
  • 26
  • 38
13
votes
3 answers

How can I show scrollbars on a PictureBox control?

Sometimes, I have a picturebox lets say 100x100. But the image it will display is actually 100x400. I don't want to increase the size of the picturebox itself. Instead, I would like to create a vertical scrollbar (or horizontal if needed). I could…
Saturn
  • 17,888
  • 49
  • 145
  • 271
13
votes
3 answers

c# picturebox memory releasing problem

I'm a newby in C#. I have to repeatedly refresh a GUI picture box in a worker thread. The image is acquired from a camera polling a driver with a GetImage method that retrives the image to be displayed. Even if I allocate the bitmap using directive…
picciopiccio
  • 309
  • 1
  • 4
  • 13
12
votes
3 answers

Load Picturebox Image From Memory?

I can't seem to figure out how to load a pictureBox image from a bitmap in memory. Is it possible or do I have to create temp file for the bitmap?
cam
  • 8,725
  • 18
  • 57
  • 81
12
votes
3 answers

Displaying an icon in a picturebox

I am trying to display icon file in a picture box. I'm using this code to set the image. pictureBox1.Image = new Icon(openFileDialog.FileName, new Size(48, 48)).ToBitmap(); But I'm getting this exception. System.ArgumentOutOfRangeException:…
Sri Harsha Chilakapati
  • 11,744
  • 6
  • 50
  • 91
12
votes
2 answers

Cut an Image into 9 pieces C#

Possible Duplicate: Image splitting into 9 pieces Though I googled enough but unfortunately failed to find a help. This Code Project Tutorial also failed to serve me what I actually need. I have an Image and 9 PictureBox(s) in a WinForm. Image…
whoone
  • 533
  • 3
  • 7
  • 16
11
votes
4 answers

How to load image from SQL Server into picture box?

I've tried a lot to find that how can I load an image from SQL Server to picture box but I couldn't find very much helpful material. First I saved image into the data-base with the help of following query: insert into imageTest (pic_id,…
Muhammad Ali Dildar
  • 1,467
  • 6
  • 24
  • 35
11
votes
2 answers

Why does DrawString look so crappy?

I am trying to add a text scale to a color image. The agcScale.jpg image (below) is 2 winform labels on the top and bottom and 2 winform pictureboxes on the left and right. The exact same code was used to produce the strings in the right and left…
jacknad
  • 13,483
  • 40
  • 124
  • 194
11
votes
3 answers

How to center image in picturebox on resize?

How can I center an image in a picturebox as I resize the form? What I have is a picturebox in a panel so if the image is larger than the picturebox, I can get scrollbars on the panel. But this doesn't work with the picturebox size mode "Center…
Jack
  • 5,680
  • 10
  • 49
  • 74
11
votes
5 answers

A PictureBox Problem

I have a problem: I have 3 picture boxes with 3 different images as in Image what can i set to pictureBox3 so both images look same..... EDITED: I want to move pictureBox3 on pictureBox2, So there is no Option to merge them to single image
Javed Akram
  • 15,024
  • 26
  • 81
  • 118
11
votes
4 answers

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

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…
Jon
  • 305
  • 3
  • 20
  • 45
11
votes
3 answers

How to retrieve zoom factor of a WinForms PictureBox?

I need the precise position of my mouse pointer over a PictureBox. I use the MouseMove event of the PictureBox. On this PictureBox, I use the "zoom" property to show an image. What is the correct way for getting the position of the mouse on the…
devilkkw
  • 418
  • 2
  • 6
  • 17
10
votes
3 answers

Keeping a PictureBox centered inside a container

I am designing a simple picture viewer with ability to do some basic image processing. At the moment I have the problem of keeping the PictureBox centered inside a TabPage all the time as well as keeping the picturebox width and size same as the…
Dumbo
  • 13,555
  • 54
  • 184
  • 288