I have an app originally written in VB6 that draws the Mandelbrot set. I loop through each pixel in a picture control, calculate the proper color for that pixel, and set the color, doing a refresh after each line. When I converted this to .NET it drew considerably slower. If I happen to minimize the app so that it doesn't have to draw anything the speed is fine.
Here are the times I'm getting for a particular view:
VB6 3 seconds
.NET (foreground) 14 seconds
.NET (background) 2 seconds
Here's a simplified piece of the VB6 code:
VB Code:
mypicture.autoredraw = true ' set at design time for x = 1 to 600 for y = 1 to 400 iterations=calculatepoint(x,y) ' this function is where all the heavy math happens mypicture.pset (x,y), colorlist(iterations) ' there's more logic going on here, but this is the important part next y doevents next x
And here's the VB.NET code
VB Code:
bmap = new bitmap(600,400,system.drawing.imaging.pixelformat.format24bpprgb) mypicture.image = bmap ' these two lines done in form.load for x = 1 to 600 for y = 1 to 400 iterations=calculatepoint(x,y) ' this function is where all the heavy math happens bmap.setpixel(x,y,colorlist(iterations)) ' again, this is the important part next y mypicture.refresh() system.windows.forms.application.doevents() next x
Is this the correct approach to this manner of drawing? Is there something I may be missing?
Thanks,
Dennis




Reply With Quote