By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

convert the vb6 code below into vb.net code

P: 5
Hi I am trying to convert the vb6 code below into vb.net code can anyboddy help
The vb6 code is from a chip8 Emulator that somboddy wrote.

vb6 code
this function keeps getting called until the image is drawn.
Sub drawscreen()
If Picture1.Point(1 + x + (i * 4), y + (j * 4)) = RGB(0, 255, 0) Then
v(&HF) = 1
Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 0, 0), BF
Else

Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 255, 0), BF
End If
End Sub

many thanks Karl
Apr 24 '07 #1
Share this Question
Share on Google+
6 Replies


RedSon
Expert 5K+
P: 5,000
Use a Good Thread Title
Using a good, clear thread title is important. The reasons for this are:

* We want this site to grow, many of our new members find the site using a search engine, by using a good thread title you will help us grow the site by helping us get better search engine rankings.
* Using a good title will benefit you too because other members of the forum will be less likely to skip over your thread and it allows the experts to quickly scan through the forum for questions they know the answer to.
* If the threads are well titled it allows other users to easily see if there have been any threads that could be relevant to their own current problem.
* It is in everybody's best interests to post properly titled threads as the more time the moderators have to spend on managing titles the less time they have available to give answers to the questions posed.

Thanks
Apr 24 '07 #2

RedSon
Expert 5K+
P: 5,000
Does Microsoft not provide any filters to go from VB6 to VB.NET?
Apr 24 '07 #3

TRScheel
Expert 100+
P: 638
Does Microsoft not provide any filters to go from VB6 to VB.NET?
Some code can be changed from VB6 to VB.Net through their converters, this looks like a piece of code that would not be able to
Apr 24 '07 #4

TRScheel
Expert 100+
P: 638
Hi I am trying to convert the vb6 code below into vb.net code can anyboddy help
The vb6 code is from a chip8 Emulator that somboddy wrote.

vb6 code
this function keeps getting called until the image is drawn.
Sub drawscreen()
If Picture1.Point(1 + x + (i * 4), y + (j * 4)) = RGB(0, 255, 0) Then
v(&HF) = 1
Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 0, 0), BF
Else

Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 255, 0), BF
End If
End Sub

many thanks Karl
PictureBox's in .NET now do not have the capability to draw. What you are looking for is System.Drawing.Pen. As far as finding the pictures color at that pixel, I believe you would have to use the System.IO and probably load the picture into memory.

Or... use the bitmap object and load it into that (if thats an option). Then you could use Bitmap.GetPixel(x, y) and it returns its color.
Apr 24 '07 #5

P: 5
PictureBox's in .NET now do not have the capability to draw. What you are looking for is System.Drawing.Pen. As far as finding the pictures color at that pixel, I believe you would have to use the System.IO and probably load the picture into memory.

Or... use the bitmap object and load it into that (if thats an option). Then you could use Bitmap.GetPixel(x, y) and it returns its color.
Thanks I will have a go at that
Apr 26 '07 #6

TRScheel
Expert 100+
P: 638
Thanks I will have a go at that

You asked me over PM to provide code about how to get the pixel color of the bitmap, here is an example (and sorry it took so long).

replace bmp.bmp with the string of the location where your bitmap is, and please note that this is a console app and pay attention to how it presents the data. Bitmap.GetPixel returns a color object, so you can get the A R G or B value of the image, or get it in another form.

Expand|Select|Wrap|Line Numbers
  1.             System.Drawing.Bitmap myBitmap = new System.Drawing.Bitmap("bmp.bmp");
  2.  
  3.             for (int i = 0; i < myBitmap.Height; i++)
  4.             {
  5.                 for (int j = 0; j < myBitmap.Width; j++)
  6.                 {
  7.                     Console.WriteLine(myBitmap.GetPixel(i, j).ToString());
  8.                 }
  9.             }
  10.  
  11.             Console.ReadKey(true);
May 10 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.