Author Topic: Paint Image  (Read 11925 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Paint Image
« Reply #15 on: November 15, 2019, 11:46:02 am »
Hi Steve,

Frankly my dear, I don't give a damn about SCREEN 12 mode. ;-))

Why in the wide world would you willingly and wistfully waste wonderful color options in graphics 32 for 16 colors? 0 alpha!?!? And further, be restricted in screen size to one.

Honestly, I don’t either.  The question about paint fills by Tempodi (and worked on by Petr), was the first time I’ve worked with SCREEN 12 in YEARS.  Occasionally I’ll do stuff in 256 color mode, but anything less than that is just a PITA and a waste of time, IMHO...

I just thought it’d be nice to highlight an error-checking method for your code, in case anyone really wanted to use it in lower color modes, but it’s not something I’d actually plug into my own programs usually.  For personal use, I tend to prefer speed over error-checking, with the assumption that if I do have problems with something, I can always debug it and add that extra functionality/protection later.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #16 on: November 15, 2019, 12:10:48 pm »
But don't get me wrong, you can learn some really cool stuff studying retro, seeing how clever people can be working with limited resources.

eg the very idea of painting with images!

So I am not ever going to be snubbing code just because it's in an outdated screen mode.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Paint Image
« Reply #17 on: November 16, 2019, 10:12:47 am »
Ah-a here is the idea that Steve uses to build Paint Tiling QB45 emulator for SCREEN 12!
People please tell me, better a neutral color or a copy of the area of image to be overwritten if you work in 32bit mode?
Cool paintImage!

Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #18 on: November 16, 2019, 11:01:08 am »
Ah-a here is the idea that Steve uses to build Paint Tiling QB45 emulator for SCREEN 12!
People please tell me, better a neutral color or a copy of the area of image to be overwritten if you work in 32bit mode?
Cool paintImage!



Hi TempodiBasic,

When using this SUB in 32 bit color mode:
Code: QB64: [Select]
  1. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  2.     d = _DEST: s = _SOURCE
  3.     _DEST destHandle&
  4.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  5.     FOR y = 0 TO _HEIGHT(destHandle&)
  6.         FOR x = 0 TO _WIDTH(destHandle&)
  7.             _SOURCE destHandle&
  8.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  9.                 _SOURCE imageHandle&
  10.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  11.             END IF
  12.         NEXT
  13.     NEXT
  14.     _DEST d: _SOURCE s
  15.  

The only color to watch out for is _RGB(119, 24, 49), because to find the places to PAINT the image, the area at x, y is PAINTed first with that color to the Border~& color that should enclose x, y unless you want to paint to edges and have all other areas enclosed with Border~& color.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Paint Image
« Reply #19 on: November 19, 2019, 01:47:10 pm »
Hi BPlus, here is promised function, which return unused (free) color in image. It is option for your and my fill program.

Code: QB64: [Select]
  1. 'function return unused color number, v.1
  2. im32 = _SCREENIMAGE '_LOADIMAGE("qb.png", 32)
  3. img = _NEWIMAGE(256, 100, 256)
  4. _DEST img
  5. FOR c = 0 TO 256
  6.     LINE (c, 0)-(c, 100), c / 1.1
  7.  
  8. DIM FreeColor AS _UNSIGNED LONG
  9. FreeColor = GETFREECOLOR~&(im32)
  10. PRINT _RED32(FreeColor); _GREEN32(FreeColor); _BLUE32(FreeColor); _ALPHA32(FreeColor)
  11. PRINT GETFREECOLOR(img)
  12. SCREEN im32
  13. 'LINE (0, 0)-(500, 500), FreeColor, B 'uncomment both rows, paint color, which in original is not used and program correctly test himself as bad.
  14. 'PAINT (10, 10), FreeColor, FreeColor
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. 'program correct functionality automatic test
  22. n = _MEMIMAGE(im32)
  23. w = _WIDTH(im32)
  24. h = _HEIGHT(im32)
  25. H$ = "Program OK"
  26. FOR s = 0 TO w * h - 4 STEP 4
  27.     IF FreeColor = _MEMGET(n, n.OFFSET + s, _UNSIGNED LONG) THEN H$ = "Program Failure."
  28.  
  29. FUNCTION GETFREECOLOR~& (img AS LONG)
  30.     GETFREECOLOR~& = -1 'without definitions FreeColor in my loop and none free color it return -1~& (4294967295)
  31.     DIM m AS _MEM
  32.     m = _MEMIMAGE(img)
  33.     W = _WIDTH(img)
  34.     H = _HEIGHT(img)
  35.         CASE 0: EXIT FUNCTION 'text mode not supported in this version
  36.         CASE 1
  37.             DIM C(0 TO 255)
  38.             FOR s = 0 TO W * H - 1
  39.                 C(_MEMGET(m, m.OFFSET + s, _UNSIGNED _BYTE)) = 1
  40.             NEXT
  41.             DO UNTIL C(FRC) = 0
  42.                 FRC = FRC + 1
  43.                 IF FRC > 255 THEN EXIT FUNCTION 'no free 8 bit color
  44.             LOOP
  45.             GETFREECOLOR = FRC
  46.  
  47.         CASE 4
  48.             DIM C32(W * H) AS _UNSIGNED LONG
  49.             FOR s = 0 TO W * H - 4 STEP 4
  50.                 C32(s) = _MEMGET(m, m.OFFSET + s, _UNSIGNED LONG)
  51.             NEXT
  52.             FOR a = 255 TO 0 STEP -1
  53.                 FOR g = 0 TO 255
  54.                     FOR b = 0 TO 255
  55.                         FOR r = 0 TO 255
  56.                             test = 2
  57.                             FOR ic = 0 TO W * H
  58.                                 IF _RGBA32(r, g, b, a) = C32(ic) THEN test = 1
  59.                             NEXT ic
  60.                             IF test = 2 THEN
  61.                                 GETFREECOLOR~& = _RGBA32(r, g, b, a)
  62.                                 _MEMFREE m
  63.                                 ERASE C32
  64.                                 EXIT FUNCTION
  65.                             END IF
  66.                         NEXT r
  67.                     NEXT b
  68.                 NEXT g
  69.             NEXT a
  70.     END SELECT
  71.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #20 on: November 19, 2019, 03:10:35 pm »
Hi Petr,

I noticed you are testing for Alpha but neither POINT nor PAINT work with Alphas. As I mentioned previously, I was disappointed that even &H color constant values would not be recognized by POINT or PAINT even with full aplha 255 or FF. It sure would be nice if an invisible border color could be used to contain PAINTS so lines aren't left with paintImage.

Maybe you _MEMory guys can write _ALPHAPOINT and _ALPHAPAINT subroutines?


Here is another test with Brick Image:
Code: QB64: [Select]
  1. _TITLE "Brick Pattern Tile, click a spot to spray paint a brick image."
  2. CONST xmax = 800, ymax = 600
  3. SCREEN _NEWIMAGE(xmax, ymax, 32)
  4. _SCREENMOVE 300, 40
  5. 'make brick pattern
  6. brickpat& = _NEWIMAGE(16, 16, 32)
  7. _DEST brickpat&
  8. LINE (0, 0)-(_WIDTH(brickpat&) - 1, _HEIGHT(brickpat&) - 1), _RGB32(128, 0, 0), BF
  9. LINE (0, 0)-(_WIDTH(brickpat&) - 1, 0), _RGB32(200, 200, 200), BF
  10. LINE (0, 7)-(_WIDTH(brickpat&) - 1, 8), _RGB32(200, 200, 200), BF
  11. LINE (0, 15)-(_WIDTH(brickpat&) - 1, 15), _RGB32(200, 200, 200), BF
  12. LINE (0, 0)-(1, 8), _RGB32(200, 200, 200), BF
  13. LINE (7, 8)-(8, 15), _RGB32(200, 200, 200), BF
  14.  
  15. WHILE _KEYDOWN(27) = 0
  16.     mx = _MOUSEX: my = _MOUSEY: mb = _MOUSEBUTTON(1)
  17.     IF mb THEN
  18.         r = r + 1
  19.         IF r > 20 THEN r = 1
  20.         CIRCLE (mx, my), 50, _RGB32(20, 20, r)
  21.         paintImage mx, my, _RGB32(20, 20, r), 0, brickpat&
  22.     END IF
  23.     _DISPLAY
  24.     _LIMIT 60
  25.  
  26. SUB paintImage (x, y, Border~&, destHandle&, imageHandle&)
  27.     d = _DEST: s = _SOURCE
  28.     _DEST destHandle&
  29.     PAINT (x, y), _RGB(119, 24, 49), Border~&
  30.     FOR y = 0 TO _HEIGHT(destHandle&)
  31.         FOR x = 0 TO _WIDTH(destHandle&)
  32.             _SOURCE destHandle&
  33.             IF POINT(x, y) = _RGB(119, 24, 49) THEN
  34.                 _SOURCE imageHandle&
  35.                 PSET (x, y), POINT(x MOD _WIDTH(imageHandle&), y MOD _HEIGHT(imageHandle&))
  36.             END IF
  37.         NEXT
  38.     NEXT
  39.     _DEST d: _SOURCE s
  40.  

Brick B+.PNG
* Brick B+.PNG (Filesize: 81.49 KB, Dimensions: 796x627, Views: 184)

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Paint Image
« Reply #21 on: November 19, 2019, 04:42:25 pm »
Hi.
 Therefore, as you have noticed, my program for finding unused colors starts from alpha 255. :) OR use _DONTBLEND in program :)
What you want, PAINT with alpha, is practically a problem. Alpha shows the RGB color intensity depending on the background used. Therefore, you would have to write a complex algorithm that would not work on the principle of a uniform color boundary of the place where you do new color. I've tried to write something like my own PAINT in the past, but it's more complicated than I thought. (I stopped having fun with it, so this is uncomplete somewhere on my harddrive).
Principle of function, as I imagined it: Read the color number X, Y at the place where you want to color. Then from this point go to all sides (something as your maze search algorithm) and look for the positions of the points that have a different color than the color of the place you want to color. After you get the whole circuit completely, you paint it and color it. That's how PAINT works right now, just looking for a specific color. I suppose ALPHA would not mind such a function. The only thing she cares about is a different (any) color point than the default color (color in place where is coloring applyed. before color apply). How confirm, that circuit is complete? Hmm.... good ask :)


Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Paint Image
« Reply #22 on: November 21, 2019, 06:12:16 pm »
Hi Bplus

about  this
Quote
I noticed you are testing for Alpha but neither POINT nor PAINT work with Alphas. As I mentioned previously, I was disappointed that even &H color constant values would not be recognized by POINT or PAINT even with full aplha 255 or FF.
I can disagree  because it seems that POINT works
Code: QB64: [Select]
  1. CONST r1 = _RGBA32(200, 0, 0, 255), r2 = _RGBA32(200, 0, 0, 200), r3 = _RGBA32(180, 0, 0, 155)
  2.  
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4.  
  5. CIRCLE (100, 100), 100, r1
  6. PRINT POINT(100, 100); "  "; POINT(100, 200)
  7. PAINT (100, 100), r2, r1
  8. PRINT POINT(100, 100); "  "; POINT(100, 200)

About why PAINT doesn't recognize BorderColor%  because in Wiki BorderColor% can be also a Long32  and not only an integer
http://qb64.org/wiki/PAINT

moreover there is something broken in the PAINT command implementation for its alternating working well/bad

see here
Code: QB64: [Select]
  1. CONST r1 = _RGBA32(200, 0, 0, 255), r2 = _RGBA32(199, 0, 0, 200)
  2. CONST r3 = _RGBA32(200, 0, 0, 255), r4 = _RGBA32(199, 0, 0, 230), r5 = _RGBA32(180, 0, 0, 255)
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4.  
  5. CIRCLE (100, 100), 100, r1
  6. PRINT POINT(100, 100); "  "; POINT(100, 200)
  7. PAINT (100, 100), r2, r1
  8. PRINT POINT(100, 100); "  "; POINT(100, 200)
  9. LINE (200, 200)-STEP(50, 70), r3, B
  10. PAINT STEP(-10, -10), r4, r3 '<--- this paint works
  11. LINE (100, 100)-(150, 170), r5, BF
  12. PRINT POINT(201, 201); "  "; POINT(101, 101)
  13. PAINT (1, 1), r3, r5 '<-- this paint works
  14. LINE (300, 100)-(404, 404), r4, B
  15. PAINT (400, 400), r2, r4 ' <-- this paint doesn't work
  16.  
  17.  

but POINT seems to work in these examples.

Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Paint Image
« Reply #23 on: November 21, 2019, 06:24:39 pm »
Hi Petr

Quote
Principle of function, as I imagined it: Read the color number X, Y at the place where you want to color. Then from this point go to all sides (something as your maze search algorithm) and look for the positions of the points that have a different color than the color of the place you want to color. After you get the whole circuit completely, you paint it and color it. That's how PAINT works right now, just looking for a specific color. I suppose ALPHA would not mind such a function. The only thing she cares about is a different (any) color point than the default color (color in place where is coloring applyed. before color apply). How confirm, that circuit is complete? Hmm.... good ask :)

what do you think of these different implementation of  FloodFill ?
https://en.wikipedia.org/wiki/Flood_fill

I think that the 8 way direction implementation is far away from PAINT command, and you?
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #24 on: November 21, 2019, 07:12:17 pm »
Hi TempodiBasic,

Here is my screen shot for code you say works:
 
Paint with aplha not working.PNG


BTW I understand why alpha should not work, it's not same color when overlaying other colors.
« Last Edit: November 21, 2019, 07:14:51 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #25 on: November 21, 2019, 09:28:33 pm »
Oh hell I can't even get _RGB32 to work as CONST but &HFF.... works fine

Code: QB64: [Select]
  1.  
  2. 'CONST r1 = &HFFBB0000, r2 = &HFF00BB00 'OK paint works right with line box
  3. 'CONST r1 = _RGB32(200, 0, 0), r2 = _RGB32(0, 128, 0) ' <<<<<<<  screws up doesn't even draw box!!!
  4. SCREEN _NEWIMAGE(800, 600, 32)
  5. _SCREENMOVE 300, 40
  6.  
  7.  
  8. ' ok normal paint working
  9. r1 = _RGB32(200, 0, 0)
  10. r2 = _RGB32(0, 128, 0)
  11.  
  12. ' and alpha paint NOT working
  13. 'r1 = _RGBA32(200, 0, 0, 200)
  14. 'r2 = _RGBA32(0, 128, 0, 200)
  15.  
  16. LINE (103, 103)-STEP(100, 100), r1, B
  17. PRINT POINT(103, 103); "  "; POINT(110, 110)
  18. PAINT (109, 109), r2, r1
  19. PRINT POINT(103, 103); "  "; POINT(110, 110)
  20.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #26 on: November 22, 2019, 10:11:35 am »
OK POINT will do alpha coloring and even match _RGBA32() with &HFF... colors where expected, it's just tricky specially if CLS not used immediately:
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. _SCREENMOVE 300, 40
  3.  
  4.  
  5.  
  6. 'CLS '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH   AHA!
  7. ' with CLS get match right off the bat! Remove comment ' and no testing needed.
  8.  
  9. ' OK so POINT can read and match Alpha
  10.  
  11. red1 = _RGBA32(255, 0, 0, 127)
  12. red2 = &H80FF0000
  13. LINE (100, 100)-STEP(100, 400), red1, BF
  14. LINE (300, 100)-STEP(100, 400), red2, BF
  15. WHILE POINT(110, 110) <> POINT(310, 310)
  16.     CLS
  17.     a = a + 1
  18.     red1 = _RGBA32(255, 0, 0, a)
  19.     LINE (100, 100)-STEP(100, 400), red1, BF
  20.     LINE (300, 100)-STEP(100, 400), red2, BF
  21.     COLOR &HFFFFFFFF
  22.     PRINT "Red1 POINT "; POINT(110, 110); " alpha a = "; a
  23.     PRINT "Red2 POINT "; POINT(310, 310)
  24.     PRINT "press any to awaken next... "
  25.     SLEEP
  26.     IF alpha = 255 THEN EXIT WHILE
  27. PRINT "A match or Alpha ran all the way to 255, Test done."
  28.  
  29.  

OK so now I have to retest PAINT... with this fine POINT understood.
« Last Edit: November 22, 2019, 10:15:25 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #27 on: November 22, 2019, 10:35:39 am »
Well CLS right off doesn't help PAINT find an Alpha Border Color but _DONTBLEND does, first time I've used it with understanding BUT _DONTBLEND ruins transparency. So no fix to erase boundary lines for Paint Image just use border lines close to colors used in image or background.

Code: QB64: [Select]
  1. 'CONST r1 = &HFFBB0000, r2 = &HFF00BB00 'OK paint works right with line box
  2. 'CONST r1 = _RGB32(200, 0, 0), r2 = _RGB32(0, 128, 0) ' <<<<<<<  screws up doesn't even draw box!!!
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. _SCREENMOVE 300, 40
  5.  
  6.  
  7. ' ok normal paint working
  8. r1 = _RGB32(200, 0, 0)
  9. r2 = _RGB32(0, 128, 0)
  10.  
  11. ' and alpha paint NOT working
  12. 'CLS '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< might work now, nope!
  13.  
  14. r1 = _RGBA32(200, 0, 0, 1) 'try nearly invisible color
  15. r2 = _RGBA32(0, 128, 0, 200)
  16. _DONTBLEND '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OK now????  YES   but _DONTBLEND ruins transparency to make border lines invisible.
  17. LINE (103, 103)-STEP(100, 100), r1, B
  18. PRINT POINT(103, 103); "  "; POINT(110, 110)
  19. PAINT (109, 109), r2, r1
  20. PRINT POINT(103, 103); "  "; POINT(110, 110)
  21.  

Ha! I reread Petr's post and have retested pretty much what he had already said, sorry Petr some of us are slow readers (me).
I too tried my own PAINT algorithm a recursive one and crashed until limited checking to only one or two directions. So why not do one direction at a time, nope, tried and doesn't work either. I too am wondering how Pathfinding (and Fire and Minesweeper) worked so well because same deal, basically.

There must be a way, QB64 can do anything any other program can do, though might be slower....
« Last Edit: November 22, 2019, 10:52:55 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Image
« Reply #28 on: November 22, 2019, 11:07:05 am »
Hi Bplus

about  thisI can disagree  because it seems that POINT works
Code: QB64: [Select]
  1. CONST r1 = _RGBA32(200, 0, 0, 255), r2 = _RGBA32(200, 0, 0, 200), r3 = _RGBA32(180, 0, 0, 155)
  2.  
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4.  
  5. CIRCLE (100, 100), 100, r1
  6. PRINT POINT(100, 100); "  "; POINT(100, 200)
  7. PAINT (100, 100), r2, r1
  8. PRINT POINT(100, 100); "  "; POINT(100, 200)

About why PAINT doesn't recognize BorderColor%  because in Wiki BorderColor% can be also a Long32  and not only an integer
http://qb64.org/wiki/PAINT

moreover there is something broken in the PAINT command implementation for its alternating working well/bad

see here
Code: QB64: [Select]
  1. CONST r1 = _RGBA32(200, 0, 0, 255), r2 = _RGBA32(199, 0, 0, 200)
  2. CONST r3 = _RGBA32(200, 0, 0, 255), r4 = _RGBA32(199, 0, 0, 230), r5 = _RGBA32(180, 0, 0, 255)
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4.  
  5. CIRCLE (100, 100), 100, r1
  6. PRINT POINT(100, 100); "  "; POINT(100, 200)
  7. PAINT (100, 100), r2, r1
  8. PRINT POINT(100, 100); "  "; POINT(100, 200)
  9. LINE (200, 200)-STEP(50, 70), r3, B
  10. PAINT STEP(-10, -10), r4, r3 '<--- this paint works
  11. LINE (100, 100)-(150, 170), r5, BF
  12. PRINT POINT(201, 201); "  "; POINT(101, 101)
  13. PAINT (1, 1), r3, r5 '<-- this paint works
  14. LINE (300, 100)-(404, 404), r4, B
  15. PAINT (400, 400), r2, r4 ' <-- this paint doesn't work
  16.  
  17.  

but POINT seems to work in these examples.

OK TempdiBasic, POINT does work, thanks!

And it looks to me like where PAINT does work, your Border Color is full Alpha 255 and where it doesn't work your Border Color is not full Alpha.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Paint Image
« Reply #29 on: November 22, 2019, 02:55:27 pm »
Here's half an idea for a paint fill which I was working on; you might consider finishing it up:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2. _TITLE "Test Fill"
  3. LINE (100, 100)-(500, 400), -1, B
  4. Fill 200, 200, &HFFFF0000, -1
  5. CIRCLE (320, 240), 200, -1
  6. Fill 320, 240, &HFFFF0000, -1
  7. CIRCLE (320, 240), 200, -1
  8. Fill 220, 240, &HFFFF0000, -1
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. SUB Fill (Ox, Oy, fillkolor AS _UNSIGNED LONG, kolor AS _UNSIGNED LONG)
  19.     TYPE Boundry
  20.         LeftX AS INTEGER
  21.         RightX AS INTEGER
  22.     END TYPE
  23.     DIM Array(_HEIGHT - 1) AS Boundry
  24.  
  25.     FOR y = Oy TO _HEIGHT - 1
  26.         FOR x = Ox TO _WIDTH - 1
  27.             IF POINT(x + 1, y) <> kolor THEN Array(y).RightX = x ELSE EXIT FOR
  28.         NEXT
  29.         FOR x = Ox TO 0 STEP -1
  30.             IF POINT(x - 1, y) <> kolor THEN Array(y).LeftX = x ELSE EXIT FOR
  31.         NEXT
  32.         IF POINT(Ox, y + 1) = kolor THEN EXIT FOR
  33.     NEXT
  34.     FOR y = Oy TO 0 STEP -1
  35.         FOR x = Ox TO _WIDTH - 1
  36.             IF POINT(x + 1, y) <> kolor THEN Array(y).RightX = x ELSE EXIT FOR
  37.         NEXT
  38.         FOR x = Ox TO 0 STEP -1
  39.             IF POINT(x - 1, y) <> kolor THEN Array(y).LeftX = x ELSE EXIT FOR
  40.         NEXT
  41.         IF POINT(Ox, y - 1) = kolor THEN EXIT FOR
  42.     NEXT
  43.  
  44.     FOR y = 0 TO _HEIGHT - 1
  45.         LINE (Array(y).LeftX, y)-(Array(y).RightX, y), fillkolor, BF
  46.     NEXT

As you can tell, this doesn't fully fill our area for us, in all cases, but it does fill a large portion for us.  At this point, all we should really need to do is run the routine recursively again around the end points of the square we've created.  I was going to finish sorting it out, but my wife ended up in the hospital again with her asthma acting up terribly.  I don't know how much free time I'll have until she gets home again, so I might not be able to follow-up and finish the concept for quite some time if nobody else is interested in doing it...

The advantage to running the routine in this manner is that it fills huge chunks of our screen at a time in boxes, without running recursively on each point.  The number of recursive calls is going to be phenomenally smaller than what we'd have if we checked each point individually, and probably wouldn't run out of memory or stack space on us.

I won't promise that it'll work, but I think the concept is sound.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!