Skip to main content
DChristop
Participating Frequently
June 19, 2015
Answered

rowBytes returns wrong value

  • June 19, 2015
  • 1 reply
  • 378 views

Hi

i am about to create an exporter for a compression format.

I experience a strange situation where the value of ExportRecord->rowBytes is giving a strange value which makes my code crash Photoshop.

I process the image row by row and initially create a buffer of size gStuff->imageSize.h*gStuff->imageSize.v*gStuff->planes

Now I get the image data line by line, plane by plane, copy it into the buffer I have created, and advance a pointer by rowBytes assuming that its value would be the same as imageSize.h to copy the next line.

This caused buffer overruns. After debugging using a simple 1000x1000 rgb image i saw that rowBytes returned 1008.

For a 900x900 image it returned 912.

Why is that? It should be 1000 and 900 in these cases, I  specify to get only get only one plane and one line.

The doc says "rowBytes = The offset between rows for the requested image data.", so where do these extra bytes come from? What value do they have?

If rowBytes is not the width of the image how usefull is it?

Thanks

Dimi

This topic has been closed for replies.
Correct answer Shmoopie99

Scanlines are usually padded to 16 byte boundaries, so rowbytes would reflect that.

1 reply

Shmoopie99Correct answer
Inspiring
July 2, 2015

Scanlines are usually padded to 16 byte boundaries, so rowbytes would reflect that.

DChristop
DChristopAuthor
Participating Frequently
July 3, 2015

That sounds logical. Thanks