You could define the colors higher in the package - right now you are allocating them every time, but they are not changing. You could also also retain the image and simply wipe and rewrite it every time as long as it is not happening in a goroutine in multiple places - if so, you could retain one image per goroutine. When you do png.Encode, the image is only read, not modified, and it is fine to hold on to it, change the pixels, and Encode it again.
It is possible to access the bytes directly but I can't see any advantage to doing that in a 5x5 example. Howard -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.