New topic: 

Flood Fill with a PATTERN

<http://forums.realsoftware.com/viewtopic.php?t=46639>

         Page 1 of 1
   [ 6 posts ]                 Previous topic | Next topic          Author  
Message        DaveS          Post subject: Flood Fill with a PATTERNPosted: 
Mon Jan 21, 2013 5:55 pm                                 
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4449
Location: San Diego, CA                Diagonal Lines, Cross Hatch etc..

The same as the FloodFill but NOT a solid color.

I have one method in mind... but its a bit on the CPU expensive side.

1) copy image to a temp picture
2) flood fill selected X,Y point on TEMP picture with a hardly ever used color 
(  RGB(1,1,1) for example)
3) flood the temp MASK with WHITE
4) replace temp MASK pixels with BLACK where TEMP main pixel is RGB(1,1,1)
5) determine bounding rectangle of MASK pattern (can be done as part of step 4)
6) draw PATTERN over temp main area within bounding rectangle
7) draw temp image over original image.... 


That could take some time for a large image..

Anyone else have a faster/better way

Patterns could be another image.... OR a series of DRAWLINE commands      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                ktekinay          Post subject: 
Re: Flood Fill with a PATTERNPosted: Mon Jan 21, 2013 6:14 pm                   
              
Joined: Mon Feb 05, 2007 5:21 pm
Posts: 376
Location: New York, NY                Please look at this code and tell me if 
this is what you're looking for. Basically, it superimposes the image m over 
the image in p without creating a box where m is drawn. (CVS is a Canvas on the 
window.)
dim p as new Picture( CVS.Width, CVS.Height, 32 )
p.Transparent = 1
p.Graphics.ForeColor = RGB( 255, 0, 0 )
p.Graphics.FillRect( 0, 0, p.Width, p.Height )

dim m as new Picture( 10, 10, 32 )
m.Transparent = 1
m.Graphics.ForeColor = RGB( 0, 255, 0 )
m.Graphics.DrawLine( 0, 0, 10, 10 )
p.Graphics.DrawPicture( m, 10, 10 )

CVS.Backdrop = p
      
_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.
  
                             Top                DaveS          Post subject: 
Re: Flood Fill with a PATTERNPosted: Mon Jan 21, 2013 7:04 pm                   
              
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4449
Location: San Diego, CA                not a rectangle.... ANY random shape....

Exactly what PICTURE.RGBSURFACE.FLOODFILL(x,y,color) does

but instead of a color I want to use an arbtrairy Pattern such as a Cross-Hatch

like the Paintbucket tool in MSPAINT

like this

      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                charonn0          Post subject: 
Re: Flood Fill with a PATTERNPosted: Mon Jan 21, 2013 7:35 pm                   
              
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1083
Location: San Francisco, CA, USA                Something like this? Similar to 
your original solution, but fewer steps I think.

Function PatternFill(P As Picture, CoordX As Integer, CoordY As Integer) As 
Picture
  Dim background As New Picture(P.Width, P.Height) 'No depth
  'just a simple cross-hatch pattern
  For Y As Integer = 0 To background.Height Step 10
  background.Graphics.DrawLine(0, Y, background.Width, Y)
  Next
  For X As Integer = 0 To background.Width Step 10
  background.Graphics.DrawLine(X, 0, X, background.Height)
  Next
  
  Dim foreground As New Picture(P.Width, P.Height)
  foreground.Graphics.DrawPicture(P, 0, 0) 'Copy the original
  foreground.RGBSurface.FloodFill(CoordX, CoordY, &cFFFFFFFF) 'Use FloodFill 
with a 100% Transparent color
  
  background.Graphics.DrawPicture(foreground, 0, 0) 'Draw the 
original-with-transparent-region over the background
  
  Return background
End Function




Basically, draw the pattern to a temp picture, floodfill the region in the 
original using a 100% transparent color, and then draw the original over the 
temp picture.      
_________________
Boredom Software  
                             Top                DaveS          Post subject: 
Re: Flood Fill with a PATTERNPosted: Tue Jan 22, 2013 12:20 am                  
               
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4449
Location: San Diego, CA                Except for one minor detail.   There MAY 
be other areas that are TRANSPARENT on the image, that cannot/should not be 
filled
which is why I mentioned RGB(1,1,1) to make the fill area easily and uniquely 
identifiable.      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                charonn0          Post subject: 
Re: Flood Fill with a PATTERNPosted: Tue Jan 22, 2013 1:16 am                   
              
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1083
Location: San Francisco, CA, USA                If you can determine a bounding 
rectangle for the selected region, you could operate solely that using 
Graphics.Clip.      
_________________
Boredom Software  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 6 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to