In this CGBitmapContextCreate, why is bytesPerRow 0?

后端 未结 1 1696
挽巷
挽巷 2021-02-10 01:56

I\'ve noticed in Apple\'s sample code that they often provide a value of 0 in the bytesPerRow parameter of CGBitmapContextCreate. For example, this comes out of the Reflection s

1条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 02:53

    My understanding is that if you pass in zero, it calculates the bytes-per-row based on the bitsPerComponent and width arguments. You might want additional padding at the end of each row of bytes (if your device required it, or some other constraint). In this case, you could pass a value that was more than just width * (bytes per pixel). I would imagine this is probably never needed in modern i/MacOS development, except for some weird edge-case optimizations.

    0 讨论(0)
提交回复
热议问题