Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET graphics methods slow compared to VB6

Status
Not open for further replies.

Clairvoyant1332

Programmer
May 21, 2003
147
US
I have this app originally written in VB6 where I loop through each pixel in a picture control and set the color, doing a refresh after each line. When I converted this to .NET it was considerably slower.

Here's a simplified piece of the VB6 code:
Code:
mypicture.autoredraw = true   ' set at design time
for x = 1 to 600
  for y = 1 to 400
    mypicture.pset (x,y), vbblack  ' 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
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
    bmap.setpixel(x,y,color.black)  ' again, this is the important part
  next y
  mypicture.refresh()
  system.windows.forms.application.doevents()
next x

Is this the correct approach? Am I missing something?

Thanks,
Dennis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top