<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageCopyToMatrix"
  },
  "title" : "MPSImageCopyToMatrix"
}
-->

# MPSImageCopyToMatrix

A class that copies image data to a matrix.

```
class MPSImageCopyToMatrix
```

## Overview

This kernel copies image data to a [`MPSMatrix`](/documentation/MetalPerformanceShaders/MPSMatrix) object. The image data is stored in a row of a matrix.  The [`dataLayout`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/dataLayout) specifies the order in which the feature channels in the image get stored in the matrix.  If the [`MPSImage`](/documentation/MetalPerformanceShaders/MPSImage) stores a batch of images, the images are copied into multiple rows, one row per image.

The number of elements in a row in the matrix must be greater than the image width multiplied its height multiplied by the number of [`featureChannels`](/documentation/MetalPerformanceShaders/MPSImage/featureChannels) in the image.

## Topics

### Initializers

[`-  initWithCoder:device:`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/init(coder:device:))

[`-  initWithDevice:dataLayout:`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/init(device:dataLayout:))

### Instance Properties

[`dataLayout`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/dataLayout)

[`destinationMatrixBatchIndex`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/destinationMatrixBatchIndex)

[`destinationMatrixOrigin`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/destinationMatrixOrigin)

### Instance Methods

[`-  encodeToCommandBuffer:sourceImage:destinationMatrix:`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/encode(commandBuffer:sourceImage:destinationMatrix:))

[`-  encodeBatchToCommandBuffer:sourceImages:destinationMatrix:`](/documentation/MetalPerformanceShaders/MPSImageCopyToMatrix/encodeBatch(commandBuffer:sourceImages:destinationMatrix:))

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`MPSKernel`](/documentation/MetalPerformanceShaders/MPSKernel)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)