RE: Win32Lib API Floodfill?
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 06, 2004
- 419 views
cklester wrote: > > cklester wrote: > > > > Brian, should this work on pixmaps? It doesn't seem to be working > > for me on those. I can get it to fill a window, though... > > Update. Here's what I have... a pixmap with two colors on it, either > black or pink. If i click on a pink area, it will fill with black. if > i click on a black area, it will not fill with pink. Why?!?! :) > > Here's the relevant code... I don't think it's wrong. > > x = pos[1] -- get mouse position > y = pos[2] > c = getPixel(pixMask,x,y) -- check color > if c = Black then > c = Pink -- paint pink on black > else > c = Black -- paint black on pink > end if > floodFillSurface(pixMask,x,y,c) > draw_Bitmap() I haven't looked at Brian's code but I guess its a wrapper for the ExtFloodFill API call. In which case, the 'c' value is not the color you WANT to flood that area with, but the color which you want to change. Try this instead... x = pos[1] -- get mouse position y = pos[2] s = getPixel(pixMask,x,y) -- check color if s = Black then c = Pink -- paint pink on black else c = Black -- paint black on pink end if setPenColor(pixMask, c) -- I assume that Brian's code creates a brush using createBrush(). floodFillSurface(pixMask,x,y,s) draw_Bitmap() Anyhow, I have floodfill working in win32lib now. I'm tidying up some documentation now and will release it this weekend. If you were using the new floodFill() routine it would look like ... x = pos[1] -- get mouse position y = pos[2] s = getPixel(pixMask,x,y) -- check color if s = Black then c = Pink -- paint pink on black else c = Black -- paint black on pink end if VOID = floodFill(pixMask,x,y,{s,c}, FLOODFILLSURFACE) draw_Bitmap() -- Derek Parnell Melbourne, Australia