2022-06-26 11:06:35 +02:00
|
|
|
/*
|
|
|
|
+---------------------------------------+
|
|
|
|
| Effets speciaux sur les images |
|
|
|
|
| deuxieme module |
|
|
|
|
+---------------------------------------+
|
|
|
|
Thierry Boudet <oulala@chez.com>
|
|
|
|
vous pouvez aussi aller regarder 'effects.c' et 'combine.c'
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2022-06-27 00:48:18 +02:00
|
|
|
#include "../tthimage.h"
|
2022-06-26 11:06:35 +02:00
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* la parametre 'table' est un tableau de 6 double. d'accord,
|
|
|
|
* mais quel est donc son contenu ?
|
|
|
|
*/
|
2022-09-17 11:23:21 +02:00
|
|
|
int Image_sinwave_0( Image_Desc *source, Image_Desc * but, double *table )
|
2022-06-26 11:06:35 +02:00
|
|
|
{
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
int foo;
|
|
|
|
#endif
|
|
|
|
int x, y, xb, yb, r, g, b;
|
|
|
|
long outside = 0;
|
|
|
|
double fx, fy, cx, cy;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
Image_dump_descriptor(source, "SinWave 0: source");
|
|
|
|
#endif
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
fprintf(stderr, "-- In %s, table is:\n", __func__);
|
|
|
|
for (foo=0; foo<6; foo++)
|
|
|
|
fprintf(stderr, "\t%4d --> %12.6f\n", foo, table[foo]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cx = (2.0 * M_PI) / (double)source->width;
|
|
|
|
cy = (2.0 * M_PI) / (double)source->height;
|
|
|
|
|
2022-09-17 11:23:21 +02:00
|
|
|
for (x=0; x<source->width; x++) {
|
2022-06-26 11:06:35 +02:00
|
|
|
fx = (double)x + (table[1] * sin(table[4] + (cx * table[0] * (double)x)));
|
|
|
|
xb = floor(fx + 0.5);
|
|
|
|
|
2022-09-17 11:23:21 +02:00
|
|
|
for (y=0; y<source->height; y++) {
|
2022-06-26 11:06:35 +02:00
|
|
|
fy = (double)y + (table[3] * sin(table[5] + cy * table[2] * (double)y));
|
|
|
|
yb = floor(fy + 0.5);
|
|
|
|
|
2022-09-17 11:23:21 +02:00
|
|
|
if ( xb>0 && yb>0 && xb<but->width && yb<but->height ) {
|
2022-06-26 11:06:35 +02:00
|
|
|
r = (source->Rpix[yb])[xb];
|
|
|
|
g = (source->Gpix[yb])[xb];
|
|
|
|
b = (source->Bpix[yb])[xb];
|
|
|
|
|
|
|
|
(but->Rpix[y])[x] = r;
|
|
|
|
(but->Gpix[y])[x] = g;
|
|
|
|
(but->Bpix[y])[x] = b;
|
|
|
|
}
|
2022-09-17 11:23:21 +02:00
|
|
|
else { outside++; }
|
2022-06-26 11:06:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
if (outside)
|
|
|
|
fprintf(stderr, "%s: outside = %ld\n", __func__, outside);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
but->modified = 1;
|
|
|
|
return OLL_KORRECT;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* 11 Octobre 1999
|
|
|
|
* Bon, sur celui-ci, je vais essayer d'expliquer...
|
|
|
|
*
|
|
|
|
* Les parametres sont en deux groupes de 3 dans la table.
|
|
|
|
* mais franchement, j'arrive plus a savoir a quoi ils servent.
|
|
|
|
*/
|
2022-09-17 11:23:21 +02:00
|
|
|
int Image_sinwave_1( Image_Desc *source, Image_Desc * but, double *table )
|
2022-06-26 11:06:35 +02:00
|
|
|
{
|
|
|
|
int foo, x, y, xb, yb, r, g, b;
|
|
|
|
long outside = 0;
|
|
|
|
double fx, fy, dx, dy;
|
|
|
|
int ox, oy;
|
|
|
|
Image_Desc *buffer;
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(source, but)) )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Image SinWave 1: images are differents %d\n", foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((buffer = Image_clone(source, 0)) == NULL )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Image SinWave 1: no mem for buffer\n");
|
|
|
|
return BUFFER_NO_MEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<source->height; y++)
|
|
|
|
{
|
|
|
|
fy = (double)y / (double)source->height * M_PI;
|
|
|
|
dy = sin(fy*table[0]) * table[1];
|
|
|
|
oy = (int)(dy);
|
|
|
|
for (x=0; x<source->width; x++)
|
|
|
|
{
|
|
|
|
xb = x + oy;
|
|
|
|
if (xb >=0 && xb<source->width)
|
|
|
|
{
|
|
|
|
r = (source->Rpix[y])[xb];
|
|
|
|
g = (source->Gpix[y])[xb];
|
|
|
|
b = (source->Bpix[y])[xb];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = g = b = 0;
|
|
|
|
outside++;
|
|
|
|
}
|
|
|
|
(buffer->Rpix[y])[x] = r;
|
|
|
|
(buffer->Gpix[y])[x] = g;
|
|
|
|
(buffer->Bpix[y])[x] = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x=0; x<source->width; x++)
|
|
|
|
{
|
|
|
|
fx = (double)x / (double)source->width * M_PI;
|
|
|
|
dx = sin(fx*table[3]) * table[4];
|
|
|
|
ox = (int)(dx);
|
|
|
|
for (y=0; y<source->height; y++)
|
|
|
|
{
|
|
|
|
yb = y + ox;
|
|
|
|
if (yb >=0 && yb<source->height)
|
|
|
|
{
|
|
|
|
r = (buffer->Rpix[yb])[x];
|
|
|
|
g = (buffer->Gpix[yb])[x];
|
|
|
|
b = (buffer->Bpix[yb])[x];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = g = b = 0;
|
|
|
|
outside++;
|
|
|
|
}
|
|
|
|
(but->Rpix[y])[x] = r;
|
|
|
|
(but->Gpix[y])[x] = g;
|
|
|
|
(but->Bpix[y])[x] = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Image_DeAllocate(buffer); free(buffer);
|
|
|
|
|
|
|
|
but->modified = 1;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
Image_dump_descriptor(but, "SinWave 1: destination");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return OLL_KORRECT;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/* new 10 janvier 2009 - avenue St Exupery */
|
|
|
|
int Image_sinwave_2(Image_Desc *source, Image_Desc *but, double table[])
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(source, but)) ) {
|
|
|
|
fprintf(stderr, "Image SinWave 2: images are differents %d\n", foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" in %s now\n", __func__);
|
|
|
|
|
|
|
|
for (foo=0; foo<6; foo++)
|
|
|
|
{
|
|
|
|
printf(" %d %g\n", foo, table[foo]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FULL_NUCKED;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
int Image_degouline_0(Image_Desc *source, Image_Desc *but, int k1, int k2)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int foo;
|
|
|
|
|
2022-08-22 17:53:30 +02:00
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
|
|
|
|
#endif
|
2022-06-26 11:06:35 +02:00
|
|
|
fprintf(stderr, "Degouline %d %d\n", k1, k2);
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(source, but)) ) {
|
2022-09-17 11:23:21 +02:00
|
|
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
2022-06-26 11:06:35 +02:00
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x=0; x<source->width; x++)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return FULL_NUCKED;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* bon sang, mais ya personne qui va se plonger dans ce code
|
|
|
|
* 100% crade, et en sortir une doc (et des exemples) un peu
|
|
|
|
* utilisables ?
|
|
|
|
*/
|
|
|
|
/*::------------------------------------------------------------------::*/
|