libgutenprint API Reference  5.2.10
Typedefs | Functions
array

The array is a simple "two-dimensional array of numbers" data structure. More...

Typedefs

typedef struct stp_array stp_array_t
 The array opaque data type. More...
 

Functions

stp_array_tstp_array_create (int x_size, int y_size)
 Create a new array. More...
 
void stp_array_destroy (stp_array_t *array)
 Destroy an array. More...
 
void stp_array_copy (stp_array_t *dest, const stp_array_t *source)
 Copy an array. More...
 
stp_array_tstp_array_create_copy (const stp_array_t *array)
 Copy and allocate an array. More...
 
void stp_array_set_size (stp_array_t *array, int x_size, int y_size)
 Resize an array. More...
 
void stp_array_get_size (const stp_array_t *array, int *x_size, int *y_size)
 Get the size of an array. More...
 
void stp_array_set_data (stp_array_t *array, const double *data)
 Set the data in an array. More...
 
void stp_array_get_data (const stp_array_t *array, size_t *size, const double **data)
 Get the data in an array. More...
 
int stp_array_set_point (stp_array_t *array, int x, int y, double data)
 Set the data at a single point in the array. More...
 
int stp_array_get_point (const stp_array_t *array, int x, int y, double *data)
 Get the data at a single point in the array. More...
 
const stp_sequence_tstp_array_get_sequence (const stp_array_t *array)
 Get the underlying stp_sequence_t. More...
 

Detailed Description

The array is a simple "two-dimensional array of numbers" data structure.

array "inherits" from the sequence data structure (implemented via containment).

Typedef Documentation

typedef struct stp_array stp_array_t

The array opaque data type.

Function Documentation

void stp_array_copy ( stp_array_t dest,
const stp_array_t source 
)

Copy an array.

Both dest and source must be valid arrays previously created with stp_array_create().

Parameters
destthe destination array.
sourcethe source array.
stp_array_t* stp_array_create ( int  x_size,
int  y_size 
)

Create a new array.

The total size of the array will be (x_size * y_size).

Parameters
x_sizethe number of "columns".
y_sizethe number of "rows".
Returns
the newly created array.
stp_array_t* stp_array_create_copy ( const stp_array_t array)

Copy and allocate an array.

dest will be created, and then the contents of source will be copied into it. dest must not have been previously allocated with stp_array_create().

Parameters
arraythe source array.
Returns
the new copy of the array.
void stp_array_destroy ( stp_array_t array)

Destroy an array.

It is an error to destroy the array more than once.

Parameters
arraythe array to destroy.
void stp_array_get_data ( const stp_array_t array,
size_t *  size,
const double **  data 
)

Get the data in an array.

Parameters
arraythe array to get the data from.
sizethe number of elements in the array (x_size * y_size) are stored in the size_t pointed to.
dataa pointer to the first element of an array of doubles is stored in a pointer to double*.
stp_array_t *array;
size_t size;
double *data;
stp_array_get_data(array, &size, &data);
int stp_array_get_point ( const stp_array_t array,
int  x,
int  y,
double *  data 
)

Get the data at a single point in the array.

Parameters
arraythe array to use.
xthe x location.
ythe y location.
datathe datum is stored in the double pointed to.
Returns
1 on success, 0 on failure.
const stp_sequence_t* stp_array_get_sequence ( const stp_array_t array)

Get the underlying stp_sequence_t.

Parameters
arraythe array to use.
Returns
the (constant) stp_sequence_t.
void stp_array_get_size ( const stp_array_t array,
int *  x_size,
int *  y_size 
)

Get the size of an array.

The current x and y sizes are stored in the integers pointed to by x_size and y_size.

Parameters
arraythe array to get the size of.
x_sizea pointer to an integer to store the x size in.
y_sizea pointer to an integer to store the y size in.
void stp_array_set_data ( stp_array_t array,
const double *  data 
)

Set the data in an array.

Parameters
arraythe array to set.
dataa pointer to the first member of an array containing the data to set. This array must be at least as long as (x_size
  • y_size).
int stp_array_set_point ( stp_array_t array,
int  x,
int  y,
double  data 
)

Set the data at a single point in the array.

Parameters
arraythe array to use.
xthe x location.
ythe y location.
datathe datum to set.
Returns
1 on success, 0 on failure.
void stp_array_set_size ( stp_array_t array,
int  x_size,
int  y_size 
)

Resize an array.

Resizing an array will destroy all data stored in the array.

Parameters
arraythe array to resize.
x_sizethe new number of "columns".
y_sizethe new number of "rows".