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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:40:34+00:00 2026-05-28T18:40:34+00:00

I am looking at a small Image Cropping and Resizing library written in C#.

  • 0

I am looking at a small Image Cropping and Resizing library written in C#. It consists of a single static class with static methods for resize and crop funcions.

For example the crop method:

public static Image Crop(Image img, Rectangle cropArea)
{
    var bmpImage = new Bitmap(img);
    var bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
    return bmpCrop;
}

I know that typically, Bitmap objects need to be disposed of to prevent memory leaks, but Is this a different case because of the class being static?

I dont want to implement this library and run into memory problems down the road

  • 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-28T18:40:36+00:00Added an answer on May 28, 2026 at 6:40 pm

    First, when using Bitmaps I would warn against using them from a static class if at any time you wish to use more than one thread. No bitmap can be used by more than one thread at a time. So for example if you next did this in one thread:

    using(Graphics g = Graphics.FromImage(bmpCrop)
    {
       // do something
    }
    

    and on another

    int w = bmpCrop.Width
    

    you will get an invalid parameter exception.

    Next, in your example, I see three image instances…

    • img
    • bmpImage
    • bmpCrop

    Right now you aren’t disposing bmpImage in this function and would need to.
    After this call it would be the callers responsibility at some point to dispose of img and bmpCrop

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

Sidebar

Related Questions

I am looking for a small and free TGA image loading class or library
I'm looking for a small C library to handle utf8 strings. Specifically, splitting based
I'm looking for a small and fast library implementing an HTTP server in .NET
I'm looking for help/suggestions in finding the most efficient way to resize an image
I'm looking for a good approach for efficiently dividing an image into small regions,
I am looking for a method, software or library for simple image analysis. The
I'm looking for a small tutorial that can help me use svg images in
I'm looking for small utility to run on windows mobile phone and trace all
I am looking for a small wiki engine that is easy to embed into
I'm looking for a small code snippet that will find a line in file

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.