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

  • Home
  • SEARCH
  • 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 8821991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:59:19+00:00 2026-06-14T05:59:19+00:00

I have got a System.Drawing.Bitmap in my code. The width is fix, the height

  • 0

I have got a System.Drawing.Bitmap in my code.

The width is fix, the height varies.

What I want to do, is to add a white border around the bitmap, with about 20 pixel, to all 4 edges.

How would this work?

  • 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-14T05:59:20+00:00Added an answer on June 14, 2026 at 5:59 am

    You could draw a rectangle behind the bitmap. The width of the rectangle would be (Bitmap.Width + BorderWidth * 2), and the position would be (Bitmap.Position – new Point(BorderWidth, BorderWidth)). Or at least that’s the way I’d go about it.

    EDIT:
    Here is some actual source code explaining how to implement it (if you were to have a dedicated method to draw an image):

    private void DrawBitmapWithBorder(Bitmap bmp, Point pos, Graphics g) {
        const int borderSize = 20;
    
        using (Brush border = new SolidBrush(Color.White /* Change it to whichever color you want. */)) {
            g.FillRectangle(border, pos.X - borderSize, pos.Y - borderSize, 
                bmp.Width + borderSize, bmp.Height + borderSize);
        }
    
        g.DrawImage(bmp, pos);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing an online accounting system as a college project. I have got
I've got a system where all changes to business objects have to be audited.
Have got an NSString *str = @12345.6789 and want to find out if there
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have the following code: public override object ConvertToStorageType(object value) { Bitmap image =
I have got a strange error occurring on my git project. liam@development ~/android/system/system/core $
Is it possible to use System.Drawing.Image in an RDLC Image Control? All I have
I have a Windows::Forms application and I want to add a custom control to
I am developing an operating system in assembly. I have got a working executable
I have got the following code from here to read an Excel file using

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.