| 464 | impl RgbImage { |
| 465 | |
| 466 | pub fn from_file(fname: &str) -> Option<RgbImage> { |
| 467 | |
| 468 | unsafe { |
| 469 | let mut s = fname.to_string(); |
| 470 | s.push('\0'); |
| 471 | // 1 = return a 3-channel color imge |
| 472 | // http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imread |
| 473 | let r = cvLoadImage(s.as_ptr() as *const c_char, 1 as c_int); |
| 474 | let i = RgbImage{ iplimage: r }; |
| 475 | |
| 476 | if r.is_null() || i.depth() != 8 || i.channels() != 3 { |
| 477 | return None; |
| 478 | } |
| 479 | Some(i) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | pub fn from_raw(image: *const IplImage) -> RgbImage { |
| 484 | |