FAQ

On Fri, Apr 22, 2016 at 12:29 AM, Seb Binet wrote:
for i,v := range floats {
ii := i*4
pix[ii+0] = byte(v)
pix[ii+1] = byte(v)
pix[ii+2] = byte(v)
pix[ii+3] = 255
}
img := image.NewNRGBA(rect)
img.Pix = pix
A couple of tangential points:

You might be better off with an image.Gray instead of an image.NRGBA.

You might be better off with a struct literal instead of calling
image.NewFoo, as the NewFoo function will allocate a pix buffer that
(in this case) is nothing but garbage for collecting.

img := &image.Gray{
   Pix: pix,
   Stride, rect.Dy(),
   Rect: rect,
}

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 11 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 21, '16 at 2:29p
activeMay 26, '16 at 4:35p
posts11
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase