<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKTexture/init(data:size:rowLength:alignment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKTexture(cm)textureWithData:size:rowLength:alignment:"
  },
  "title" : "init(data:size:rowLength:alignment:)"
}
-->

# init(data:size:rowLength:alignment:)

Creates a new texture from custom formatted raw pixel data.

```
convenience init(data pixelData: Data, size: CGSize, rowLength: UInt32, alignment: UInt32)
```

## Parameters

`pixelData`

An `NSData` object that holds the bitmap data. The pixels must be 32 bpp, 8bpc (unsigned integer) RGBA pixel data. The color components should have been already multiplied by the alpha value.

`size`

The size of the new texture in points.

`rowLength`

The number of bytes of memory to use per row of the bitmap.

`alignment`

The offset between individual pixels of the pixel data. Specify `0` for tightly packed data.

## Return Value

A new texture object.

## Discussion

The image data is copied before control is returned to your game.

---

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)