[go-nuts] Re: [Newbie] Create PNG from 2D Array and Write Over HTTP

2017-02-27 Thread Guillermo Estrada
Hi, first I would avoid using 2D arrays for storing pixels and such, that's not even a Go thing, (although Go internal library uses a 1D array for storing pixels of images), even in C or C++ a 1D array is recomended, it is faster to say the least and more efficient. img[x][y] becomes img[y*widt

[go-nuts] Re: [Newbie] Create PNG from 2D Array and Write Over HTTP

2017-02-27 Thread howardcshaw
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