rgb [in/out] fmt and stride must be set in ImageRgb
(&self, rgb: &mut ImageRgb)
| 384 | } |
| 385 | // rgb [in/out] fmt and stride must be set in ImageRgb |
| 386 | fn to(&self, rgb: &mut ImageRgb) { |
| 387 | rgb.w = self.width(); |
| 388 | rgb.h = self.height(); |
| 389 | let bytes_per_row = Self::get_bytes_per_row(rgb.w, rgb.fmt, rgb.stride()); |
| 390 | rgb.raw.resize(rgb.h * bytes_per_row, 0); |
| 391 | let stride = self.stride(); |
| 392 | let planes = self.planes(); |
| 393 | unsafe { |
| 394 | match (self.chroma(), rgb.fmt()) { |
| 395 | (Chroma::I420, ImageFormat::Raw) => { |
| 396 | super::I420ToRAW( |
| 397 | planes[0], |
| 398 | stride[0], |
| 399 | planes[1], |
| 400 | stride[1], |
| 401 | planes[2], |
| 402 | stride[2], |
| 403 | rgb.raw.as_mut_ptr(), |
| 404 | bytes_per_row as _, |
| 405 | self.width() as _, |
| 406 | self.height() as _, |
| 407 | ); |
| 408 | } |
| 409 | (Chroma::I420, ImageFormat::ARGB) => { |
| 410 | super::I420ToARGB( |
| 411 | planes[0], |
| 412 | stride[0], |
| 413 | planes[1], |
| 414 | stride[1], |
| 415 | planes[2], |
| 416 | stride[2], |
| 417 | rgb.raw.as_mut_ptr(), |
| 418 | bytes_per_row as _, |
| 419 | self.width() as _, |
| 420 | self.height() as _, |
| 421 | ); |
| 422 | } |
| 423 | (Chroma::I420, ImageFormat::ABGR) => { |
| 424 | super::I420ToABGR( |
| 425 | planes[0], |
| 426 | stride[0], |
| 427 | planes[1], |
| 428 | stride[1], |
| 429 | planes[2], |
| 430 | stride[2], |
| 431 | rgb.raw.as_mut_ptr(), |
| 432 | bytes_per_row as _, |
| 433 | self.width() as _, |
| 434 | self.height() as _, |
| 435 | ); |
| 436 | } |
| 437 | (Chroma::I444, ImageFormat::ARGB) => { |
| 438 | super::I444ToARGB( |
| 439 | planes[0], |
| 440 | stride[0], |
| 441 | planes[1], |
| 442 | stride[1], |
| 443 | planes[2], |