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

Hdc ???

P: 43
I wanted to use setpixel but somehow the picture were still all white:

Please help:

Expand|Select|Wrap|Line Numbers
  1. Public Function showparc_image()
  2. Dim x2 As Integer = Convert.ToInt32(ReadLine(TextBox2.Text, 2))
  3. Dim y2 As Integer = Convert.ToInt32(ReadLine(TextBox2.Text, 1))
  4. Dim newBitmap
  5. Dim g
  6. newBitmap = New Bitmap(x2, y2)
  7. g = Graphics.FromImage(newBitmap)
  8. g.FillRectangle(New SolidBrush(Color.White), New Rectangle(0, 0, 800, 600))
  9. newBitmap.Save(CurDir() + "\controller.bmp")
  10. Dim type = ReadLine(TextBox2.Text, 3)
  11. Dim lin = 3
  12. Dim a1
  13. Dim a2
  14. Dim a3
  15. Dim a4
  16. Dim xxa = 0
  17. Dim yya = 0
  18. Dim colora As Color
  19. lp:
  20. If ReadLine(TextBox2.Text, lin) = "ENDOFFILE" Then
  21.  
  22. End If
  23. a1 = Convert.ToInt32(ReadLine(TextBox2.Text, lin + 1))
  24. a2 = Convert.ToInt32(ReadLine(TextBox2.Text, lin + 2))
  25. a3 = Convert.ToInt32(ReadLine(TextBox2.Text, lin + 3))
  26. a4 = ReadLine(TextBox2.Text, lin + 4)
  27. a4 = Replace(a4, "B", "") ' replace comma+space with just comma
  28. a4 = Replace(a4, "=", "") ' replace comma+space with just comma
  29. a4 = Convert.ToInt32(a4)
  30. Dim mybitmap As New Bitmap(CurDir() + "\controller.bmp")
  31. colora = System.Drawing.Color.FromArgb(a1 + a2 + a3 + a4)
  32. mybitmap.SetPixel(xxa, yya, colora)
  33. If xxa = x2 - 1 Then
  34.     fn = True
  35.     xxa = 0
  36.     GoTo lp
  37. Else
  38.     xxa = xxa + 1
  39. End If
  40. If yya = y2 - 1 Then
  41.     GoTo ends
  42. Else
  43.     If fn = True Then
  44.         fn = False
  45.         yya = yya + 1
  46.     End If
  47. End If
  48. GoTo lp
  49. ends:
  50. PictureBox2.ImageLocation = CurDir() + "\controller.bmp"
  51. End Function
Feb 2 '08 #1
Share this Question
Share on Google+
4 Replies


P: 14
I get that error all the time and it's allways something with the object properties. Try changing the ScaleMode of the window or picture and make sure that it doesn't draw outside of the area wich can cause a low level error.
Feb 2 '08 #2

P: 43
its not an error the color just dont appear on the picturebox nomatter if I set the x & y manually or not.
Feb 2 '08 #3

P: 14
I would try to find another way of solving the problem since .NET is full of bugs and it might not be your fault if it's not working. A lot of the stuff I made in VB.NET 2005 before I threw it away made the whole framework crash unexpectedly. Make sure that you don't use XP or Vista since Microsofts own applications doesn't work in XP and Vista hangs after 3 minutes before it crashes your harddrive.

B.T.W. It would be easier to read your code if you used the code tags. You may get more answers if you do.
Feb 5 '08 #4

Expert 5K+
P: 8,434
I'd recommend that you learn to use proper control structures (Eg. While loop, Select Case and so on) rather than creating "pretend loops" by using GoTo.

Have you verified that SetPixel is definitely the source of the problem? Or is it possible that you have picked up an incorrect value somewhere to put in the SetPixel? If you haven't check this out and make sure you're investigating the right problem. VB's debugging tools will be your best friend in this endeavour.
Feb 6 '08 #5

Post your reply

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