Skip to content

Commit 602ff80

Browse files
committed
[*] update normally
1 parent 14c01f4 commit 602ff80

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

lib/recorder/src/recorder.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,32 @@ impl RecordingSession {
879879
frame: Frame,
880880
resolution: Resolution,
881881
) -> Result<ResizedImageBuffer, RecorderError> {
882-
let (original_width, original_height) =
883-
(frame.cb_data.data.width, frame.cb_data.data.height);
884-
885-
let now = std::time::Instant::now();
886-
let img = Self::resize_image(
887-
frame.cb_data.data,
888-
resolution.dimensions(original_width, original_height),
889-
)?;
890-
log::debug!("resize image time: {:.2?}", now.elapsed());
882+
let img = if matches!(resolution, Resolution::Original(_)) {
883+
let img: ImageBuffer<Rgba<u8>, Vec<u8>> = ImageBuffer::from_raw(
884+
frame.cb_data.data.width,
885+
frame.cb_data.data.height,
886+
frame.cb_data.data.pixel_data,
887+
)
888+
.ok_or_else(|| {
889+
RecorderError::ImageProcessingFailed("Failed to create image buffer".to_string())
890+
})?;
891+
892+
let img: ImageBuffer<Rgb<u8>, Vec<u8>> = img.convert();
893+
img
894+
} else {
895+
let (original_width, original_height) =
896+
(frame.cb_data.data.width, frame.cb_data.data.height);
897+
898+
let now = std::time::Instant::now();
899+
let img = Self::resize_image(
900+
frame.cb_data.data,
901+
resolution.dimensions(original_width, original_height),
902+
)?;
903+
904+
log::debug!("resize image time: {:.2?}", now.elapsed());
905+
906+
img
907+
};
891908

892909
Ok(img)
893910
}

0 commit comments

Comments
 (0)