Liste des Groupes | Revenir à cl c |
On 16/03/2024 15:09, Malcolm McLean wrote:if someone would write simpler version i would writeOn 16/03/2024 14:40, David Brown wrote:>On 16/03/2024 12:33, Malcolm McLean wrote:Now is this David Brown being David Borwn, ot its it actaully ture?
>And here's some code I wrote a while ago. Use that as a pattern. But>
not sure how well it works. Haven't used it for a long time.
>
https://github.com/MalcolmMcLean/binaryimagelibrary/blob/master/drawbinary.c
>
>
Your implementation is a mess, /vastly/ more difficult to prove
correct than the OP's original one, and unlikely to be very much
faster (it will certainly scale in the same way in both time and
memory usage).
>And I need to run some tests, don't I?#include <stdio.h>
>
#include <stdlib.h>
#include <string.h>
#include <time.h>
>
int floodfill_r(unsigned char *grey, int width, int height, int x, int y,
unsigned char target, unsigned char dest)
{
if (x < 0 || x >= width || y < 0 || y >= height)
return 0;
if (grey[y*width+x] != target)
return 0;
grey[y*width+x] = dest;
floodfill_r(grey, width, height, x - 1, y, target, dest);
floodfill_r(grey, width, height, x + 1, y, target, dest);
floodfill_r(grey, width, height, x, y - 1, target, dest);
floodfill_r(grey, width, height, x, y + 1, target, dest);
>
return 0;
}
>
Les messages affichés proviennent d'usenet.