I was optimizing a piece of code that relies heavily on
picture.RGBSurface.Pixel(c, r) = RGB(pixr, pixg, pixb)
I think i saw a posting on linked in on how to optimize this with tutorial etc.
I was optimizing a piece of code that relies heavily on
picture.RGBSurface.Pixel(c, r) = RGB(pixr, pixg, pixb)
I think i saw a posting on linked in on how to optimize this with tutorial etc.
For starters, save a reference to the picture’s RGBSurface for reuse, instead of generating it new each time:
Var theSurface as RGBSurface
theSurface = myPicture.RGBSurface
theSurface.Pixel(c, r) = RGB(pixR, pixG, pixB)
That should make a big difference if you are making a lot of changes.
Also, use the Y value as the outer loop and the X value in the inner loop, if you are looping through all the pixels.