Click here to Skip to main content
13,144,958 members (49,758 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

5.2K views
3 bookmarked
Posted 15 Aug 2011

Work with bitmaps faster in C#

, 15 Aug 2011
Rate this:
Please Sign up or sign in to vote.
You can increase the speed of both SetPixel and GetPixel by doing the following:Add the line 'int step = 0' at the LockBitmap class level.Remove 'int' declation of 'step' in the LockBits method and calculate as is.In both SetPixel and GetPixel, remove the line:int cCount = Depth /...

You can increase the speed of both SetPixel and GetPixel by doing the following:



  1. Add the line 'int step = 0' at the LockBitmap class level.

  2. Remove 'int' declation of 'step' in the LockBits method and calculate as is.

  3. In both SetPixel and GetPixel, remove the line:

  4. int cCount = Depth / 8;

  5. In both SetPixel and GetPixel, replace cCount with Step:

  6. //Get start index of the specified pixel
    int i = ((y * Width) + x) * cCount;

    now becomes:


    //Get start index of the specified pixel
    int i = ((y * Width) + x) * Step;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

robertjb20
Software Developer n/a
Canada Canada
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 15 Aug 2011
Article Copyright 2011 by robertjb20
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid