![]() |
![]() |
![]() |
VIPS Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
#include <vips/vips.h> VipsRegion; VipsRegionClass; VipsRegion * vips_region_new (VipsImage *image
); int vips_region_buffer (VipsRegion *reg
,VipsRect *r
); int vips_region_image (VipsRegion *reg
,VipsRect *r
); int vips_region_region (VipsRegion *reg
,VipsRegion *dest
,VipsRect *r
,int x
,int y
); int vips_region_equalsregion (VipsRegion *reg1
,VipsRegion *reg2
); int vips_region_position (VipsRegion *reg
,int x
,int y
); void vips_region_paint (VipsRegion *reg
,VipsRect *r
,int value
); void vips_region_paint_pel (VipsRegion *reg
,VipsRect *r
,VipsPel *ink
); void vips_region_black (VipsRegion *reg
); void vips_region_copy (VipsRegion *reg
,VipsRegion *dest
,VipsRect *r
,int x
,int y
); int vips_region_prepare (VipsRegion *reg
,VipsRect *r
); int vips_region_prepare_to (VipsRegion *reg
,VipsRegion *dest
,VipsRect *r
,int x
,int y
); int vips_region_prepare_many (VipsRegion **reg
,VipsRect *r
); #define VIPS_REGION_LSKIP (R) #define VIPS_REGION_N_ELEMENTS (R) #define VIPS_REGION_SIZEOF_LINE (R) #define VIPS_REGION_ADDR (R, X, Y) #define VIPS_REGION_ADDR_TOPLEFT (R)
A VipsRegion is a small part of an image and some pixels. You use regions to read pixels out of images without having to have the whole image in memory at once.
A region can be a memory buffer, part of a memory-mapped file, part of some other image, or part of some other region.
Regions must be created, used and freed all within the same thread, since
they can reference private per-thread caches. VIPS sanity-checks region
ownership in various places, so you are likely to see g_assert()
errors if
you don't follow this rule.
There is API to transfer ownership of regions between threads, but hopefully this is only needed within VIPS, so we don't expose it. Hopefully.
typedef struct { /* Users may read these two fields. */ VipsImage *im; /* Link back to parent image */ VipsRect valid; /* Area of parent we can see */ /* The rest of VipsRegion is private. */ } VipsRegion;
A small part of a VipsImage. 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()
.
VipsRegion * vips_region_new (VipsImage *image
);
Create a region. VipsRegion s start out empty, you need to call
vips_region_prepare()
to fill them with pixels.
See also: vips_region_prepare()
.
|
image to create this region on |
int vips_region_buffer (VipsRegion *reg
,VipsRect *r
);
The region is transformed so that at least r
pixels are available as a
memory buffer.
|
region to operate upon |
|
VipsRect of pixels you need to be able to address |
Returns : |
0 on success, or -1 for error. |
int vips_region_image (VipsRegion *reg
,VipsRect *r
);
The region is transformed so that at least r
pixels are available directly
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.
|
region to operate upon |
|
VipsRect of pixels you need to be able to address |
Returns : |
0 on success, or -1 for error. |
int vips_region_region (VipsRegion *reg
,VipsRegion *dest
,VipsRect *r
,int x
,int y
);
Make VIPS_REGION_ADDR()
on reg
go to dest
instead.
r
is the part of reg
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 reg->valid
is indeed
valid.
If the region we attach to is modified, 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 ).
|
region to operate upon |
|
region to connect to |
|
VipsRect of pixels you need to be able to address |
|
postion of r in dest
|
|
postion of r in dest
|
Returns : |
0 on success, or -1 for error. |
int vips_region_equalsregion (VipsRegion *reg1
,VipsRegion *reg2
);
Do two regions point to the same piece of image? ie.
1 2 3 4 5 6 |