otisonoza
otisonoza

Reputation: 1344

What is the fastest way to copy a QImage's pixels to an array?

I'm planning to store an QImage's pixel data in an array, then do some work with it in OpenCL.

What is the best approach to get all pixel data (colour code)?

Upvotes: 2

Views: 738

Answers (2)

Naresh
Naresh

Reputation: 653

uchar * QImage::bits () gives the pointer to the first pixel data. You can create an OpenCL buffer with CL_MEM_USE_HOST_POINTER flag by passing pointer returned from bits.

Upvotes: 3

user3146587
user3146587

Reputation: 4330

Use the QImage::bits() and QImage::byteCount() methods to get a raw pointer to the image data and the size in bytes of the image data.

Upvotes: 1

Related Questions