NewTexture2DFromImage creates and returns a pointer to a new Texture2D using the specified image file as data. Supported image formats are: PNG, JPEG and GIF.
(imgfile string)
| 82 | // using the specified image file as data. |
| 83 | // Supported image formats are: PNG, JPEG and GIF. |
| 84 | func NewTexture2DFromImage(imgfile string) (*Texture2D, error) { |
| 85 | |
| 86 | // Decodes image file into RGBA8 |
| 87 | rgba, err := DecodeImage(imgfile) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | |
| 92 | t := newTexture2D() |
| 93 | t.SetFromRGBA(rgba) |
| 94 | return t, nil |
| 95 | } |
| 96 | |
| 97 | // NewTexture2DFromRGBA creates a new texture from a pointer to an RGBA image object. |
| 98 | func NewTexture2DFromRGBA(rgba *image.RGBA) *Texture2D { |
no test coverage detected