2022-06-27 09:48:18 +11:00
|
|
|
/*
|
|
|
|
warp0.c
|
|
|
|
---------------
|
|
|
|
diverses deformations d'image.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "../tthimage.h"
|
|
|
|
|
|
|
|
#ifndef DEBUG_LEVEL
|
|
|
|
#define DEBUG_LEVEL 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* bon, caisse que peut bien faire ce truc ?
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Image_warp_essai_0(Image_Desc *src, Image_Desc *dst, double angle,
|
|
|
|
int xc, int yc)
|
|
|
|
{
|
|
|
|
int x, y, r, g, b;
|
|
|
|
long lfoo;
|
2022-07-07 21:52:00 +11:00
|
|
|
double arad, dheight, dwidth, tmax, dist;
|
2022-06-27 09:48:18 +11:00
|
|
|
int ofx, ofy;
|
|
|
|
|
|
|
|
dheight = (double)dst->height;
|
|
|
|
dwidth = (double)dst->width;
|
|
|
|
|
|
|
|
lfoo = ((dst->height*dst->height)+(dst->width*dst->width));
|
|
|
|
tmax = sqrt((double)lfoo) / 2.0;
|
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
#if DEBUG_LEVEL
|
2022-06-27 09:48:18 +11:00
|
|
|
fprintf(stderr, "%s : %d,%d dh = %f dw = %f tmax = %f\n", __func__,
|
|
|
|
xc, yc, dheight, dwidth, tmax);
|
2022-07-07 21:52:00 +11:00
|
|
|
#endif
|
2022-06-27 09:48:18 +11:00
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
for (y=0; y<dst->height; y++) {
|
|
|
|
/* printf("------- Ligne %d -----------------\n", y); */
|
2022-06-27 09:48:18 +11:00
|
|
|
arad = ((double)y / dheight) * M_PI;
|
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
for (x=0; x<dst->width; x++) {
|
2022-06-27 09:48:18 +11:00
|
|
|
dist = (double)x / dwidth;
|
|
|
|
|
|
|
|
ofx = xc + (int)(sin(arad)*dist*tmax);
|
|
|
|
ofy = yc + (int)(cos(arad)*dist*tmax);
|
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
/* printf("%15f %15f %6d %6d\n", arad, dist, ofx, ofy); */
|
2022-06-27 09:48:18 +11:00
|
|
|
|
|
|
|
if ( ofx>=0 && ofx<src->width && ofy>=0 && ofy<src->height )
|
|
|
|
{
|
|
|
|
Image_getRGB(src, ofx, ofy, &r, &g, &b);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = g = b = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Image_plotRGB(dst, x, y, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
return FUNC_IS_BETA;
|
2022-06-27 09:48:18 +11:00
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
int
|
|
|
|
Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle)
|
|
|
|
{
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "Warp 1: what I can do here ?\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return FUNC_NOT_FINISH;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* voir aussi les module scale.c et warp1.c
|
|
|
|
*/
|
|
|
|
/*::------------------------------------------------------------------::*/
|