From b06f7705e42b7ccf3a2ef2c07e7009fa14ba5342 Mon Sep 17 00:00:00 2001 From: Chris Couzens Date: Sun, 12 Feb 2023 18:40:03 +0000 Subject: [PATCH] Update for leptonica 1.83.0 https://github.com/ccouzens/leptonica-plumbing/issues/5 --- src/tess_base_api.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/tess_base_api.rs b/src/tess_base_api.rs index de734a1..012a00c 100644 --- a/src/tess_base_api.rs +++ b/src/tess_base_api.rs @@ -290,12 +290,18 @@ impl TessBaseApi { } /// Wrapper for [`TessBaseAPIGetInputImage`](https://tesseract-ocr.github.io/tessapi/5.x/a00008.html#ad2c023e46bf634305b3ae8cd0c091a65) - pub fn get_input_image(&self) -> Option { + pub fn get_input_image( + &self, + ) -> Option> { let ptr = unsafe { TessBaseAPIGetInputImage(self.0) }; if ptr.is_null() { None } else { - Some(unsafe { leptonica_plumbing::BorrowedPix::new(ptr) }) + Some(unsafe { + leptonica_plumbing::memory::BorrowedFrom::new( + leptonica_plumbing::Pix::new_from_pointer(ptr), + ) + }) } } @@ -407,7 +413,10 @@ impl TessBaseApi { &self, level: TessPageIteratorLevel, text_only: c_int, - ) -> Result { + ) -> Result< + leptonica_plumbing::memory::RefCountedExclusive, + TessBaseApiGetComponentImagesError, + > { let ptr = unsafe { TessBaseAPIGetComponentImages( self.0, @@ -420,7 +429,11 @@ impl TessBaseApi { if ptr.is_null() { Err(TessBaseApiGetComponentImagesError {}) } else { - Ok(unsafe { leptonica_plumbing::Boxa::new_from_pointer(ptr) }) + Ok(unsafe { + leptonica_plumbing::memory::RefCountedExclusive::new( + leptonica_plumbing::Boxa::new_from_pointer(ptr), + ) + }) } } }