Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. i am changing size of imge with dimension given by textbox.

i am changing size of imge with dimension given by textbox.

Scheduled Pinned Locked Moved C#
graphicshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    megha_p
    wrote on last edited by
    #1

    i used this code but my picturebox is changing value but my image in not fitting in that picturebox.. it comes half or first quadrant etc. so please help me in this private void Calculate_btn_Click(object sender, EventArgs e) { Bitmap sourceimage = (Bitmap)pictureBox2.Image.Clone(); int height = sourceimage.Size.Height; int width = sourceimage.Size.Width; float nPercent = 0; float nPercentW = 0; float nPercentH = 0; int newheight = Convert.ToInt32(height_txt.Text); int newwidth = Convert.ToInt32(width_txt.Text); nPercentW = ((float)newheight / (float)height); nPercentH = ((float)newwidth / (float)width); if (nPercentH < nPercentW) nPercent = nPercentH; else nPercent = nPercentW; int destWidth = (int)(width * nPercent); int destHeight = (int)(height * nPercent); Bitmap b = new Bitmap(destWidth, destHeight); Graphics g = Graphics.FromImage((Image)b); g.DrawImage(sourceimage, 0, 0, destWidth, destHeight); pictureBox3.Image = sourceimage; pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups