---
title: "modifyPixelData(_:)"
framework: spritekit
role: symbol
role_heading: Instance Method
path: "spritekit/skmutabletexture/modifypixeldata(_:)"
---

# modifyPixelData(_:)

Modifies the contents of a mutable texture.

## Declaration

```swift
func modifyPixelData(_ block: @escaping @Sendable (UnsafeMutableRawPointer?, Int) -> Void)
```

```swift
func modifyPixelData() async -> (UnsafeMutableRawPointer?, Int)
```

## Parameters

- `block`: A block to be called when the texture can be safely modified. The block takes the following parameters:

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func modifyPixelData() async -> (UnsafeMutableRawPointer?, Int) For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. The contents of the texture can be modified only at specific times when the graphics hardware permits it. When this method is called, it schedules a new background task to update the texture and then returns. Your block is called when the texture can be modified. Your block is called on an arbitrary queue. Your block should modify the texture’s contents and then return. The texture bytes are assumed to be stored as tightly packed 32 bpp, 8bpc (unsigned integer) RGBA pixel data. The color components you provide should have already been multiplied by the alpha value.
