pub struct RegionItem { /* private fields */ }
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
impl RegionItem
pub fn id(&self) -> ItemId
Sourcepub fn reference_size(&self) -> (u32, u32)
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.
Sourcepub fn add_point(&mut self, x: i32, y: i32) -> Result<Region>
pub fn add_point(&mut self, x: i32, y: i32) -> Result<Region>
Add a point region to the region item.
Sourcepub fn add_rectangle(&mut self, rectangle: Rectangle) -> Result<Region>
pub fn add_rectangle(&mut self, rectangle: Rectangle) -> Result<Region>
Add a rectangle region to the region item.
Sourcepub fn add_ellipse(
&mut self,
center_x: i32,
center_y: i32,
radius_x: u32,
radius_y: u32,
) -> Result<Region>
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.
Sourcepub fn add_polygon(&mut self, points: &[(i32, i32)]) -> Result<Region>
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.
Sourcepub fn add_polyline(&mut self, points: &[(i32, i32)]) -> Result<Region>
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.
Sourcepub fn add_referenced_mask(
&mut self,
rectangle: Rectangle,
mask_item_id: ItemId,
) -> Result<Region>
pub fn add_referenced_mask( &mut self, rectangle: Rectangle, mask_item_id: ItemId, ) -> Result<Region>
Add a referenced mask region to the region item.
Sourcepub fn add_inline_mask_data(
&mut self,
rectangle: Rectangle,
mask_data: &[u8],
) -> Result<Region>
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.
Sourcepub fn add_inline_mask(
&mut self,
rectangle: Rectangle,
image: &Image,
) -> Result<Region>
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.