Cogl.Texture2D.new_from_file
Description: Reference for Cogl.Texture2D.new_from_file

### Constructor

# Cogl Texture2Dnew_from_file

#### Declaration [src]

    CoglTexture2D*
    cogl_texture_2d_new_from_file (
      CoglContext* ctx,
      const char* filename,
      GError** error
    )

#### Description [src]

Creates a low-level `CoglTexture2D` texture from an image file.

The storage for the texture is not allocated before this function returns. You can call `cogl_texture_allocate()` to explicitly allocate the underlying storage or preferably let Cogl automatically allocate storage lazily when it may know more about how the texture is being used and can optimize how it is allocated.

The texture is still configurable until it has been allocated so for example you can influence the internal format of the texture using `cogl_texture_set_components()` and cogl_texture_set_premultiplied().

Available since: | 1.16
This constructor is not directly available to language bindings

#### Parameters

`ctx` | `CoglContext`
| A `CoglContext`.
| The data is owned by the caller of the function.
`filename` | `const char*`
| The file to load.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`error` | `GError **`
| The return location for a `GError*`, or `NULL`.

#### Return value

Returns: | `CoglTexture2D`
| A newly created `CoglTexture2D` or `NULL` on failure and `error` will be updated.
| The caller of the function takes ownership of the data, and is responsible for freeing it.