Movatterモバイル変換


[0]ホーム

URL:


libvips

A fast image processing library with low memory needs.

DownloadInstallDocumentationIssuesWikilibvips projectslibvips on GitHub
Top  | DescriptionHomeUpPrevNext

generate

generate — calculate pixels and pixel buffers

Stability Level

Stable, unless otherwise indicated

Functions

int(*VipsRegionWrite) ()
intvips_sink_disc ()
intvips_sink ()
intvips_sink_tile ()
void(*VipsSinkNotify) ()
intvips_sink_screen ()
intvips_sink_memory ()
void *vips_start_one ()
intvips_stop_one ()
void *vips_start_many ()
intvips_stop_many ()
VipsImage **vips_allocate_input_array ()
intvips_image_generate ()
intvips_image_pipeline_array ()
intvips_image_pipelinev ()

Includes

#include <vips/vips.h>

Description

These functions let you attach generate functions to imagesand ask for regions of images to be calculated.

Functions

VipsRegionWrite ()

int(*VipsRegionWrite) (VipsRegion *region,VipsRect *area,void *a);

The function should write the pixels inarea fromregion.a is thevalue passed intovips_sink_disc().

See also:vips_sink_disc().

Parameters

region

get pixels from here

 

area

area to write

 

a

client data

 

Returns

0 on success, -1 on error.


vips_sink_disc ()

intvips_sink_disc (VipsImage *im,VipsRegionWrite write_fn,void *a);

vips_sink_disc() loops overim, top-to-bottom, generating it in sections.As each section is produced,write_fn is called.

write_fn is always called single-threaded (though not always from the samethread), it's always given imagesections in top-to-bottom order, and there are never any gaps.

This operation is handy for making image sinks which output to things likedisc files. Things likevips_jpegsave(), for example, use this to writeimages to files in JPEG format.

See also:vips_concurrency_set().

[method]

Parameters

im

image to process

 

write_fn

called for every batch of pixels.

[scope call]

a

client data.

[closure write_fn]

Returns

0 on success, -1 on error.


vips_sink ()

intvips_sink (VipsImage *im,VipsStartFn start_fn,VipsGenerateFn generate_fn,VipsStopFn stop_fn,void *a,void *b);

Loops over an image.generate_fn is called for every pixel inthe image, withthereg argument being a region of calculated pixels.vips_sink() isused to implement operations likevips_avg() which have no image output.

Each set of pixels is sized according to the requirements of the imagepipeline that generatedim.

See also:vips_image_generate(),vips_image_new().

[method]

Parameters

im

scan over this image

 

start_fn

start sequences with this function

 

generate_fn

generate pixels with this function

 

stop_fn

stop sequences with this function

 

a

user data

 

b

user data

 

Returns

0 on success, or -1 on error.


vips_sink_tile ()

intvips_sink_tile (VipsImage *im,int tile_width,int tile_height,VipsStartFn start_fn,VipsGenerateFn generate_fn,VipsStopFn stop_fn,void *a,void *b);

Loops over an image.generate_fn is called for everypixel in the image, withthereg argument being a region of calculated pixels.

Each set of pixels istile_width bytile_height pixels (less at theimage edges). This is handy for things like writing a tiled TIFF image,where tiles have to be generated with a certain size.

See also:vips_sink(),vips_get_tile_size().

[method]

Parameters

im

scan over this image

 

tile_width

tile width

 

tile_height

tile height

 

start_fn

start sequences with this function

 

generate_fn

generate pixels with this function

 

stop_fn

stop sequences with this function

 

a

user data

 

b

user data

 

Returns

0 on success, or -1 on error.


VipsSinkNotify ()

void(*VipsSinkNotify) (VipsImage *im,VipsRect *rect,void *a);

vips_sink_screen ()

intvips_sink_screen (VipsImage *in,VipsImage *out,VipsImage *mask,int tile_width,int tile_height,int max_tiles,int priority,VipsSinkNotify notify_fn,void *a);

This operation rendersin in the background, making pixels available onout as they are calculated. Thenotify_fn callback is run every time a newset of pixels are available. Calculated pixels are kept in a cache withtiles sizedtile_width bytile_height pixels and with at mostmax_tilestiles.Ifmax_tiles is -1, the cache is of unlimited size (up to the maximum imagesize).Themask image is a one-band uchar image and has 255 for pixels which arecurrently in cache and 0 for uncalculated pixels.

Only a single sink is calculated at any one time, though many may bealive. Usepriority to indicate which renders are more important:zero means normalpriority, negative numbers are low priority, positive numbers highpriority.

Calls tovips_region_prepare() onout return immediately and holdwhatever iscurrently in cache for thatVipsRect (checkmask to see which parts of theVipsRect are valid). Any pixels in theVipsRect which are not incache are addedto a queue, and thenotify_fn callback will trigger when those pixels areready.

Thenotify_fn callback is run from one of the background threads. In thecallbackyou need to somehow send a message to the main thread that the pixels areready. In a glib-based application, this is easily done withg_idle_add().

Ifnotify_fn isNULL thenvips_sink_screen() runs synchronously.vips_region_prepare() onout will always block until the pixels have beencalculated.

See also:vips_tilecache(),vips_region_prepare(),vips_sink_disc(),vips_sink().

[method]

Parameters

in

input image

 

out

output image.

[out]

mask

mask image indicating valid pixels

 

tile_width

tile width

 

tile_height

tile height

 

max_tiles

maximum tiles to cache

 

priority

rendering priority

 

notify_fn

pixels are ready notification callback.

[scope call][nullable]

a

client data for callback.

[closure notify_fn][nullable]

Returns

0 on success, -1 on error.


vips_sink_memory ()

intvips_sink_memory (VipsImage *im);

Loops overim, generating it to a memory buffer attached toim. It isused by vips to implement writing to a memory buffer.

See also:vips_sink(),vips_get_tile_size(),vips_image_new_memory().

Parameters

im

generate this image to memory

 

Returns

0 on success, or -1 on error.


vips_start_one ()

void *vips_start_one (VipsImage *out,void *a,void *b);

Start function for one image in. Input image isa.

See also:vips_image_generate().

Parameters

out

image to generate

 

a

user data

 

b

user data

 

vips_stop_one ()

intvips_stop_one (void *seq,void *a,void *b);

Stop function for one image in. Input image isa.

See also:vips_image_generate().

Parameters

seq

sequence value

 

a

user data

 

b

user data

 

vips_start_many ()

void *vips_start_many (VipsImage *out,void *a,void *b);

Start function for many images in.a is a pointer toaNULL-terminated array of input images.

See also:vips_image_generate(),vips_allocate_input_array()

Parameters

out

image to generate

 

a

user data

 

b

user data

 

vips_stop_many ()

intvips_stop_many (void *seq,void *a,void *b);

Stop function for many images in.a is a pointer toaNULL-terminated array of input images.

See also:vips_image_generate().

Parameters

seq

sequence value

 

a

user data

 

b

user data

 

vips_allocate_input_array ()

VipsImage **vips_allocate_input_array (VipsImage *out,...);

Convenience function --- make aNULL-terminated array of input images.Use withvips_start_many().

See also:vips_image_generate(),vips_start_many().

Parameters

out

free array when this image closes

 

...

NULL-terminated list of input images

 

Returns

NULL-terminated array of images. Do not free the result.


vips_image_generate ()

intvips_image_generate (VipsImage *image,VipsStartFn start_fn,VipsGenerateFn generate_fn,VipsStopFn stop_fn,void *a,void *b);

Generates an image. The action depends on the image type.

For images created withvips_image_new(),vips_image_generate() justattaches the start/generate/stop callbacks and returns.

For images created withvips_image_new_memory(), memory is allocated forthe whole image and it is entirely generated usingvips_sink_memory().

For images created withvips_image_new_temp_file() and friends, memory fora few scanlines is allocated andvips_sink_disc() used to generate the image in small chunks. As eachchunk is generated, it is written to disc.

See also:vips_sink(),vips_image_new(),vips_region_prepare().

Parameters

image

generate this image

 

start_fn

start sequences with this function

 

generate_fn

generate pixels with this function

 

stop_fn

stop sequences with this function

 

a

user data

 

b

user data

 

Returns

0 on success, or -1 on error.


vips_image_pipeline_array ()

intvips_image_pipeline_array (VipsImage *image,VipsDemandStyle hint,VipsImage **in);

Add an image to a pipeline.image depends on all of the images inin,image prefers to supply pixels according tohint.

Operations can set demand hints, that is, hints to the VIPS IO system aboutthe type of region geometry they work best with. For example,operations which transform coordinates will usually work best withVIPS_DEMAND_STYLE_SMALLTILE, operations which work on local windows ofpixels will likeVIPS_DEMAND_STYLE_FATSTRIP.

Header fields inimage are set from the fields inin, with lower-numberedimages inin taking priority.For example, ifin[0] andin[1] both have an itemcalled "icc-profile", it's the profile attached toin[0] that will end uponimage.Image history is completely copied from allin.image will have the historyof all the input images.The array of input images can be empty, meaningimage is at the start of apipeline.

VIPS uses the list of input images to build the tree of operations it needsfor the cache invalidation system.

See also:vips_image_pipelinev(),vips_image_generate().

Parameters

image

output image.

[out]

hint

demand hint forimage

 

in

NULL-terminated array of input images.

[array zero-terminated=1]

Returns

0 on success, -1 on error.


vips_image_pipelinev ()

intvips_image_pipelinev (VipsImage *image,VipsDemandStyle hint,...);

Build an array and callvips_image_pipeline_array().

See also:vips_image_generate().

Parameters

image

output image of pipeline

 

hint

hint for this image

 

...

NULL-terminated list of input images

 

See Also

VipsImage,VipsRegion

Generated by GTK-Doc V1.34.0

[8]ページ先頭

©2009-2025 Movatter.jp