go - Convert image.Image to image.NRGBA -


when call png.decode(imagefile) returns type image.image. can't find documented way convert image.nrgba or image.rgba on can call methods at().

how can achieve this?

if don't need "convert" image type, , want extract underlying type interface, use "type assertion":

if img, ok := i.(*image.rgba); ok {     // img *image.rgba } 

or type switch:

switch := i.(type) { case *image.rgba:     // in *image.rgba case *image.nrgba:     // in *image.nrbga } 

Comments