0

I am trying to draw into a Surface from native code and can't understand why the stride in my ANativeWindow_Buffer is not "width * 2" for an RGB 565 format?

My window is 533x732 and format is RGB565. The stride comes back as 544.

I don't get how the stride can be 544 or how I can tweak my buffer of RGB 565 data to account for it.

This is a similar question that was answered but this guy is using Skia which I'm not using: Native window rendering issue on Samsung Galaxy S3

Community
  • 1
  • 1
spartygw
  • 3,289
  • 2
  • 27
  • 51
  • Okay, I see 'stride' here is in PIXELS, not bytes. Still, I would expect stride to be 533 in this case and not 544. So now I'm having to waste CPU cycles by copying my RGB data into a buffer and padding for the last 11 pixels in the expected stride. The image displays correctly now but I'm still confused why stride != width. – spartygw May 03 '13 at 20:03

1 Answers1

0

It's fairly common for stride to be a multiple of 16 (or some other power of two) due to hardware limitations. This is why stride is specified separately.

If you can declare your source buffer to have a stride of 544, you can do a straight copy.

fadden
  • 51,356
  • 5
  • 116
  • 166