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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:16:37+00:00 2026-06-17T09:16:37+00:00

The white background after re-sizing the image using VB.net as shown below. I tried

  • 0

The white background after re-sizing the image using VB.net as shown below. I tried to change some values but failed.

Dim FileToResize As String = Server.MapPath("~/images/" & filename & FileUpload1.FileName)
Using originalBitmap As Bitmap = Bitmap.FromFile(FileToResize, True), newbmp As Bitmap = New Bitmap(200, 200)
    Dim WidthVsHeightRatio = CDec(originalBitmap.Width) / CDec(originalBitmap.Height)

    Using newg As Graphics = Graphics.FromImage(newbmp)
        newg.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        newg.Clear(Color.White)

        If WidthVsHeightRatio = 1D Then
            newg.DrawImage(originalBitmap, 0, 0, 200, 200)
            newg.Save()


        ElseIf WidthVsHeightRatio < 1D Then 'Image is taller than wider

            newg.DrawImage(originalBitmap, New RectangleF(New PointF((100 - (200 * WidthVsHeightRatio) / 2), 0), New SizeF(200 * WidthVsHeightRatio, 200.0F)))
            newg.Save()

        Else 'Image is wider than taller

            Dim inverse As Double = Math.Pow(WidthVsHeightRatio, -1)
            newg.DrawImage(originalBitmap, New RectangleF(New PointF(0, 100 - ((200 * inverse) / 2)), New SizeF(200.0F, 200 * inverse)))
            newg.Save()
        End If
    End Using

    newbmp.Save(Server.MapPath("~/images/" & "_th_" & filename & FileUpload1.FileName), System.Drawing.Imaging.ImageFormat.Jpeg)
    NewsItem.ImageLink = filename & FileUpload1.FileName
    NewsItem.smallimage = "_th_" & filename & FileUpload1.FileName
End Using
  • 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-17T09:16:37+00:00Added an answer on June 17, 2026 at 9:16 am

    I did a bit of research recently for generating Image Thumbnails on the fly for an eCommerce site. I started off doing this myself generating a bitmap and then resizing etc. After problems with image size on disc and quality I looked in to http://imageresizing.net/ and I haven’t looked back since. It can generate images from byte(), streams and physicals files all very quickly with one line of code:

    ImageBuilder.Current.Build(New MemoryStream(bImage), sImageLocation + sFullFileName, New      ResizeSettings("maxwidth=214&maxheight=238"))
    

    I would definitely recommend this component rather than trying to reinvent the wheel…

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

Sidebar

Related Questions

After I rotate or deskew an image with Imagemagick there's a white background in
I would like to change the white background in a UIPickerView to an image
I need to blink between two colors:red and white. I've found that after $targetcss('background-color','red')
CSS border radius works fine, but it's now revealing a white background. (I'd prefer
When I change the HTML declaration my background becomes white instead of green. Before:
I have a VB.NET form with a red background and white text. I want
I am using emacs on MacOS 10.6 with Terminal. I have a white background.
I have two images, large text on white background. The length varies but the
I've recently started using Eclipse CDT. After some searching, I've found a way to
My UIWindow initially has a white background. I want to change the background to

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.