![]() ![]() G.DrawImage(bmp, dest_rect, src_rect, GraphicsUnit.Pixel) Src_rect = new Rectangle(0, (bmp.Height - sample_height) / 2, bmp.Width, sample_height) Int sample_height = (int)(pbox.Height / size_ratio) Src_rect = new Rectangle((bmp.Width - sample_width) / 2, 0, sample_width, bmp.Height) įloat size_ratio = (float)pbox.Width / bmp.Width ![]() Int sample_width = (int)(pbox.Width / size_ratio) ![]() Var dest_rect = new Rectangle(0, 0, pbox.Width, pbox.Height) įloat size_ratio = (float)pbox.Height / bmp.Height Var resized = new Bitmap(pbox.Width, pbox.Height) Pbox.SizeMode = PictureBoxSizeMode.Normal īool source_is_wider = (float)bmp.Width / bmp.Height > (float)pbox.Width / pbox.Height This code should enable that: static public void fillPictureBox(PictureBox pbox, Bitmap bmp) The PictureBox.SizeMode options are missing a "fill" or "cover" mode which would be like zoom except with cropping to ensure you're filling the picture box. My picturebox is squared, if the image is rectangular how to it crop and show it in the picturebox like this, the lower part of the picture will be removed. What is the code to make the image fit in the picturebox? If the image is too large for the picturebox to fit. PictureBox1.Image = Image.FromStream(stream) Using (var stream = new MemoryStream(data)) Var adapter = new SqlDataAdapter(SqlCommand) Using (SqlCommand SqlCommand = new SqlCommand("Select Photo from Employee where EmpID LIKE '%' + + '%' ", textBox1.Text) Using (SqlConnection myDatabaseConnection = new SqlConnection(m圜onnectionString.ConnectionString)) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |