Sujet : Re: filling area by color atack safety
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.cDate : 20. Mar 2024, 00:30:56
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <utd76v$2e7rj$1@i2pn2.org>
References : 1 2
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
Michael S wrote:
On Wed, 20 Mar 2024 00:03:04 +0100
fir <fir@grunge.pl> wrote:
im not quite sure what you do here.. pass the structure? in fact
the thing you name context you may not pass at all just make is
standalone static variables becouse they/it is the same for whole
"branch" (given recursive branch of recolorisation)
>
something like
>
int old_color = 0xff0000;
int new_color = 0x00ff00;
>
void RecolorizePixelAndAdjacentPixels(int x, int y)
{
//...
}
>
>
>
Not thred-safe.
>
some thread safe as previous, and i just say that thiose new_color and old_color in arguments i add for convenience - as those all was functional test if the operation of recolorisation visibly works and how in my lowres (bigpixel) graphics editor - its no need to pass it
down the stack..also the test if old_color = new color then return
is strictly probably not needed to populate
i also made unnecesary GetPixelSafe - i use two metods liek SetPixelSafe just checks if x,y is in array at all ans SetPixelUnsafe
simply frame[y*frame_width+x] = color
so if you were interested in speed comparsions you wouldnt need to pass
structure at all and that will be faster
i agree generally with bot mclean and brown in this discusion
1) its not optimal so its kinda wrong
2) it is simple so its kinda usable and for some uses its handy so
not all accusations of this being wring are justified