Compare commits
No commits in common. "3e0b1762d15fc0ee4ce84e2fd2d8d4c81ee2cc3d" and "17263bf2152f048b9bedeffb4838cc5e65498b6e" have entirely different histories.
3e0b1762d1
...
17263bf215
30
src/image.c
30
src/image.c
@ -1,30 +0,0 @@
|
|||||||
#include "image.h"
|
|
||||||
#include "mem_allocator.h"
|
|
||||||
#include "mem_libc.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
Image *create_image(u64 width, u64 height, Pixel *data,
|
|
||||||
const Allocator *allocator) {
|
|
||||||
Allocator alloc;
|
|
||||||
if (!allocator) {
|
|
||||||
alloc = wapp_mem_libc_allocator();
|
|
||||||
} else {
|
|
||||||
alloc = *allocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 buf_length = width * height;
|
|
||||||
u64 total_size = sizeof(Image) + sizeof(Pixel) * buf_length;
|
|
||||||
|
|
||||||
Image *img = wapp_mem_allocator_alloc(&alloc, total_size);
|
|
||||||
if (!img) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
img->width = width;
|
|
||||||
img->height = height;
|
|
||||||
img->buf_length = buf_length;
|
|
||||||
memcpy(img->data, data, buf_length);
|
|
||||||
|
|
||||||
return img;
|
|
||||||
}
|
|
34
src/image.h
34
src/image.h
@ -1,34 +0,0 @@
|
|||||||
#ifndef IMAGE_H
|
|
||||||
#define IMAGE_H
|
|
||||||
|
|
||||||
#include "mem_allocator.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#include "aliases.h"
|
|
||||||
|
|
||||||
typedef struct pixel Pixel;
|
|
||||||
struct pixel {
|
|
||||||
u8 r;
|
|
||||||
u8 g;
|
|
||||||
u8 b;
|
|
||||||
u8 a;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct image Image;
|
|
||||||
struct image {
|
|
||||||
u64 width;
|
|
||||||
u64 height;
|
|
||||||
u64 buf_length;
|
|
||||||
Pixel data[];
|
|
||||||
};
|
|
||||||
|
|
||||||
Image *create_image(u64 width, u64 height, Pixel *data,
|
|
||||||
const Allocator *allocator);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif // !IMAGE_H
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("\t TAG: %04u (%s)\n", fields[i].tag,
|
printf("\t TAG: %04u (%s)\n", fields[i].tag,
|
||||||
tag_names[fields[i].tag] ? tag_names[fields[i].tag] : "UNKNOWN");
|
tag_names[fields[i].tag] ? tag_names[fields[i].tag] : "UNKNOWN");
|
||||||
printf("\t TYPE: 0x%04x (%s)\n", fields[i].type,
|
printf("\t TYPE: 0x%04x (%s)\n", fields[i].type,
|
||||||
filed_types[fields[i].type].name ? filed_types[fields[i].type].name
|
filed_type_names[fields[i].type] ? filed_type_names[fields[i].type]
|
||||||
: "UNKNOWN");
|
: "UNKNOWN");
|
||||||
printf("\t COUNT: %04u\n", fields[i].count);
|
printf("\t COUNT: %04u\n", fields[i].count);
|
||||||
printf("\tVAL/OFF: %04u\n", fields[i].value_offset);
|
printf("\tVAL/OFF: %04u\n", fields[i].value_offset);
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
#ifdef TIFF_TYPE_LOOKUP
|
#ifdef TIFF_TYPE_LOOKUP
|
||||||
#undef TIFF_TYPE
|
#undef TIFF_TYPE
|
||||||
#define TIFF_TYPE(NAME, ID, VALUE, BYTES) [VALUE] = (TiffFieldType){.name = NAME, .byte_count = BYTES},
|
#define TIFF_TYPE(NAME, ID, VALUE) [VALUE] = NAME,
|
||||||
#else
|
#else
|
||||||
#undef TIFF_TYPE
|
#undef TIFF_TYPE
|
||||||
#define TIFF_TYPE(NAME, ID, VALUE, BYTES) ID = VALUE,
|
#define TIFF_TYPE(NAME, ID, VALUE) ID = VALUE,
|
||||||
#endif /* ifdef TIFF_TYPE_LOOKUP */
|
#endif /* ifdef TIFF_TYPE_LOOKUP */
|
||||||
|
|
||||||
TIFF_TYPE("UNSIGNED BYTE" , TIFF_ENTRY_BYTE , 0x0001, 1) // 8-bit unsigned integer
|
TIFF_TYPE("UNSIGNED BYTE" , TIFF_ENTRY_BYTE , 0x0001) // 8-bit unsigned integer
|
||||||
TIFF_TYPE("ASCII" , TIFF_ENTRY_ASCII , 0x0002, 1) // 8-bit byte that contains a 7-bit ASCII code; the last byte must be NUL (binary zero)
|
TIFF_TYPE("ASCII" , TIFF_ENTRY_ASCII , 0x0002) // 8-bit byte that contains a 7-bit ASCII code; the last byte must be NUL (binary zero)
|
||||||
TIFF_TYPE("UNSIGNED SHORT" , TIFF_ENTRY_SHORT , 0x0003, 2) // 16-bit (2-byte) unsigned integer
|
TIFF_TYPE("UNSIGNED SHORT" , TIFF_ENTRY_SHORT , 0x0003) // 16-bit (2-byte) unsigned integer
|
||||||
TIFF_TYPE("UNSIGNED LONG" , TIFF_ENTRY_LONG , 0x0004, 4) // 32-bit (4-byte) unsigned integer
|
TIFF_TYPE("UNSIGNED LONG" , TIFF_ENTRY_LONG , 0x0004) // 32-bit (4-byte) unsigned integer
|
||||||
TIFF_TYPE("UNSIGNED RATIONAL", TIFF_ENTRY_RATIONAL , 0x0005, 8) // Two LONGs: the first represents the numerator of a fraction; the second, the denominator
|
TIFF_TYPE("UNSIGNED RATIONAL", TIFF_ENTRY_RATIONAL , 0x0005) // Two LONGs: the first represents the numerator of a fraction; the second, the denominator
|
||||||
TIFF_TYPE("SIGNED BYTE" , TIFF_ENTRY_SBYTE , 0x0006, 1) // An 8-bit signed (twos-complement) integer
|
TIFF_TYPE("SIGNED BYTE" , TIFF_ENTRY_SBYTE , 0x0006) // An 8-bit signed (twos-complement) integer
|
||||||
TIFF_TYPE("UNDEFINED" , TIFF_ENTRY_UNDEFINED , 0x0007, 1) // An 8-bit byte that may contain anything, depending on the definition of the field
|
TIFF_TYPE("UNDEFINED" , TIFF_ENTRY_UNDEFINED , 0x0007) // An 8-bit byte that may contain anything, depending on the definition of the field
|
||||||
TIFF_TYPE("SIGNED SHORT" , TIFF_ENTRY_SSHORT , 0x0008, 2) // A 16-bit (2-byte) signed (twos-complement) integer
|
TIFF_TYPE("SIGNED SHORT" , TIFF_ENTRY_SSHORT , 0x0008) // A 16-bit (2-byte) signed (twos-complement) integer
|
||||||
TIFF_TYPE("SIGNED LONG" , TIFF_ENTRY_SLONG , 0x0009, 4) // A 32-bit (4-byte) signed (twos-complement) integer
|
TIFF_TYPE("SIGNED LONG" , TIFF_ENTRY_SLONG , 0x0009) // A 32-bit (4-byte) signed (twos-complement) integer
|
||||||
TIFF_TYPE("SIGNED RATIONAL" , TIFF_ENTRY_SRATIONAL , 0x000a, 8) // Two SLONG’s: the first represents the numerator of a fraction, the second the denominator
|
TIFF_TYPE("SIGNED RATIONAL" , TIFF_ENTRY_SRATIONAL , 0x000a) // Two SLONG’s: the first represents the numerator of a fraction, the second the denominator
|
||||||
TIFF_TYPE("FLOAT" , TIFF_ENTRY_FLOAT , 0x000b, 4) // Single precision (4-byte) IEEE format
|
TIFF_TYPE("FLOAT" , TIFF_ENTRY_FLOAT , 0x000b) // Single precision (4-byte) IEEE format
|
||||||
TIFF_TYPE("DOUBLE" , TIFF_ENTRY_DOUBLE , 0x000c, 8) // Double precision (8-byte) IEEE format
|
TIFF_TYPE("DOUBLE" , TIFF_ENTRY_DOUBLE , 0x000c) // Double precision (8-byte) IEEE format
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#ifndef TIFFREAD_H
|
#ifndef TIFFREAD_H
|
||||||
#define TIFFREAD_H
|
#define TIFFREAD_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
|
|
||||||
#define TAG_MAX_COUNT (UINT16_MAX * sizeof(const char *))
|
#define TAG_MAX_COUNT (UINT16_MAX * sizeof(const char *))
|
||||||
@ -41,13 +37,7 @@ enum tiff_field_types {
|
|||||||
#include "tiff_field_types.inc"
|
#include "tiff_field_types.inc"
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct field_type TiffFieldType;
|
const char *filed_type_names[TYPE_MAX_COUNT] = {
|
||||||
struct field_type {
|
|
||||||
const char *name;
|
|
||||||
u16 byte_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
TiffFieldType filed_types[TYPE_MAX_COUNT] = {
|
|
||||||
#define TIFF_TYPE_LOOKUP
|
#define TIFF_TYPE_LOOKUP
|
||||||
#include "tiff_field_types.inc"
|
#include "tiff_field_types.inc"
|
||||||
#undef TIFF_TYPE_LOOKUP
|
#undef TIFF_TYPE_LOOKUP
|
||||||
@ -94,8 +84,4 @@ enum tiff_photometric_interpretation {
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif // !TIFFREAD_H
|
#endif // !TIFFREAD_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user