Functions provided by the LIBICV image processing library for reading and writing of images.
More...
|
icv_image_t * | icv_create (size_t width, size_t height, ICV_COLOR_SPACE color_space) |
|
icv_image_t * | icv_zero (icv_image_t *bif) |
|
int | icv_destroy (icv_image_t *bif) |
|
int | icv_image_size (const char *label, size_t dpi, size_t data_size, bu_mime_image_t type, size_t *widthp, size_t *heightp) |
|
icv_image_t * | icv_read (const char *filename, bu_mime_image_t format, size_t width, size_t height) |
|
int | icv_write (icv_image_t *bif, const char *filename, bu_mime_image_t format) |
|
int | icv_writeline (icv_image_t *bif, size_t y, void *data, ICV_DATA type) |
|
int | icv_writepixel (icv_image_t *bif, size_t x, size_t y, double *data) |
|
unsigned char * | icv_data2uchar (const icv_image_t *bif) |
|
double * | icv_uchar2double (unsigned char *data, size_t size) |
|
char * | icv_ascii_art (icv_image_t *i, struct icv_ascii_art_params *p) |
|
Functions provided by the LIBICV image processing library for reading and writing of images.
◆ ICV_ASCII_ART_PARAMS_DEFAULT
#define ICV_ASCII_ART_PARAMS_DEFAULT {0, 0, 1.0} |
Definition at line 193 of file io.h.
◆ icv_create()
This function allocates memory for an image and returns the resultant image.
- Parameters
-
width | Width of the image to be created |
height | Height of the image to be created |
color_space | Color space of the image (RGB, grayscale) |
- Returns
- Image structure with allocated space and zeroed data array
◆ icv_zero()
This function zeroes all the data entries of an image
- Parameters
-
◆ icv_destroy()
This function frees the allocated memory for a ICV Structure and data.
◆ icv_image_size()
Function to calculate (or make an educated guess) about the dimensions of an image, when the image doesn't supply such information.
Standard image sizes may be hinted using the label parameter. Many standard print and display sizes (e.g., "A4" and "SVGA") are recognized and used in concert with the dpi and data_size parameters.
- Parameters
-
[in] | label | String hinting at a size (pass NULL if not using) |
[in] | dpi | Dots per inch of image (pass 0 if not using) |
[in] | data_size | Number of uncompressed image bytes (necessary if deducing an unspecified image size) |
[in] | type | Image type (necessary if deducing an unspecified image size) |
[out] | widthp | Pointer to variable that will hold image width |
[out] | heightp | Pointer to variable that will hold image height |
- Returns
- Returns 1 if an image size was identified, zero otherwise.
◆ icv_read()
Load a file into an ICV struct. For most formats, this will be called with format=ICV_IMAGE_AUTO.
The data is packed in icv_image struct in double format with varied channels as per the specification of image to be loaded.
To read stream from stdin pass NULL pointer for filename.
In case of bw and pix image if size is unknown pass 0 for width and height. This will read the image till EOF is reached. The image size of the output image will be : height = 1; width = size; where size = total bytes read
- Parameters
-
filename | File to read |
format | Probable format of the file, typically ICV_IMAGE_AUTO |
width | Width when passed as parameter from calling program. |
height | Height when passed as parameter from calling program. |
- Returns
- A newly allocated struct holding the loaded image info.
◆ icv_write()
Saves Image to a file or streams to stdout in respective format
To stream it to stdout pass NULL pointer for filename.
- Parameters
-
bif | Image structure of file. |
filename | Filename of the file to be written. |
format | Specific format of the file to be written. |
- Returns
- on success 0, on failure -1 with log messages.
◆ icv_writeline()
Write an image line to the data of ICV struct. Can handle unsigned char buffers.
Note : This function requires memory allocation for ICV_UCHAR_DATA, which in turn acquires BU_SEM_SYSCALL semaphore.
- Parameters
-
bif | ICV struct where data is to be written |
y | Index of the line at which data is to be written. 0 for the first line |
data | Line Data to be written |
type | Type of data, e.g., uint8 data specify ICV_DATA_UCHAR or 1 |
- Returns
- on success 0, on failure -1
◆ icv_writepixel()
Writes a pixel to the specified coordinates in the data of ICV struct.
- Parameters
-
bif | ICV struct where data is to be written |
x | x-dir coordinate of the pixel |
y | y-dir coordinate of the pixel. (0,0) coordinate is taken as bottom left |
data | Data to be written |
- Returns
- on success 0, on failure -1
◆ icv_data2uchar()
Converts double data of icv_image to unsigned char data. This function also does gamma correction using the gamma_corr parameter of the image structure.
Gamma correction prevents bad color aliasing.
- Parameters
-
bif | ICV struct where data is to be read from |
- Returns
- array of unsigned char converted data, or NULL on failure
◆ icv_uchar2double()
Converts unsigned char array to double array. This function returns array of double data.
Used to convert data from pix, bw, ppm type images for icv_image struct.
This does not free the char data.
- Parameters
-
data | pointer to the array to be converted. |
size | Size of the array. |
- Returns
- double array.
◆ icv_ascii_art()
Converts the image to an ASCII art text string. This function returns a char array - it is the caller's responsibility to free it.
Note that this function does not attempt to correct for the aspect ratio problem (character printing in terminals often will result in the image being "stretched" in height.) If the use case calls for that, the application should use icv_resize to adjust the image before calling icv_ascii_art. (See the ascii libicv test code for an example.)
- Parameters
-
i | ICV image data. |
p | ASCII text generation parameters. |
- Returns
- char array.