Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Edit 2:

You are calling the public int ColorDepth { get { return Bitmap.GetPixelFormatSize(_bitmap.PixelFormat); } } for each SetPixel to calculate the color components. Make it a one time initialization property and set its value in the constructor instead of evaluating it each time.

Edit 3:

I checked its source code and I think this probably would be micro-optimization because all it does is return(unchecked((int)pixfmt) >> 8) & 0xFF;

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Edit 2:

You are calling the public int ColorDepth { get { return Bitmap.GetPixelFormatSize(_bitmap.PixelFormat); } } for each SetPixel to calculate the color components. Make it a one time initialization property and set its value in the constructor instead of evaluating it each time.

Edit 3:

I checked its source code and I think this probably would be micro-optimization because all it does is return(unchecked((int)pixfmt) >> 8) & 0xFF;

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Edit 2:

You are calling the public int ColorDepth { get { return Bitmap.GetPixelFormatSize(_bitmap.PixelFormat); } } for each SetPixel to calculate the color components. Make it a one time initialization property and set its value in the constructor instead of evaluating it each time.

Edit 3:

I checked its source code and I think this probably would be micro-optimization because all it does is return(unchecked((int)pixfmt) >> 8) & 0xFF;

Copying a comment to answer.
Source Link

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Edit 2:

You are calling the public int ColorDepth { get { return Bitmap.GetPixelFormatSize(_bitmap.PixelFormat); } } for each SetPixel to calculate the color components. Make it a one time initialization property and set its value in the constructor instead of evaluating it each time.

Edit 3:

I checked its source code and I think this probably would be micro-optimization because all it does is return(unchecked((int)pixfmt) >> 8) & 0xFF;

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Edit 2:

You are calling the public int ColorDepth { get { return Bitmap.GetPixelFormatSize(_bitmap.PixelFormat); } } for each SetPixel to calculate the color components. Make it a one time initialization property and set its value in the constructor instead of evaluating it each time.

Edit 3:

I checked its source code and I think this probably would be micro-optimization because all it does is return(unchecked((int)pixfmt) >> 8) & 0xFF;

Copying comment to answer.
Source Link

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

As far as performance is concerned and if your code allows it you may consider using a jagged array instead of a multidimensional one. They are said to have a better performance.

And as usual the bottle-neck of your code are the GetPixel/SetPixel that are really slow. You should be accessing the bitmap directly

Edit:

You can improve BitmapLocker - make it IDisposable and use it with a using to automatically release the bitmap - you won't however gain any performance but you'll be sure that it's released without having to thing about releasing it manually.

Source Link
t3chb0t
  • 44.7k
  • 9
  • 84
  • 190
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /