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 8517591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:44:44+00:00 2026-06-11T05:44:44+00:00

for resizing my picture i use this method: private Bitmap ResizeBitmap(Bitmap b, int nWidth,

  • 0

for resizing my picture i use this method:

private Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
{
    Bitmap result = new Bitmap(nWidth, nHeight);
    using (Graphics g = Graphics.FromImage((System.Drawing.Image)result))
        g.DrawImage(b, 0, 0, nWidth, nHeight);
    return result;
}

is there any possibilty to create a white or black border at the top/bottom or the right/left side of the picture, so that the picture is centered and i don’t have to do it by css?

example: i have a picture that is 200×100 pixels and i want to have it to work in a 100×100 px image field on my website. at the moment i resize the 200×100 px picture to 100×50 pixels, so that it matches in the 100×100 px box and center the picture by css.

what i need is after resizing my picture to add a border to it, so that the picture is not 100×50 px, but 100×100 px with white or black border…

any ideas… can i do this with normal .net libraries? thanks for all advices!

best regards,
jessica

  • 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-06-11T05:44:45+00:00Added an answer on June 11, 2026 at 5:44 am

    i finally found a way solving my problem:

    private Bitmap ResizeBitmapWithPadding(Bitmap b, int nWidth, int nHeight, int originalWidth, int originalHeight)
    {
        Bitmap result = new Bitmap(originalWidth, originalHeight);
        using (Graphics g = Graphics.FromImage((System.Drawing.Image)result))
        { 
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.Clear(GetColor());
            g.DrawImage(b, (originalWidth - nWidth) / 2, (originalHeight - nHeight) / 2, nWidnHeight);
        }
        return result;
    }
    

    thanks for your help!

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

Sidebar

Related Questions

Having an issue resizing the #main_wrap on: http://www.coffeeproteindrink.com/method-athlete/ #main_wrap { min-height: 100%; background: url(images/content_back.png)
I have some problems resizing a div with ID mask which I use to
I am in trouble with positioning and photo resizing. Here is the picture: 1
After uploading and resizing this photo, i noticed the quality of it become slightly
This is an Android question: I am taking a jpeg picture taken with the
I'm using a WrapPanel in WPF to display images. When resizing the form, these
I'm building application, which paints raw bitmap images on label's hdc using StrechDIBits. ptr
I'm resizing and saving some images using Coldfusion8 . However, all images, no matter
this is very confusing for me, cannot picture how it can be done. I
I'm trying to have my table use 100% of the height. This fiddle shows

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.