|
-
Aug 3rd, 2003, 12:56 PM
#1
Thread Starter
Fanatic Member
[Resolved] ExtFloodFill
Hi There!
Does anyone know how to do a floodfill in VB .NET?
The app is like this:
I have a black and white image that I have scanned.
Then you select a color, click anywhere on the image, and the shape is filled.
Just like an old-style colouringbook.
I have found a routine to capture the screen, and I can make a floodfill on that image
without problems, and have that image displayed in a picturebox.
Then I figured it would be easy. Just replace the desktop DC with my image DC
using
VB Code:
hDc = MyGraphics.GetHdc.ToInt32
But then I just end up with a black
rectangle covering my entire image.
It seems that the GetHdc doesnt return the right DC, for the image/bitmap.
This is really frustrating, especially since I know that all my API's work, if I just have the right DC's.
Please help... I'm making this app for my son, and he will be very disapointed if I can't get this to work.
BTW. I have also tried to make a recursive function, that set's
a pixel, then checks the surrounding pixels, and set's them if they
have the right color, then calls it'self for the next pixel and so on.
That also works, but only with small images.
If the image is too large then i get a stackoverflow exception.
Last edited by pax; Aug 4th, 2003 at 03:02 AM.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Aug 4th, 2003, 03:00 AM
#2
Thread Starter
Fanatic Member
Resolved
Hi There.
Never mind. The problem is solved. I found that the bitblt function
didn't work with the HDC from a graphics object.
So after CreateCompatibleBitmap, I create a new graphics object
FromHdc, so I get a graphics object refering to my new bitmap.
Then I can just use my DrawImage function from that graphics
object to draw the image into my bitmap.
Then I can use the ExtFloodFill function without problems.
Seems wierd though, that you have to mix GDI and GDI+ to get
this result, but who cares? As long as it works....
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jan 30th, 2004, 02:44 AM
#3
New Member
Please,I have same problem
Please I have same problem with ExtFloodFill function in VB.NET.
If you can ,please, send me the code at [email protected].
Please it is very urgent.
PLEASE!!!!!!!!!!!
Thanks
-
Jan 30th, 2004, 03:58 AM
#4
New Member
Thanks
Thanks a lot.You really saved my life.
THANKS.
I send you a thanks e-mail , from address [email protected](it is my other address).If you need help with something else,ask me, maybe i can help you
Thanks
Avy
-
Jun 16th, 2005, 02:50 PM
#5
New Member
Re: [Resolved] ExtFloodFill
Can you aslo send the sample to me? I'm also in the same problem... 
To : [email protected]
-
Jun 16th, 2005, 02:56 PM
#6
Re: Resolved
 Originally Posted by pax
Hi There.
Never mind. The problem is solved. I found that the bitblt function
didn't work with the HDC from a graphics object.
So after CreateCompatibleBitmap, I create a new graphics object
FromHdc, so I get a graphics object refering to my new bitmap.
Then I can just use my DrawImage function from that graphics
object to draw the image into my bitmap.
Then I can use the ExtFloodFill function without problems.
Seems wierd though, that you have to mix GDI and GDI+ to get
this result, but who cares? As long as it works.... 
It is possible to use bitblt with HDC's of graphics objects, I do it all the time. What exact problem were you having??
I don't live here any more.
-
Jun 16th, 2005, 02:58 PM
#7
Re: [Resolved] ExtFloodFill
You should not post your email addreses into ANY open forum.
Bots will pick it up and you will be spammed by solicitors.
You can PM your email address to anyone on the board.
If you must, you should use the word AT instead of the symbol @
-
Jun 16th, 2005, 03:44 PM
#8
New Member
Re: [Resolved] ExtFloodFill
I don't get it work :S...
If I use it then it will be only white :S
See the code :
Code:
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Declare Function DeleteDC Lib "gdi32" Alias "DeleteDC" (ByVal hdc As Integer) As Integer
Declare Function SelectObject Lib "gdi32" Alias "SelectObject" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer
Declare Function CreateCompatibleDC Lib "gdi32" Alias "CreateCompatibleDC" (ByVal hdc As Integer) As Integer
Declare Function FloodFill Lib "gdi32" Alias "FloodFill" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Integer) As Integer
Declare Function ExtFloodFill Lib "gdi32" Alias "ExtFloodFill" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Integer, ByVal wFillType As Integer) As Integer
Declare Function CreateCompatibleBitmap Lib "gdi32" Alias "CreateCompatibleBitmap" (ByVal hdc As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
Const SRCCOPY As Integer = &HCC0020
Const SRCINVERT As Integer = &H660046
Sub Main()
Dim bmp1, bmp2 As Bitmap
Dim g1, g2 As Graphics
Dim hdc1, hdc2 As IntPtr
Dim oldBmp As IntPtr
bmp1 = New Bitmap("pic.bmp")
g1 = Graphics.FromImage(bmp1)
hdc1 = g1.GetHdc
hdc2 = CreateCompatibleDC(hdc1)
oldBmp = SelectObject(hdc2, bmp1.GetHbitmap())
ExtFloodFill(hdc2, 5, 5, &HFF00, 0)
BitBlt(hdc1, 0, 0, 50, 50, hdc2, 0, 0, SRCCOPY)
SelectObject(hdc2, oldBmp)
DeleteDC(hdc2)
g1.ReleaseHdc(hdc1)
g1.Dispose()
bmp1.Save("test1.bmp")
End Sub
test1.bmp is just white
-
Nov 27th, 2011, 04:01 PM
#9
New Member
Re: [Resolved] ExtFloodFill
hi ,
i have problem with the floodfill algorithm
i have a form with 4 text boxes use for entering 4 numbers and a commoand button that draws a pie chart depending on the numbers from the text boxes on picture box(pic1) , the problem is that the code draws the outlines of the chart but i want it to be filled with colors
does anyone know how to do that
here is the code:
Private Sub draw_Click()
Pic1.Cls
Pic1.DrawWidth = 7
Sum = Val(Text1.Text) + (Text2.Text) + (Text3.Text) + (Text4.Text)
p11 = Val(Text1.Text) / Sum * 6.28
p12 = Val(Text2.Text) / Sum * 6.28
p13 = Val(Text3.Text) / Sum * 6.28
p14 = Val(Text4.Text) / Sum * 6.28
Pic1.Circle (4000, 4000), 1500, vbRed, 0, -p11
Pic1.Circle (4000, 4000), 1500, vbGreen, -p11, -(p11 + p12)
Pic1.Circle (4000, 4000), 1500, vbBlue, -(p11 + p12), -(p11 + p12 + p13)
Pic1.Circle (4000, 4000), 1500, vbYellow, -(p11 + p12 + p13), -6.28
end sub
sorry for my weak english , i really need help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|