<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage_Buffer/rowBytes",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@S@vImage_Buffer@FI@rowBytes"
  },
  "title" : "rowBytes"
}
-->

# rowBytes

The distance, in bytes, between the start of one pixel row and the next in an image, including any unused space between them.

```
var rowBytes: Int
```

## Discussion

The [`rowBytes`](/documentation/Accelerate/vImage_Buffer/rowBytes) value must be at least the [`width`](/documentation/Accelerate/vImage_Buffer/width) multiplied by the pixel size, where the pixel size depends on the image format. You can provide a larger value, in which case the extra bytes extend beyond the end of each row of pixels. You may want to do this to improve performance, or to describe an image within a larger image without copying the data. The vImage library doesn’t treat the extra bytes as part of the image that the vImage buffer represents.

For example, the following code creates two buffers, `subBufferOne` and `subBufferTwo`, that point to the bottom-right quadrant of `bufferOne` and the top-left quadrant of `bufferTwo`, respectively. Note that both subbuffers share the same [`rowBytes`](/documentation/Accelerate/vImage_Buffer/rowBytes) as their original buffers.

```swift
let bufferOne = try vImage_Buffer(cgImage: cgImageOne,
                                  format: format)

let bufferTwo = try vImage_Buffer(cgImage: cgImageTwo,
                                  format: format)

// `subBufferTwo` points to the bottom-right quadrant of `bufferTwo`.
var start = (bufferTwo.rowBytes * Int(bufferOne.height / 2))    // y
start += Int(bufferOne.width / 2) * format.componentCount       // x
var subBufferOne = vImage_Buffer(data: bufferOne.data.advanced(by: start),
                                height: bufferOne.height / 2,
                                width: bufferOne.width / 2,
                                rowBytes: bufferTwo.rowBytes)

// `subBufferTwo` points to the top-left quadrant of `bufferTwo`.
let subBufferTwo = vImage_Buffer(data: bufferTwo.data,
                                height: bufferTwo.height / 2,
                                width: bufferTwo.width / 2,
                                rowBytes: bufferTwo.rowBytes)

try subBufferTwo.copy(destinationBuffer: &subBufferOne, pixelSize: 3)
```

On return, `bufferOne` contains the top-left quadrant of `bufferTwo` copied to its bottom-right quadrant.

![A composite image that contains a background photograph of a leafy plant and a foreground photograph of a bunch of flowers. The foreground image fills the bottom-right quadrant of the image.](images/com.apple.accelerate/media-4052506@2x.png)

When you allocate floating-point data for images, keep the data 4-byte-aligned by allocating bytes as integer multiples of four. For best performance, allocate bytes as integer multiples of 16.

---

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)