Get the number of bytes for a frame with this RGB format and the given size */
| 122 | /* Get the number of bytes for a frame with this RGB format and the given size |
| 123 | */ |
| 124 | std::size_t PixelFormatRGB::bytesPerFrame(Size frameSize) const |
| 125 | { |
| 126 | auto bpsValid = this->bitsPerSample >= 8 && this->bitsPerSample <= 16; |
| 127 | if (!bpsValid || !frameSize.isValid()) |
| 128 | return 0; |
| 129 | |
| 130 | auto numSamples = std::size_t(frameSize.height) * std::size_t(frameSize.width); |
| 131 | auto nrBytes = numSamples * this->nrChannels() * ((this->bitsPerSample + 7) / 8); |
| 132 | DEBUG_RGB_FORMAT("PixelFormatRGB::bytesPerFrame samples %d channels %d bytes %d", |
| 133 | int(numSamples), |
| 134 | this->nrChannels(), |
| 135 | nrBytes); |
| 136 | return nrBytes; |
| 137 | } |
| 138 | |
| 139 | int PixelFormatRGB::getChannelPosition(Channel channel) const |
| 140 | { |
no test coverage detected