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

### Constructor

# Cogl Texture2Dnew_from_file

since: 1.16

#### 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 method is not directly available to language bindings.

#### Parameters

`ctx`

  Type: `CoglContext`

  A `CoglContext`.

  The data is owned by the caller of the function.

`filename`

  Type: `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`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will left initialized to `NULL` by the constructor if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `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.