0

Im writing a program that requires a lot of updates to be made to a 1400 x 900 pixel image (approx every second or so). In my current build i have used a lockbits function which recalls data from an array (which i have used to store data about each pixel on the map) and places the correct pixels on the bitmap.

full code

sample because it wont let me post otherwise

        if (enb == 1 || enb == 6 || enb == 7 || enb == 8 || enb == 9)
        {
            rgbValues[(y * bmpData.Stride) + (x * 4) + 3] = 255; //alpha
            rgbValues[(y * bmpData.Stride) + (x * 4) + 2] = Convert.ToByte(provinces[(Convert.ToInt16(tmp3n)), 13]); //red
            rgbValues[(y * bmpData.Stride) + (x * 4) + 1] = Convert.ToByte(provinces[(Convert.ToInt16(tmp3n)), 14]); //green
            rgbValues[(y * bmpData.Stride) + (x * 4)] = Convert.ToByte(provinces[(Convert.ToInt16(tmp3n)), 15]); //blue
        }

My issue is that once there is a large amount of colours on the bitmap, it can take a lot of time for the map to be updated, causing the entire run time to increase too much (late in run time i found it could take five seconds to update the image).

Is there any problems with my current algorithm that might be causing this issue? or is there any more suitable/efficient algorithms i could use instead?

Apologies if this isnt an appropriate question for here, but im stumped on how to do this, and im fairly sure its possible. Thank you <3

  • I've heard from other posts on here that bitmaps arent disposable, im not sure if the local scope bitmap image i am declaring in this program might be causing the problem, is this possible? – Jamie Gorman Feb 07 '18 at 10:49
  • Did some changes to clean up the code, looks like the question has gone past the point where anyone will see it though : / – Jamie Gorman Feb 07 '18 at 12:10
  • Looks like the issue revolves around the loop used for going through each x and y, it appears to take a long time purely because its cycling through so many coordinates, im not sure how to fix this. – Jamie Gorman Feb 07 '18 at 12:22

1 Answers1

0

The issue appears to be to do with the iteration through the array, rather than the placement of pixels themselves. Since that means the title is wrong, im gonna close this and potentially make a new question.