]> git.saurik.com Git - wxWidgets.git/commitdiff
Separated wxImage::FloodFill from image.cpp
authorJulian Smart <julian@anthemion.co.uk>
Mon, 1 Apr 2002 22:14:42 +0000 (22:14 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 1 Apr 2002 22:14:42 +0000 (22:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

21 files changed:
distrib/msw/tmake/filelist.txt
src/common/image.cpp
src/gtk/files.lst
src/gtk1/files.lst
src/mac/carbon/files.lst
src/mac/files.lst
src/mgl/files.lst
src/microwin/files.lst
src/motif/files.lst
src/msw/files.lst
src/msw/makefile.b32
src/msw/makefile.bcc
src/msw/makefile.dos
src/msw/makefile.g95
src/msw/makefile.sc
src/msw/makefile.vc
src/msw/makefile.wat
src/os2/files.lst
src/wxUniv.dsp
src/wxWindows.dsp
src/x11/files.lst

index ad36c67b9391ecf84f7c63ae352b2362b4dc4481..9f182dd5313ba9a4a100f400d9278f47980ca638 100644 (file)
@@ -180,6 +180,7 @@ iconbndl.cpp        Common
 imagall.cpp    Common
 imagbmp.cpp    Common
 image.cpp      Common
+imagfill.cpp   Common
 imaggif.cpp    Common
 imagiff.cpp    Common
 imagjpeg.cpp   Common  Win32Only
index f98926b073568fbd5822d91e08d1f84c25337436..d4f9ddac8cfe2a6020b03bf03dd412a70d28c4e8 100644 (file)
@@ -820,248 +820,6 @@ bool wxImage::SetMaskFromImage(const wxImage& mask,
     return TRUE;
 }
 
-
-// DoFloodFill
-// Fills with the colour extracted from fillBrush, starting at x,y until either
-// a color different from the start pixel is reached (wxFLOOD_SURFACE)
-// or fill color is reached (wxFLOOD_BORDER)
-
-bool wxImage::MatchPixel(int x, int y, int w, int h, const wxColour & c)
-{
-    if ((x<0)||(x>=w)||(y<0)||(y>=h)) return false;
-
-    unsigned char r = GetRed(x,y);
-    unsigned char g = GetGreen(x,y);
-    unsigned char b = GetBlue(x,y);
-    return c.Red() == r && c.Green() == g && c.Blue() == b ;
-}
-
-bool wxImage::MatchBoundaryPixel(int x, int y, int w, int h, const wxColour & fill, const wxColour & bound)
-{
-    if ((x<0)||(x>=w)||(y<0)||(y>=h)) return TRUE;
-
-    unsigned char r = GetRed(x,y);
-    unsigned char g = GetGreen(x,y);
-    unsigned char b = GetBlue(x,y);
-    if ( fill.Red() == r && fill.Green() == g && fill.Blue() == b ) return TRUE;
-    if ( bound.Red() == r && bound.Green() == g && bound.Blue() == b ) return TRUE;
-    return FALSE ;
-}
-
-
-void wxImage::DoFloodFill (wxCoord x, wxCoord y, const wxBrush & fillBrush,
-        const wxColour& testColour, int style /*=wxFLOOD_SURFACE */,
-        int LogicalFunction /*= wxCOPY, currently unused */)
-{
-    /* A diamond flood-fill using a circular queue system.
-    Each pixel surrounding the current pixel is added to
-    the queue if it meets the criteria, then is retrieved in
-    its turn.  Code originally based on http://www.drawit.co.nz/Developers.htm */
-
-    int width = GetWidth();
-    int height = GetHeight();
-
-    //Draw using a pen made from the current brush colour
-    //Potentially allows us to use patterned flood fills in future code
-    wxColour fillColour = fillBrush.GetColour();
-    unsigned char r = fillColour.Red();
-    unsigned char g = fillColour.Green();
-    unsigned char b = fillColour.Blue();
-
-    //initial test :
-    if (style == wxFLOOD_SURFACE)
-    {
-       //if wxFLOOD_SURFACE, if fill colour is same as required, we don't do anything
-       if (     GetRed(x,y)   != r
-             || GetGreen(x,y) != g
-             || GetBlue (x,y) != b   )
-        {
-        //prepare memory for queue
-        //queue save, start, read
-        size_t *qs, *qst, *qr;
-
-        //queue size (physical)
-        long qSz= height * width * 2;
-        qst = new size_t [qSz];
-
-        //temporary x and y locations
-        int xt, yt;
-
-        for (int i=0; i < qSz; i++)
-            qst[i] = 0;
-
-        // start queue
-        qs=qr=qst;
-        *qs=xt=x;
-        qs++;
-        *qs=yt=y;
-        qs++;
-
-        SetRGB(xt,yt,r,g,b);
-
-        //Main queue loop
-        while(qr!=qs)
-        {
-            //Add new members to queue
-            //Above current pixel
-            if(MatchPixel(xt,yt-1,width,height,testColour))
-            {
-                *qs=xt;
-                qs++;
-                *qs=yt-1;
-                qs++;
-                SetRGB(xt,yt-1,r,g,b);
-
-                //Loop back to beginning of queue
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Below current pixel
-            if(MatchPixel(xt,yt+1,width,height,testColour))
-            {
-                *qs=xt;
-                qs++;
-                *qs=yt+1;
-                qs++;
-                SetRGB(xt,yt+1,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Left of current pixel
-            if(MatchPixel(xt-1,yt,width,height,testColour))
-            {
-                *qs=xt-1;
-                qs++;
-                *qs=yt;
-                qs++;
-                SetRGB(xt-1,yt,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Right of current pixel
-            if(MatchPixel(xt+1,yt,width,height,testColour))
-            {
-                *qs=xt+1;
-                qs++;
-                *qs=yt;
-                qs++;
-                SetRGB(xt+1,yt,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Retrieve current queue member
-            qr+=2;
-
-            //Loop back to the beginning
-            if(qr>=(qst+qSz)) qr=qst;
-            xt=*qr;
-            yt=*(qr+1);
-
-        //Go Back to beginning of loop
-        }
-
-        delete [] qst ;
-        }
-    }
-    else
-    {
-    //style is wxFLOOD_BORDER
-    // fill up to testColor border - if already testColour don't do anything
-    if (  GetRed(x,y)   != testColour.Red()
-       || GetGreen(x,y) != testColour.Green()
-       || GetBlue(x,y)  != testColour.Blue()   )
-        {
-        //prepare memory for queue
-        //queue save, start, read
-        size_t *qs, *qst, *qr;
-
-        //queue size (physical)
-        long qSz= height * width * 2;
-        qst = new size_t [qSz];
-
-        //temporary x and y locations
-        int xt, yt;
-
-        for (int i=0; i < qSz; i++)
-            qst[i] = 0;
-
-        // start queue
-        qs=qr=qst;
-        *qs=xt=x;
-        qs++;
-        *qs=yt=y;
-        qs++;
-
-        SetRGB(xt,yt,r,g,b);
-
-        //Main queue loop
-        while(qr!=qs)
-        {
-            //Add new members to queue
-            //Above current pixel
-            if(!MatchBoundaryPixel(xt,yt-1,width,height,fillColour,testColour))
-            {
-                *qs=xt;
-                qs++;
-                *qs=yt-1;
-                qs++;
-                SetRGB(xt,yt-1,r,g,b);
-
-                //Loop back to beginning of queue
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Below current pixel
-            if(!MatchBoundaryPixel(xt,yt+1,width,height,fillColour,testColour))
-            {
-                *qs=xt;
-                qs++;
-                *qs=yt+1;
-                qs++;
-                SetRGB(xt,yt+1,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Left of current pixel
-            if(!MatchBoundaryPixel(xt-1,yt,width,height,fillColour,testColour))
-            {
-                *qs=xt-1;
-                qs++;
-                *qs=yt;
-                qs++;
-                SetRGB(xt-1,yt,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Right of current pixel
-            if(!MatchBoundaryPixel(xt+1,yt,width,height,fillColour,testColour))
-            {
-                *qs=xt+1;
-                qs++;
-                *qs=yt;
-                qs++;
-                SetRGB(xt+1,yt,r,g,b);
-                if(qs>=(qst+qSz)) qs=qst;
-            }
-
-            //Retrieve current queue member
-            qr+=2;
-
-            //Loop back to the beginning
-            if(qr>=(qst+qSz)) qr=qst;
-            xt=*qr;
-            yt=*(qr+1);
-
-        //Go Back to beginning of loop
-        }
-
-        delete [] qst ;
-        }
-    }
-    //all done,
-}
-
-
 #if wxUSE_PALETTE
 
 // Palette functions
index 991ca2f4136af97882d57c45cc80502d9fbdea23..955714a70f074b85d90daa9e9888add34edce149 100644 (file)
@@ -108,6 +108,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -688,6 +689,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index 991ca2f4136af97882d57c45cc80502d9fbdea23..955714a70f074b85d90daa9e9888add34edce149 100644 (file)
@@ -108,6 +108,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -688,6 +689,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index d02a542c82b150a8588cdbf133cdf21d80b9e93c..33ddee3faf4c6da44e8d4c45d1e8539edbd66dec 100644 (file)
@@ -105,6 +105,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -714,6 +715,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index d02a542c82b150a8588cdbf133cdf21d80b9e93c..33ddee3faf4c6da44e8d4c45d1e8539edbd66dec 100644 (file)
@@ -105,6 +105,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -714,6 +715,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index 6cbdd7545c41a20cf83b666ddb71132b56b6102c..9574b76fc3ba861c42963dee5428d8246c0d99b6 100644 (file)
@@ -108,6 +108,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -588,6 +589,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index bc64109b37701f226935fe4c07ef5aba360e8212..878c5709419b71d303506659ae49cc60ed80ed13 100644 (file)
@@ -105,6 +105,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -681,6 +682,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index f704083c0d9f5e29ac5d883dea8e3cfe70956312..53e7dce06083eb9f784854a5ce527596f8ecc054 100644 (file)
@@ -107,6 +107,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -676,6 +677,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index 721ee5869b3b0b3b090f288743709d176bee66bb..56c834bf038fe68be4af2073aeeeeb306842ef2a 100644 (file)
@@ -92,6 +92,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -749,6 +750,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index 8f28aa1b84e0d25de10a63a77747837290325569..094457d0f7a59e922666c74898379493dfcf52ad 100644 (file)
@@ -175,6 +175,7 @@ COMMONOBJS = \
                $(MSWDIR)\imagall.obj \
                $(MSWDIR)\imagbmp.obj \
                $(MSWDIR)\image.obj \
+               $(MSWDIR)\imagfill.obj \
                $(MSWDIR)\imaggif.obj \
                $(MSWDIR)\imagiff.obj \
                $(MSWDIR)\imagjpeg.obj \
@@ -772,6 +773,8 @@ $(MSWDIR)\imagbmp.obj: $(COMMDIR)\imagbmp.$(SRCSUFF)
 
 $(MSWDIR)\image.obj: $(COMMDIR)\image.$(SRCSUFF)
 
+$(MSWDIR)\imagfill.obj: $(COMMDIR)\imagfill.$(SRCSUFF)
+
 $(MSWDIR)\imaggif.obj: $(COMMDIR)\imaggif.$(SRCSUFF)
 
 $(MSWDIR)\imagiff.obj: $(COMMDIR)\imagiff.$(SRCSUFF)
index fbe678ad421daca590f9e7b11e90b382ed159009..12afb467871b99de613af18eaa3e1266e7e8315e 100644 (file)
@@ -161,6 +161,7 @@ COMMONOBJS = \
                $(MSWDIR)\imagall.obj \
                $(MSWDIR)\imagbmp.obj \
                $(MSWDIR)\image.obj \
+               $(MSWDIR)\imagfill.obj \
                $(MSWDIR)\imaggif.obj \
                $(MSWDIR)\imagiff.obj \
                $(MSWDIR)\imagxpm.obj \
@@ -624,6 +625,8 @@ $(MSWDIR)\imagbmp.obj: $(COMMDIR)\imagbmp.$(SRCSUFF)
 
 $(MSWDIR)\image.obj: $(COMMDIR)\image.$(SRCSUFF)
 
+$(MSWDIR)\imagfill.obj: $(COMMDIR)\imagfill.$(SRCSUFF)
+
 $(MSWDIR)\imaggif.obj: $(COMMDIR)\imaggif.$(SRCSUFF)
 
 $(MSWDIR)\imagiff.obj: $(COMMDIR)\imagiff.$(SRCSUFF)
index c318f46e540e6fe530afcb01fafac4ba74cb2204..b4a85ff6370ece19f3a2725cd3857537368d5c4e 100644 (file)
@@ -146,6 +146,7 @@ COMMONOBJS1 = \
                $(COMMDIR)\imagall.obj \
                $(COMMDIR)\imagbmp.obj \
                $(COMMDIR)\image.obj \
+               $(COMMDIR)\imagfill.obj \
                $(COMMDIR)\imaggif.obj \
                $(COMMDIR)\imagiff.obj \
                $(COMMDIR)\imagxpm.obj \
@@ -1078,6 +1079,11 @@ $(COMMDIR)/image.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
 <<
 
+$(COMMDIR)/imagfill.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
 $(COMMDIR)/imaggif.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
index a8b7b186b6f8ff46cfee2ec35686846db6693c91..141ee901928297d2de1bd2db1a5ec301443bf904 100644 (file)
@@ -214,6 +214,7 @@ COMMONOBJS  = \
                $(COMMDIR)/imagall.$(OBJSUFF) \
                $(COMMDIR)/imagbmp.$(OBJSUFF) \
                $(COMMDIR)/image.$(OBJSUFF) \
+               $(COMMDIR)/imagfill.$(OBJSUFF) \
                $(COMMDIR)/imaggif.$(OBJSUFF) \
                $(COMMDIR)/imagiff.$(OBJSUFF) \
                $(COMMDIR)/imagjpeg.$(OBJSUFF) \
index a8580feab3bd19f02d784e7b65a1bbbf167d0f9f..c3a6362057b148300f3b7dbf14cad3ae33afb38e 100644 (file)
@@ -119,6 +119,7 @@ COMMONOBJS = \
                $(COMMDIR)\imagall.obj \
                $(COMMDIR)\imagbmp.obj \
                $(COMMDIR)\image.obj \
+               $(COMMDIR)\imagfill.obj \
                $(COMMDIR)\imaggif.obj \
                $(COMMDIR)\imagiff.obj \
                $(COMMDIR)\imagjpeg.obj \
index 1fcb1fffc4700f8ca8ca9c03e840634a2a7cd68e..ab809e04a98db4844c006791272eae86f9ae8327 100644 (file)
@@ -195,6 +195,7 @@ COMMONOBJS = \
                $(COMMDIR)\$D\imagall.obj \
                $(COMMDIR)\$D\imagbmp.obj \
                $(COMMDIR)\$D\image.obj \
+               $(COMMDIR)\$D\imagfill.obj \
                $(COMMDIR)\$D\imaggif.obj \
                $(COMMDIR)\$D\imagiff.obj \
                $(COMMDIR)\$D\imagjpeg.obj \
index 555b216041692307ebba432b44a17c4ec148f77b..87d43e0b6e3032d543b0e6b599102df49ba11d1d 100644 (file)
@@ -157,6 +157,7 @@ COMMONOBJS = &
        imagall.obj &
        imagbmp.obj &
        image.obj &
+       imagfill.obj &
        imaggif.obj &
        imagiff.obj &
        imagjpeg.obj &
@@ -916,6 +917,9 @@ imagbmp.obj:     $(COMMDIR)\imagbmp.cpp
 image.obj:     $(COMMDIR)\image.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
 
+imagfill.obj:     $(COMMDIR)\imagfill.cpp
+  *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
 imaggif.obj:     $(COMMDIR)\imaggif.cpp
   *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
 
index b7acd13bcbcb9275581a8a2f1b744899880b5bb2..e1d738c8f0ea38476d389efb52c467eaf9125ecb 100644 (file)
@@ -101,6 +101,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -694,6 +695,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \
index 8f59a5bfe8690243af74c296d00c7371cf9711df..9a4b05a9ba7738d94ba81c066bb1c6f57c0cc435 100644 (file)
@@ -325,6 +325,10 @@ SOURCE=.\common\image.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\common\imagfill.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\common\imaggif.cpp
 # End Source File
 # Begin Source File
index 81c44dbce91f380780f4576ed55a436072b95386..3064a53feaca158ced5ac488471f8246b2442551 100644 (file)
@@ -484,6 +484,10 @@ SOURCE=.\common\image.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\common\imagfill.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\common\imaggif.cpp
 # End Source File
 # Begin Source File
index 32a2c700870e66ba752ee0ec0516a63146beef54..52fdd6903096005e3afe1e5b63b4dab6cc915656 100644 (file)
@@ -139,6 +139,7 @@ ALL_SOURCES = \
                common/imagall.cpp \
                common/imagbmp.cpp \
                common/image.cpp \
+               common/imagfill.cpp \
                common/imaggif.cpp \
                common/imagiff.cpp \
                common/imagjpeg.cpp \
@@ -702,6 +703,7 @@ COMMONOBJS = \
                imagall.o \
                imagbmp.o \
                image.o \
+               imagfill.o \
                imaggif.o \
                imagiff.o \
                imagjpeg.o \