Skip to content

Commit

Permalink
Update for leptonica 1.83.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ccouzens committed Feb 12, 2023
1 parent 0e53c35 commit b06f770
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/tess_base_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<leptonica_plumbing::BorrowedPix> {
pub fn get_input_image(
&self,
) -> Option<leptonica_plumbing::memory::BorrowedFrom<leptonica_plumbing::Pix>> {
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),
)
})
}
}

Expand Down Expand Up @@ -407,7 +413,10 @@ impl TessBaseApi {
&self,
level: TessPageIteratorLevel,
text_only: c_int,
) -> Result<leptonica_plumbing::Boxa, TessBaseApiGetComponentImagesError> {
) -> Result<
leptonica_plumbing::memory::RefCountedExclusive<leptonica_plumbing::Boxa>,
TessBaseApiGetComponentImagesError,
> {
let ptr = unsafe {
TessBaseAPIGetComponentImages(
self.0,
Expand All @@ -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),
)
})
}
}
}
Expand Down

0 comments on commit b06f770

Please sign in to comment.