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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:12:52+00:00 2026-06-13T13:12:52+00:00

In following code, I am getting an error on the line bitmap = newBitmap

  • 0

In following code, I am getting an error on the line bitmap = newBitmap, saying it can’t assign bitmap since it’s a using variable. How can i resize the Bitmap?

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

....

using (var bitmap = new Bitmap(_width, _height, _width * 3, PixelFormat.Format24bppRgb, pBuffer))
{
    if (!this.Secondpass)
    {
        long[] HistogramValues = Form1.GetHistogram(bitmap);
        Form1.Histograms.Add(HistogramValues);
        long t = Form1.GetTopLumAmount(HistogramValues, 1000);
        Form1.averagesTest.Add(t);                            
    }
    else
    {                    
        if (_frameId > 0)
        {
            double t = Form1.averagesTest[_frameId] / 1000.0 - Form1.averagesTest[_frameId - 1] / 1000.0;
            w.WriteLine("averagesTest >>>  " + t);
            double tt = framesCounts();
            if (_frameId == framesCounts())
            {
                w.Close();
            }
            if (Form1.averagesTest[_frameId] / 1000.0 - Form1.averagesTest[_frameId - 1] / 1000.0 > 0.0) 
            {
                count = 6;
            }

            if (count > 0)
            {
                Bitmap newBitmap = ResizeBitmap(bitmap, 10, 10);
                bitmap.Dispose();
                bitmap = newBitmap;
                bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
                bitmap.Save(Path.Combine(_outFolder, _frameId.ToString("D6") + ".bmp"),ImageFormat.Bmp);
                count --;
            }
        }
    }
}
  • 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-13T13:12:53+00:00Added an answer on June 13, 2026 at 1:12 pm

    You’re attempting to re-assign the variable bitmap which was defined in the using statement. According to the C# Specification, that is an error:

    Local variables declared in a resource-acquisition are read-only, and must include an initializer. A compile-time error occurs if the embedded statement attempts to modify these local variables (by assignment or the ++ and — operators) or pass them as ref or out parameters.

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

Sidebar

Related Questions

I'm getting an error message: unimplemented or unreasonable conversion requested using the following code:
I am getting an error because of the following line of code: int x
In the following code @ line 4 & 5 i am getting the error
I have the following code and am getting error at NSString *weight line: *
I am using vb.net and the following code, but I am getting an error.
I am compiling following code and getting following error. How to fix this? Thanks
I have the following code however am getting the error Uncaught TypeError: Object #<addThis>
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
With the following code, I keep getting error C2535 when I compile. It's complaining
I'm getting the error message when running the following code from a C# console

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.