Struct RegionItem

Source
pub struct RegionItem { /* private fields */ }
Available on crate feature v1_18 only.
Expand description

Region item.

See ISO/IEC 23008-12:2022 Section 6.10 “Region items and region annotations”

Implementations§

Source§

impl RegionItem

Source

pub fn id(&self) -> ItemId

Source

pub fn reference_size(&self) -> (u32, u32)

Get the reference size for a region item.

The reference size specifies the coordinate space used for the region items. When the reference size does not match the image size, the regions need to be scaled to correspond.

Source

pub fn regions(&self) -> Vec<Region>

Get the regions that are part of a region item.

Source

pub fn add_point(&mut self, x: i32, y: i32) -> Result<Region>

Add a point region to the region item.

Source

pub fn add_rectangle(&mut self, rectangle: Rectangle) -> Result<Region>

Add a rectangle region to the region item.

Source

pub fn add_ellipse( &mut self, center_x: i32, center_y: i32, radius_x: u32, radius_y: u32, ) -> Result<Region>

Add an ellipse region to the region item.

Source

pub fn add_polygon(&mut self, points: &[(i32, i32)]) -> Result<Region>

Add a polygon region to the region item.

A polygon is a sequence of points that form a closed shape. The first point does not need to be repeated as the last point. The points are provided as pairs of (X, Y) coordinates.

Source

pub fn add_polyline(&mut self, points: &[(i32, i32)]) -> Result<Region>

Add a polyline region to the region item.

A polyline is a sequence of points that does not form a closed shape. Even if the polyline is closed, the only points that are part of the region are those that intersect (even minimally) a one-pixel line drawn along the polyline. The points are provided as pairs of (X, Y) coordinates.

Source

pub fn add_referenced_mask( &mut self, rectangle: Rectangle, mask_item_id: ItemId, ) -> Result<Region>

Add a referenced mask region to the region item.

Source

pub fn add_inline_mask_data( &mut self, rectangle: Rectangle, mask_data: &[u8], ) -> Result<Region>

Add an inline mask region to the region item.

The region geometry is described by a left top corner position, and a size defined by width and height.

The mask is held as inline data on the region, one bit per pixel, the most significant bit first pixel, no padding. If the bit value is 1, the corresponding pixel is part of the region. If the bit value is 0, the corresponding pixel is not part of the region.

Source

pub fn add_inline_mask( &mut self, rectangle: Rectangle, image: &Image, ) -> Result<Region>

Add an inline mask region image to the region item.

The region geometry is described by a left top corner position, and a size defined by width and height.

The mask data is held as inline data in the region, one bit per pixel. The provided image is converted to inline data, where any pixel with a value >= 0x80 becomes part of the mask region. If the image width is less than the specified rectangle.width, it is expanded to match the rectangle.width of the region (zero fill on the right). If the image height is less than the specified rectangle.height, it is expanded to match the rectangle.height of the region (zero fill on the bottom). If the image width or height is greater than the rectangle.width or rectangle.height (correspondingly) of the region, the image is cropped.

Trait Implementations§

Source§

impl Drop for RegionItem

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.