This commit is contained in:
tTh 2024-05-01 21:40:44 +02:00
parent 11e87efd67
commit 4f27e491b1
5 changed files with 32 additions and 18 deletions

View File

@ -1,4 +1,25 @@
# Floatimg, the base library
# Floatimg, the base/core library
## Data structures
Image's pixels (floating point number, a `float` for C)
are ordonned as an array of lines of single
componant values. Every componant is in a separate array,
who are *glued* together by an in-memory image descriptor.
```
#define MAGIC_FIMG 0x00F11F00
typedef struct {
uint32_t magic;
int width;
int height;
int type;
float fval;
int count;
float *R, *G, *B, *A;
FimgMetaData mdatas; // added 20230912
int reserved;
} FloatImg;
```
Need more explanations...

View File

@ -17,6 +17,7 @@ extern int verbosity; /* must be declared around main() */
/* --------------------------------------------------------------------- */
/*
* floating resultat img MUST be allocated before calling this func.
* and MUST be of type 'gray image'.
*/
int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
{
@ -43,15 +44,12 @@ if (FIMG_TYPE_RGB != src->type) {
if (FIMG_TYPE_GRAY != dst->type) {
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
dst->type, dst);
/*
* may be we can convert dst picture on the fly ?
*/
/* may be we can convert dst picture on the fly ? */
return -9;
}
/* entering the main processing loop */
nbb = src->width * src->height;
for (foo=0; foo<nbb; foo++) {
dst->R[foo] = ( (src->R[foo] * kr) +
(src->G[foo] * kg) +
@ -79,7 +77,6 @@ if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) {
/* entering the main processing loop */
nbb = src->width * src->height;
for (foo=0; foo<nbb; foo++) {
dst->R[foo] = dst->G[foo] = dst->B[foo] =
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;

View File

@ -87,15 +87,15 @@ if (FIMG_TYPE_RGB != fimg->type) {
/* OK, we have to make a fake metadata chunk, if the caller
* don't have one. Ugly, and nice */
if (NULL == pmd) {
fprintf(stderr, ">>> %s making faked metadata\n", __func__);
// fprintf(stderr, ">>> %s making faked metadata\n", __func__);
foo = fimg_default_metadata(&fakemd, 3);
fprintf(stderr, "fakemd is at %p\n", &fakemd);
// fprintf(stderr, "fakemd is at %p\n", &fakemd);
pmd = &fakemd;
}
else {
/* OK, get some funky metadatas */
// fprintf(stderr, "%s get metadatas\n", __func__);
fprintf(stderr, "acqu fval=%f count=%d\n", pmd->fval, pmd->count);
fprintf(stderr, "%s: acqu fval=%f count=%d\n", __func__,
pmd->fval, pmd->count);
}
fp = fopen(fname, "w");

View File

@ -201,9 +201,7 @@ if (head->type != FIMG_TYPE_RGB) {
}
for (foo=0; foo<(head->width*head->height); foo++) {
add = head->R[foo];
add += head->G[foo];
add += head->B[foo];
add = head->R[foo] + head->G[foo] + head->B[foo];
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
}
return 0;
@ -410,7 +408,6 @@ for (idx=0; idx<surface; idx++) {
return 0;
}
/* ---------------------------------------------------------------- */
/* Warning: this function is _very_ slow */
void fimg_drand48(FloatImg *fi, float kmul)
{
@ -434,7 +431,6 @@ for (idx=0; idx<nbre; idx++) {
fi->G[idx] = drand48() * kmul;
fi->B[idx] = drand48() * kmul;
}
}
/* ---------------------------------------------------------------- */

View File

@ -35,7 +35,7 @@ if (notused) {
notused, __func__);
}
if (NULL != title) {
fprintf(stderr, "==== metadate for %s\n", title);
fprintf(stderr, "======== metadata for %s\n", title);
}
if (verbosity) {
fprintf(stderr, "sizeof(metadata) = %ld\n", \
@ -98,7 +98,7 @@ pmd->magic = MAGIC_MDATA;
pmd->cpid = getpid(); // we are the creator, no ?
pmd->count = 1; // mmmm...
pmd->fval = 255.0; // Ok
strcpy(pmd->idcam, "<noname>");
strcpy(pmd->idcam, "<noname camera>");
pmd->origin = 0xdeadbeef; // classic joke, sorry
pmd->reserved[0] = bla;
pmd->reserved[7] = 0x55445544; // magic number is a crime