libgta
1.0.9
Read and Write Generic Tagged Array (GTA) files
|
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
uintmax_t dimensions[] = { 256, 128 };
void *data;
uintmax_t x, y;
FILE *f;
return 1;
}
return 1;
}
return 1;
}
if (!data) {
return 1;
}
for (y = 0; y < 128; y++) {
for (x = 0; x < 256; x++) {
uintmax_t indices[] = { x, y };
pixel[0] = x;
pixel[1] = 2 * y;
pixel[2] = 128;
}
}
return 1;
}
return 1;
}
return 1;
}
f = fopen("rgb.gta", "wb");
if (!f) {
return 1;
}
return 1;
}
return 1;
}
if (fclose(f) != 0) {
return 1;
}
free(data);
f = fopen("rgb.gta", "rb");
if (!f) {
return 1;
}
return 1;
}
return 1;
}
return 1;
}
return 1;
}
if (!data) {
return 1;
}
return 1;
}
if (fclose(f) != 0) {
return 1;
}
free(data);
return 0;
}
gta_type_t gta_get_component_type(const gta_header_t *restrict header, uintmax_t i)
Get the type of a component.
void gta_set_compression(gta_header_t *restrict header, gta_compression_t compression)
Set the compression.
gta_result_t gta_set_dimensions(gta_header_t *restrict header, uintmax_t n, const uintmax_t *restrict sizes)
Set the dimensions.
void gta_destroy_header(gta_header_t *restrict header)
Destroy a GTA header structure and free its resources.
gta_result_t
GTA result type.
Definition: gta.h:214
gta_result_t gta_set_tag(gta_taglist_t *restrict taglist, const char *restrict name, const char *restrict value)
Set a tag.
gta_result_t gta_write_data_to_stream(const gta_header_t *restrict header, const void *restrict data, FILE *restrict f)
Write the complete data to a stream.
void * gta_get_element(const gta_header_t *restrict header, void *restrict data, const uintmax_t *restrict indices)
Get the address of an array element (modifiable).
@ GTA_OK
Success / no error.
Definition: gta.h:215
uintmax_t gta_get_dimensions(const gta_header_t *restrict header)
Get the number of dimensions.
gta_result_t gta_read_data_from_stream(const gta_header_t *restrict header, void *restrict data, FILE *restrict f)
Read the complete data from a stream.
gta_result_t gta_read_header_from_stream(gta_header_t *restrict header, FILE *restrict f)
Read a GTA header from a stream.
uintmax_t gta_get_components(const gta_header_t *restrict header)
Get the number of components.
uintmax_t gta_get_dimension_size(const gta_header_t *restrict header, uintmax_t i)
Get the size in a dimension.
uintmax_t gta_get_data_size(const gta_header_t *restrict header)
Get the total size of the array data.
struct gta_internal_header_struct gta_header_t
The GTA header type.
Definition: gta.h:194
gta_result_t gta_create_header(gta_header_t *restrict *restrict header)
Create a new GTA header structure and initialize it.
gta_result_t gta_write_header_to_stream(const gta_header_t *restrict header, FILE *restrict f)
Write a GTA header to a stream.
gta_taglist_t * gta_get_component_taglist(gta_header_t *restrict header, uintmax_t i)
Get the tag list of a component (modifiable).
@ GTA_BZIP2
BZIP2 compression (moderate speed, good compression rates)
Definition: gta.h:315
@ GTA_UINT8
uint8_t
Definition: gta.h:273
gta_result_t gta_set_components(gta_header_t *restrict header, uintmax_t n, const gta_type_t *restrict types, const uintmax_t *restrict sizes)
Set the components of an array element.
gta_type_t
GTA data types.
Definition: gta.h:271