Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 425963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:25:56+00:00 2026-05-12T19:25:56+00:00

I am using pictureBox to show images which are received from server but my

  • 0

I am using pictureBox to show images which are received from server but my problem is that picture box in compact framework has only three Size Modes

StretchImage, Normal, CenterImage

the pictures i am getting are generally bigger in size so i have to use StrecthImage mode. But then the aspect ratio is maintained so the images shown become distorted.

So is their anyway to come out of this problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:25:56+00:00Added an answer on May 12, 2026 at 7:25 pm

    finally i found answer for my question which is here—–

     float actualHeight = myImg.Height;
     float actualWidth = myImg.Width;
     float imgRatio = actualWidth / actualHeight;
     float maxRatio = (float)this.Width / this.Height;
    
                    if(imgRatio!=maxRatio)
                    {
                        if (imgRatio < maxRatio)
                        {
                            imgRatio = this.Height / actualHeight;
                            actualWidth = imgRatio * actualWidth;
                            actualHeight = this.Height;
                        }
                        else
                        {
                            imgRatio = this.Width / actualWidth;
                            actualHeight = imgRatio * actualHeight;
                            actualWidth = this.Width;
                        }
                    }
     pictureBox.Size=new Size((int)actualWidth,(int)actualHeight);
     pictureBox.Location = new Point((int)((this.Width - actualWidth) / 2), (int)((this.Height - actualHeight) / 2));
    

    but before doing this keep the picture box size mode as stretchImage

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: A program displays a picture using a PictureBox .
A simple code that should show an image using PictureBox doesn't work (frm is
previously i was using picture box and its built in utilities to draw some
Hi I am using visual studio 8, vb.net. I have a picture box on
I'm trying to make a program that will draw lines over a picturebox using
I'm using a picturebox to display images in a form. If the image is
I write a code that read a png image from file and show with
I am currently coding a C# application that displays a image using PictureBox on
I'm using savefiledialog to save an image. Canvas is picturebox and the loaded image
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.