Top | Description | Object Hierarchy | ![]() | ![]() | ![]() | ![]() |
VipsRegion * | vips_region_new () |
int | vips_region_buffer () |
int | vips_region_image () |
int | vips_region_region () |
int | vips_region_equalsregion () |
int | vips_region_position () |
void | vips_region_paint () |
void | vips_region_paint_pel () |
void | vips_region_black () |
void | vips_region_copy () |
int | vips_region_shrink_method () |
int | vips_region_shrink () |
int | vips_region_prepare () |
int | vips_region_prepare_to () |
VipsPel * | vips_region_fetch () |
int | vips_region_width () |
int | vips_region_height () |
void | vips_region_invalidate () |
#define | VIPS_COUNT_PIXELS() |
#define | VIPS_REGION_LSKIP() |
#define | VIPS_REGION_N_ELEMENTS() |
#define | VIPS_REGION_SIZEOF_ELEMENT() |
#define | VIPS_REGION_SIZEOF_PEL() |
#define | VIPS_REGION_SIZEOF_LINE() |
#define | VIPS_REGION_ADDR() |
#define | VIPS_REGION_ADDR_TOPLEFT() |
AVipsRegion is a small part of an image. You use regions toread pixels out of images without having to have the whole image in memoryat once.
A region can be a memory buffer, part of a memory-mapped file, part of someother image, or part of some other region.
Regions must be created, used and freed all within the same thread, sincethey can reference private per-thread caches. VIPS sanity-checks regionownership in various places, so you are likely to seeg_assert()
errors ifyou don't follow this rule.
Thereis API to transfer ownership of regions between threads, but hopefully thisis only needed within VIPS, so we don't expose it. Hopefully.
VipsRegion *vips_region_new (VipsImage *image
);
Create a region.VipsRegion s start out empty, you need to callvips_region_prepare()
to fill them with pixels.
See also:vips_region_prepare()
.
intvips_region_buffer (VipsRegion *reg
,constVipsRect *r
);
The region is transformed so that at leastr
pixels are available as amemory buffer that can be written to.
intvips_region_image (VipsRegion *reg
,constVipsRect *r
);
The region is transformed so that at leastr
pixels are available to beread from the image. The image needs to be a memory buffer or represent afile on disc that has been mapped or can be mapped.
intvips_region_region (VipsRegion *reg
,VipsRegion *dest
,constVipsRect *r
,int x
,int y
);
MakeVIPS_REGION_ADDR()
onreg
go todest
instead.
r
is the part ofreg
which you want to be able to address (thiseffectively becomes the valid field), (x
,y
) is the top LH corner of thecorresponding area indest
.
Performs all clipping necessary to ensure thatreg->valid
is indeedvalid.
If the region we attach to is moved or destroyed, we can be left withdangling pointers! If the region we attach to is on another image, thetwo images must have the same sizeof(pel).
reg | region to operate upon | |
dest | region to connect to | |
r | VipsRect of pixels you need to be able to address | |
x | position of | |
y | position of |
intvips_region_equalsregion (VipsRegion *reg1
,VipsRegion *reg2
);
Do two regions point to the same piece of image? ie.
123 | VIPS_REGION_ADDR(reg1,x,y)==VIPS_REGION_ADDR(reg2,x,y)&&*VIPS_REGION_ADDR(reg1,x,y)==*VIPS_REGION_ADDR(reg2,x,y)forallx,y,reg1,reg2. |
intvips_region_position (VipsRegion *reg
,int x
,int y
);
Set the position of a region. This only affects reg->valid, ie. the waypixels are addressed, not reg->data, the pixels which are addressed. Clipagainst the size of the image. Do not allow negative positions, orpositions outside the image.
voidvips_region_paint (VipsRegion *reg
,constVipsRect *r
,int value
);
Paintsvalue
intoreg
covering rectangler
.r
is clipped againstreg->valid
.
For int images,value
ispassed tomemset()
, 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 againstreg->valid
.
See also:vips_region_black()
.
voidvips_region_paint_pel (VipsRegion *reg
,constVipsRect *r
,constVipsPel *ink
);
Paintsink
intoreg
covering rectangler
.r
is clipped againstreg->valid
.
ink
should be a byte array of the same size as an image pixel containingthe binary value to write into the pixels.
See also:vips_region_paint()
.
voidvips_region_black (VipsRegion *reg
);
Paints 0 into the valid part ofreg
.
See also:vips_region_paint()
.
voidvips_region_copy (VipsRegion *reg
,VipsRegion *dest
,constVipsRect *r
,int x
,int y
);
Copy from one region to another. Copy arear
from insidereg
todest
,positioning the area of pixels atx
,y
. The two regions must have pixelswhich are the same size.
See also:vips_region_paint()
.
intvips_region_shrink_method (VipsRegion *from
,VipsRegion *to
,constVipsRect *target
,VipsRegionShrink method
);
Write the pixelstarget
into
from the x2 larger area infrom
.Non-complex uncoded images and LABQ only. Images with alpha (seevips_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()
.
intvips_region_shrink (VipsRegion *from
,VipsRegion *to
,constVipsRect *target
);
Write the pixelstarget
into
from the x2 larger area infrom
.Non-complex uncoded images and LABQ only. Images with alpha (seevips_image_hasalpha()
) shrink with pixels scaled by alpha to avoid fringing.
This is a compatibility stub that just callsvips_region_shrink_method()
.
See also:vips_region_shrink_method()
.
intvips_region_prepare (VipsRegion *reg
,constVipsRect *r
);
vips_region_prepare() fillsreg
with pixels. After calling,you can address at least the arear
withVIPS_REGION_ADDR()
and getvalid pixels.
vips_region_prepare() runs in-line, that is, computation is done bythe calling thread, no new threads are involved, and computationblocks until the pixels are ready.
Usevips_sink_screen()
to calculate an area of pixels in thebackground.
See also:vips_sink_screen()
,vips_region_prepare_to()
.
intvips_region_prepare_to (VipsRegion *reg
,VipsRegion *dest
,constVipsRect *r
,int x
,int y
);
Likevips_region_prepare()
: fillreg
with the pixels in arear
.
Unlikevips_region_prepare()
, rather than writing the result toreg
, thepixels are written intodest
at offsetx
,y
.
Also unlikevips_region_prepare()
,dest
is not set up for writing foryou withvips_region_buffer()
. You canpointdest
at anything, and pixels really will be written there.This makesvips_region_prepare_to()
useful for making the ends ofpipelines.
See also:vips_region_prepare()
,vips_sink_disc()
.
reg | region to prepare | |
dest | region to write to | |
r | VipsRect of pixels you need to be able to address | |
x | position of | |
y | position of |
VipsPel *vips_region_fetch (VipsRegion *region
,int left
,int top
,int width
,int height
,size_t *len
);
Generate an area of pixels and return a copy. The result must be freedwithg_free()
. The requested area must be completely inside the image.
This is equivalent tovips_region_prepare()
, followed by a memcpy. It isconvenient for language bindings.
voidvips_region_invalidate (VipsRegion *reg
);
Mark a region as containing invalid pixels. Calling this function meansthat the next timevips_region_prepare()
is called, the region will berecalculated.
This is faster than callingvips_image_invalidate_all()
, but obviously onlyaffects a single region.
#define VIPS_REGION_ADDR(R, X, Y)
This macro returns a pointer to a pixel in a region. The (X
,Y
)coordinates need to be within theVipsRect (R->valid
).
If DEBUG is defined, you get a version that checks bounds for you.
See also:vips_region_prepare()
.
#define VIPS_REGION_ADDR_TOPLEFT(R) ((R)->data)
This macro returns a pointer to the top-left pixel in theVipsRegion, thatis, the pixel at (R->valid.left
,R->valid.top
).
See also:vips_region_prepare()
.