Vips.Region¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
bpl |
r |
||
data |
r |
||
im |
r |
the |
|
invalid |
r |
||
parent_object |
r |
||
seq |
r |
||
thread |
r |
||
type |
r |
||
valid |
r |
the |
|
window |
r |
Class Details¶
- class Vips.Region(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A small part of a
Vips.Image
. valid holds the left/top/width/height of the area of pixels that are available from the region.See also: VIPS_REGION_ADDR(),
Vips.Region.new
(),Vips.Region.prepare
().- classmethod new(image)¶
- Parameters:
image (
Vips.Image
) – image to create this region on- Return type:
Create a region.
Vips.Region
s start out empty, you need to callVips.Region.prepare
() to fill them with pixels.See also:
Vips.Region.prepare
().
- black()¶
Paints 0 into the valid part of self.
See also:
Vips.Region.paint
().
- buffer(r)¶
- Parameters:
r (
Vips.Rect
) –Vips.Rect
of pixels you need to be able to address- Returns:
0 on success, or -1 for error.
- Return type:
The region is transformed so that at least r pixels are available as a memory buffer that can be written to.
- copy(dest, r, x, y)¶
- Parameters:
dest (
Vips.Region
) – destination regionx (
int
) – position of r in desty (
int
) – position of r in dest
- Returns:
destination region
- Return type:
dest:
Vips.Region
Copy from one region to another. Copy area r from inside self to dest, positioning the area of pixels at x, y. The two regions must have pixels which are the same size.
See also:
Vips.Region.paint
().
- equalsregion(reg2)¶
- Parameters:
reg2 (
Vips.Region
) – region to test- Returns:
non-zero on equality.
- Return type:
Do two regions point to the same piece of image? ie.
VIPS_REGION_ADDR(reg1, x, y) == VIPS_REGION_ADDR(reg2, x, y) && *VIPS_REGION_ADDR(reg1, x, y) == *VIPS_REGION_ADDR(reg2, x, y) for all x, y, reg1, reg2.
- fetch(left, top, width, height, len)¶
- Parameters:
- Returns:
A copy of the pixel data.
- Return type:
Generate an area of pixels and return a copy. The result must be freed with
GLib.free
(). The requested area must be completely inside the image.This is equivalent to
Vips.Region.prepare
(), followed by a memcpy. It is convenient for language bindings.
- image(r)¶
- Parameters:
r (
Vips.Rect
) –Vips.Rect
of pixels you need to be able to address- Returns:
0 on success, or -1 for error.
- Return type:
The region is transformed so that at least r pixels are available to be read from the image. The image needs to be a memory buffer or represent a file on disc that has been mapped or can be mapped.
- invalidate()¶
Mark a region as containing invalid pixels. Calling this function means that the next time
Vips.Region.prepare
() is called, the region will be recalculated.This is faster than calling
Vips.Image.invalidate_all
(), but obviously only affects a single region.See also:
Vips.Image.invalidate_all
(),Vips.Region.prepare
().
- paint(r, value)¶
-
Paints value into self covering rectangle r. r is clipped against self->valid.
For int images, value is passed to memset(), so it usually needs to be 0 or 255. For float images, value is cast to a float and copied in to each band element.
r is clipped against self->valid.
See also:
Vips.Region.black
().
- paint_pel(r, ink)¶
-
Paints ink into self covering rectangle r. r is clipped against self->valid.
ink should be a byte array of the same size as an image pixel containing the binary value to write into the pixels.
See also:
Vips.Region.paint
().
- position(x, y)¶
- Parameters:
- Returns:
0 on success, or -1 for error.
- Return type:
Set the position of a region. This only affects reg->valid, ie. the way pixels are addressed, not reg->data, the pixels which are addressed. Clip against the size of the image. Do not allow negative positions, or positions outside the image.
- prepare(r)¶
- Parameters:
r (
Vips.Rect
) –Vips.Rect
of pixels you need to be able to address- Returns:
0 on success, or -1 on error.
- Return type:
Vips.Region.prepare
() fills self with pixels. After calling, you can address at least the area r with VIPS_REGION_ADDR() and get valid pixels.Vips.Region.prepare
() runs in-line, that is, computation is done by the calling thread, no new threads are involved, and computation blocks until the pixels are ready.Use vips_sink_screen() to calculate an area of pixels in the background.
See also: vips_sink_screen(),
Vips.Region.prepare_to
().
- prepare_to(dest, r, x, y)¶
- Parameters:
dest (
Vips.Region
) – region to write tor (
Vips.Rect
) –Vips.Rect
of pixels you need to be able to addressx (
int
) – position of r in desty (
int
) – position of r in dest
- Returns:
0 on success, or -1 on error
- Return type:
Like
Vips.Region.prepare
(): fill self with the pixels in area r.Unlike
Vips.Region.prepare
(), rather than writing the result to self, the pixels are written into dest at offset x, y.Also unlike
Vips.Region.prepare
(), dest is not set up for writing for you withVips.Region.buffer
(). You can point dest at anything, and pixels really will be written there. This makesVips.Region.prepare_to
() useful for making the ends of pipelines.See also:
Vips.Region.prepare
(), vips_sink_disc().
- region(dest, r, x, y)¶
- Parameters:
dest (
Vips.Region
) – region to connect tor (
Vips.Rect
) –Vips.Rect
of pixels you need to be able to addressx (
int
) – position of r in desty (
int
) – position of r in dest
- Returns:
0 on success, or -1 for error.
- Return type:
Make VIPS_REGION_ADDR() on self go to dest instead.
r is the part of self which you want to be able to address (this effectively becomes the valid field), (x, y) is the top LH corner of the corresponding area in dest.
Performs all clipping necessary to ensure that self->valid is indeed valid.
If the region we attach to is moved or destroyed, we can be left with dangling pointers! If the region we attach to is on another image, the two images must have the same sizeof(pel).
- shrink_method(to, target, method)¶
- Parameters:
to (
Vips.Region
) – destination regionmethod (
Vips.RegionShrink
) – method to use when generating target pixels
- Returns:
- to:
destination region
- Return type:
(
int
, to:Vips.Region
)
Write the pixels target in to from the x2 larger area in self. Non-complex uncoded images and LABQ only. Images with alpha (see
Vips.Image.hasalpha
()) shrink with pixels scaled by alpha to avoid fringing.method selects the method used to do the 2x2 shrink.
See also:
Vips.Region.copy
().