2022-06-27 02:19:31 +02:00
|
|
|
/*
|
|
|
|
cadres4.c
|
|
|
|
=========
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include "../tthimage.h"
|
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* fonction en chantier -> coredump probable
|
2022-10-28 05:53:07 +02:00
|
|
|
* je ne sais pas a quoi va servir le parametre 'flags' ...
|
2022-06-27 02:19:31 +02:00
|
|
|
* 7 nov 2007:
|
|
|
|
* le flag a disparu, il contient maintenant la valeur de
|
|
|
|
* la composante verte. lol.
|
|
|
|
*/
|
2022-10-28 05:53:07 +02:00
|
|
|
int Image_cadre_burp_0(Image_Desc *img, int p1, int p2, int gval)
|
2022-06-27 02:19:31 +02:00
|
|
|
{
|
|
|
|
int x, y, zz, v;
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
2022-10-28 05:53:07 +02:00
|
|
|
fprintf(stderr, ">>> %s ( %p %d %d 0x%02x )\n", __func__, img, p1, p2, gval);
|
2022-06-27 02:19:31 +02:00
|
|
|
#endif
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (x=0; x<img->width; x++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
v = (x * 256) / img->width;
|
2022-10-28 05:53:07 +02:00
|
|
|
for (zz=0; zz<p1; zz++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
y = zz;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
|
|
|
(img->Gpix[y])[x] = gval;
|
|
|
|
(img->Bpix[y])[x] = v;
|
|
|
|
|
|
|
|
y = img->height-zz-1;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
|
|
|
(img->Gpix[y])[x] = gval;
|
|
|
|
(img->Bpix[y])[x] = 255-v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (y=p1; y<img->height-p1; y++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
v = (y * 256) / img->height;
|
2022-10-28 05:53:07 +02:00
|
|
|
for (zz=0; zz<p2; zz++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
x = zz;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
|
|
|
(img->Gpix[y])[x] = gval;
|
|
|
|
(img->Bpix[y])[x] = v;
|
|
|
|
|
|
|
|
x = img->width-zz-1;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
|
|
|
(img->Gpix[y])[x] = gval;
|
|
|
|
(img->Bpix[y])[x] = 255-v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
img->modified = 1;
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
2022-07-04 11:17:33 +02:00
|
|
|
* 13 Juin 2002: grosse colere, je vais faire du codage a la Gruuik.
|
|
|
|
* 1er Juillet 2022: la colere est toujours la, mais ce n'est pas la
|
|
|
|
* meme qu'il y a vingt ans...
|
2022-06-27 02:19:31 +02:00
|
|
|
*/
|
2022-10-28 05:53:07 +02:00
|
|
|
int Image_cadre_burp_1(Image_Desc *img, int p1, int p2, int flags)
|
2022-06-27 02:19:31 +02:00
|
|
|
{
|
|
|
|
int x, xx, y, yy, v;
|
|
|
|
|
2022-07-04 11:17:33 +02:00
|
|
|
#define TOPV 170
|
|
|
|
|
2022-06-27 02:19:31 +02:00
|
|
|
#if DEBUG_LEVEL
|
2022-07-04 11:17:33 +02:00
|
|
|
fprintf(stderr, ">>> %s ( %p %d %d $%x )\n", __func__, img, p1, p2, flags);
|
2022-06-27 02:19:31 +02:00
|
|
|
#endif
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (x=0; x<img->width; x++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
v = (x * 256) / img->width;
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
printf("%s : debug %d %d\n", __func__, x, v);
|
|
|
|
#endif
|
2022-10-28 05:53:07 +02:00
|
|
|
for (yy=0; yy<p1; yy++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
y = yy;
|
2022-07-04 11:17:33 +02:00
|
|
|
(img->Rpix[y])[x] = TOPV-v;
|
|
|
|
(img->Gpix[y])[x] = TOPV;
|
2022-06-27 02:19:31 +02:00
|
|
|
(img->Bpix[y])[x] = v;
|
|
|
|
|
|
|
|
y = img->height-yy-1;
|
|
|
|
(img->Rpix[y])[x] = v;
|
2022-07-04 11:17:33 +02:00
|
|
|
(img->Gpix[y])[x] = TOPV;
|
|
|
|
(img->Bpix[y])[x] = TOPV-v;
|
2022-06-27 02:19:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (y=p1; y<img->height-p1; y++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
v = (y * 256) / img->height;
|
2022-10-28 05:53:07 +02:00
|
|
|
for (xx=0; xx<p2; xx++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
x = xx;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
2022-07-04 11:17:33 +02:00
|
|
|
(img->Gpix[y])[x] = TOPV;
|
2022-06-27 02:19:31 +02:00
|
|
|
(img->Bpix[y])[x] = v;
|
|
|
|
|
|
|
|
x = img->width-xx-1;
|
|
|
|
(img->Rpix[y])[x] = 0;
|
2022-07-04 11:17:33 +02:00
|
|
|
(img->Gpix[y])[x] = TOPV;
|
|
|
|
(img->Bpix[y])[x] = TOPV-v;
|
2022-06-27 02:19:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
if (flags & 1) {
|
2022-06-27 02:19:31 +02:00
|
|
|
fprintf(stderr, "plop from %s\n", __func__);
|
|
|
|
}
|
|
|
|
|
2022-07-04 11:17:33 +02:00
|
|
|
#undef TOPV /* molly guard */
|
|
|
|
|
2022-06-27 02:19:31 +02:00
|
|
|
return OLL_KORRECT;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* new 10 decembre 2007 - ave St Exupery - fait pour l'affichage web
|
|
|
|
* des exemples des objets POV de tTh
|
2022-07-04 11:17:33 +02:00
|
|
|
*
|
2022-06-27 02:19:31 +02:00
|
|
|
*/
|
2022-10-28 05:53:07 +02:00
|
|
|
int Image_cadre_burp_2(Image_Desc *img, int taille, int pr, int pg, int pb)
|
2022-06-27 02:19:31 +02:00
|
|
|
{
|
|
|
|
int x, y, zz;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
2022-07-04 11:17:33 +02:00
|
|
|
fprintf(stderr, ">>> %s: sz %d, rgb %d %d %d\n", __func__, taille, pr, pg, pb);
|
2022-06-27 02:19:31 +02:00
|
|
|
#endif
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (x=0; x<img->width; x++) {
|
|
|
|
for (zz=0; zz<taille; zz++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
y = zz;
|
|
|
|
(img->Rpix[y])[x] |= pr;
|
|
|
|
(img->Gpix[y])[x] ^= pg;
|
|
|
|
(img->Bpix[y])[x] &= pb;
|
|
|
|
|
|
|
|
y = img->height-zz-1;
|
|
|
|
(img->Rpix[y])[x] |= pr;
|
|
|
|
(img->Gpix[y])[x] ^= pg;
|
|
|
|
(img->Bpix[y])[x] &= pb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (y=taille; y<img->height-taille; y++) {
|
|
|
|
for (zz=0; zz<taille; zz++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
x = zz;
|
|
|
|
(img->Rpix[y])[x] |= pr;
|
|
|
|
(img->Gpix[y])[x] ^= pg;
|
|
|
|
(img->Bpix[y])[x] &= pb;
|
|
|
|
|
|
|
|
x = img->width-zz-1;
|
|
|
|
(img->Rpix[y])[x] |= pr;
|
|
|
|
(img->Gpix[y])[x] ^= pg;
|
|
|
|
(img->Bpix[y])[x] &= pb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OLL_KORRECT;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2022-10-28 05:53:07 +02:00
|
|
|
int Image_cadre_burp_3(Image_Desc *img, int taille, int pr, int pg, int pb)
|
2022-06-27 02:19:31 +02:00
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
2022-10-28 05:53:07 +02:00
|
|
|
fprintf(stderr, ">>> %s ( %p %d %d %d %d)\n", __func__, img, taille,
|
|
|
|
pr, pg, pb);
|
2022-06-27 02:19:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
foo = Image_cadre_burp_2(img, taille, pr, pg, pb);
|
|
|
|
foo = Image_cadre_burp_2(img, taille/2, pr/2, pg/2, pb/2);
|
|
|
|
|
|
|
|
img->modified = 2;
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
int Image_cadre_rasta_0(Image_Desc *img, int taille)
|
|
|
|
{
|
|
|
|
Image_Rect rect;
|
|
|
|
int foo;
|
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
2022-10-28 05:53:07 +02:00
|
|
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, img, taille);
|
2022-06-27 02:19:31 +02:00
|
|
|
#endif
|
|
|
|
|
2022-07-04 11:17:33 +02:00
|
|
|
#define RASTA_RAND 4
|
2022-06-27 02:19:31 +02:00
|
|
|
|
|
|
|
rect.x = rect.y = 0;
|
|
|
|
rect.w = img->width;
|
|
|
|
rect.h = img->height;
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
for (foo=0; foo<taille; foo++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
r = 220 + (rand() % RASTA_RAND);
|
|
|
|
b = 10 + (rand() % RASTA_RAND);
|
2022-10-28 05:53:07 +02:00
|
|
|
Image_draw_rect(img, &rect, r, 12, b);
|
2022-06-27 02:19:31 +02:00
|
|
|
rect.x++; rect.y++;
|
|
|
|
rect.h-=2; rect.w-=2;
|
|
|
|
}
|
2022-10-28 05:53:07 +02:00
|
|
|
for (foo=0; foo<taille; foo++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
r = 220 + (rand() % RASTA_RAND);
|
|
|
|
g = 200 + (rand() % RASTA_RAND);
|
2022-10-28 05:53:07 +02:00
|
|
|
Image_draw_rect(img, &rect, r, g, 12);
|
2022-06-27 02:19:31 +02:00
|
|
|
rect.x++; rect.y++;
|
|
|
|
rect.h-=2; rect.w-=2;
|
|
|
|
}
|
2022-10-28 05:53:07 +02:00
|
|
|
for (foo=0; foo<taille; foo++) {
|
2022-06-27 02:19:31 +02:00
|
|
|
g = 220 + (rand() % RASTA_RAND);
|
|
|
|
b = 10 + (rand() % RASTA_RAND);
|
2022-10-28 05:53:07 +02:00
|
|
|
Image_draw_rect(img, &rect, 12, g, b);
|
2022-06-27 02:19:31 +02:00
|
|
|
rect.x++; rect.y++;
|
|
|
|
rect.h-=2; rect.w-=2;
|
|
|
|
}
|
|
|
|
|
|
|
|
img->modified = 1;
|
|
|
|
|
2022-10-28 05:53:07 +02:00
|
|
|
return OLL_KORRECT;
|
2022-06-27 02:19:31 +02:00
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|