Browse Source

Rename set_size to set_view_size

Move variables inside loop for conversion function
pull/65/head
Steve Cook 2 years ago
parent
commit
d1c6305221
  1. 8
      ctru-rs/examples/camera-image.rs
  2. 2
      ctru-rs/src/services/cam.rs

8
ctru-rs/examples/camera-image.rs

@ -34,7 +34,7 @@ fn main() { @@ -34,7 +34,7 @@ fn main() {
let camera = &mut cam.outer_right_cam;
camera
.set_size(CamSize::CTR_TOP_LCD)
.set_view_size(CamSize::CTR_TOP_LCD)
.expect("Failed to set camera size");
camera
@ -108,14 +108,12 @@ fn main() { @@ -108,14 +108,12 @@ fn main() {
// but the image would need to be rotated 90 degrees.
fn convert_image_to_rgb8(img: &[u8], x: usize, y: usize, width: usize, height: usize) -> Vec<u8> {
let mut rgb8 = vec![0u8; img.len()];
let mut draw_x;
let mut draw_y;
for j in 0..height {
for i in 0..width {
// Y-coordinate of where to draw in the frame buffer
draw_y = y + height - j;
let draw_y = y + height - j;
// X-coordinate of where to draw in the frame buffer
draw_x = x + i;
let draw_x = x + i;
// Initial index of where to draw in the frame buffer based on y and x coordinates
let draw_index = (draw_y + draw_x * height) * 3;

2
ctru-rs/src/services/cam.rs

@ -521,7 +521,7 @@ pub trait Camera { @@ -521,7 +521,7 @@ pub trait Camera {
}
}
fn set_size(&mut self, size: CamSize) -> crate::Result<()> {
fn set_view_size(&mut self, size: CamSize) -> crate::Result<()> {
unsafe {
let r = ctru_sys::CAMU_SetSize(self.camera_as_raw(), size.bits(), ctru_sys::CONTEXT_A);
if r < 0 {

Loading…
Cancel
Save