---
title: MTKTextureLoader
framework: metalkit
role: symbol
role_heading: Class
path: metalkit/mtktextureloader
---

# MTKTextureLoader

An object that creates textures from existing data in common image formats.

## Declaration

```swift
class MTKTextureLoader
```

## Overview

Overview Use the MTKTextureLoader class to create a Metal texture from existing image data. This class supports common file formats, like PNG, JPEG, and TIFF. It also loads image data from KTX and PVR files, asset catalogs, Core Graphics images, and other sources. It infers the output texture format and pixel format from the image data. You create textures synchronously or asynchronously using MTKTextureLoader methods that return MTLTexture instances. Pass options to these methods that customize the image-loading and texture-creation process. First create an MTKTextureLoader instance, passing the device that it uses to create textures. Then use one of the texture loader’s methods to create a texture. The code example below synchronously creates a texture from data at a URL, using the default options: If you use custom data formats, or change the image data at runtime, use MTLTexture methods instead. For more information, see Creating and sampling textures.

## Topics

### Creating a Texture Loader

- [init(device:)](metalkit/mtktextureloader/init(device:).md)
- [device](metalkit/mtktextureloader/device.md)

### Loading Textures from URLs

- [newTexture(URL:options:)](metalkit/mtktextureloader/newtexture(url:options:).md)
- [newTexture(URL:options:completionHandler:)](metalkit/mtktextureloader/newtexture(url:options:completionhandler:).md)
- [newTextures(URLs:options:error:)](metalkit/mtktextureloader/newtextures(urls:options:error:).md)
- [newTextures(URLs:options:completionHandler:)](metalkit/mtktextureloader/newtextures(urls:options:completionhandler:).md)

### Loading Textures from Asset Catalogs

- [newTexture(name:scaleFactor:bundle:options:)](metalkit/mtktextureloader/newtexture(name:scalefactor:bundle:options:).md)
- [newTexture(name:scaleFactor:bundle:options:completionHandler:)](metalkit/mtktextureloader/newtexture(name:scalefactor:bundle:options:completionhandler:).md)
- [newTextures(names:scaleFactor:bundle:options:completionHandler:)](metalkit/mtktextureloader/newtextures(names:scalefactor:bundle:options:completionhandler:).md)
- [newTexture(name:scaleFactor:displayGamut:bundle:options:)](metalkit/mtktextureloader/newtexture(name:scalefactor:displaygamut:bundle:options:).md)
- [newTexture(name:scaleFactor:displayGamut:bundle:options:completionHandler:)](metalkit/mtktextureloader/newtexture(name:scalefactor:displaygamut:bundle:options:completionhandler:).md)
- [newTextures(names:scaleFactor:displayGamut:bundle:options:completionHandler:)](metalkit/mtktextureloader/newtextures(names:scalefactor:displaygamut:bundle:options:completionhandler:).md)

### Loading Textures from Core Graphics Images

- [newTexture(cgImage:options:)](metalkit/mtktextureloader/newtexture(cgimage:options:).md)
- [newTexture(cgImage:options:completionHandler:)](metalkit/mtktextureloader/newtexture(cgimage:options:completionhandler:).md)

### Loading Textures from In-Memory Data Representations

- [newTexture(data:options:)](metalkit/mtktextureloader/newtexture(data:options:).md)
- [newTexture(data:options:completionHandler:)](metalkit/mtktextureloader/newtexture(data:options:completionhandler:).md)

### Loading Textures from Model I/O Representations

- [newTexture(texture:options:)](metalkit/mtktextureloader/newtexture(texture:options:).md)
- [newTexture(texture:options:completionHandler:)](metalkit/mtktextureloader/newtexture(texture:options:completionhandler:).md)

### Specifying Loading Options

- [MTKTextureLoader.Option](metalkit/mtktextureloader/option.md)

### Completing a Texture Loading Operation

- [MTKTextureLoader.ArrayCallback](metalkit/mtktextureloader/arraycallback.md)
- [MTKTextureLoader.Callback](metalkit/mtktextureloader/callback.md)

### Handling Errors

- [MTKTextureLoader.Error](metalkit/mtktextureloader/error.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
