# Linear Access to the image data

**URL:** <https://forum.commonvisionblox.com/t/linear-access-to-the-image-data/303>\
**Category:** .Net API\
**Created:** [December 19, 2017, 3:20pm UTC](https://forum.commonvisionblox.com/t/linear-access-to-the-image-data/303 "2017-12-19T15:20:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [December 19, 2017, 3:36pm UTC](https://forum.commonvisionblox.com/t/linear-access-to-the-image-data/303/2 "2017-12-19T15:36:18Z")

</div>

This access is available on the `ImagePlane`, e.g. to access the first plane:

> `LinearAccessData imageData = image.Planes[0].GetLinearAccess();`

This gives you the `BasePtr`, `XInc`, and `YInc` as `IntPtr`s. This call will throw if linear access is not possible, though. To get around that you can call:

> `image.Planes[0].TryGetLinearAccess(out LinearAccessData imageData);`

This does not throw, but returns `false` if not possible. You then have to use:

> `image.Planes[0].Vpat`

By the way: if you know the pixel datatype upfront you can also use (for `byte` pixels):

> `LinearAccessData<byte> imageData = image.Planes[0].GetLinearAccess<byte>();`

Additionally to the base pointer and increments you get an indexer to access the pixel data:

> `imageData[x, y] = 255 - imageData[x, y];`

(This is convenient, but direct pointer access is faster.)

---

_[View the full topic](https://forum.commonvisionblox.com/t/linear-access-to-the-image-data/303)._
