Hdc ???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patr0805
    New Member
    • Sep 2007
    • 48

    Hdc ???

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

    Please help:

    [CODE=vbnet]Public Function showparc_image( )
    Dim x2 As Integer = Convert.ToInt32 (ReadLine(TextB ox2.Text, 2))
    Dim y2 As Integer = Convert.ToInt32 (ReadLine(TextB ox2.Text, 1))
    Dim newBitmap
    Dim g
    newBitmap = New Bitmap(x2, y2)
    g = Graphics.FromIm age(newBitmap)
    g.FillRectangle (New SolidBrush(Colo r.White), New Rectangle(0, 0, 800, 600))
    newBitmap.Save( CurDir() + "\controller.bm p")
    Dim type = ReadLine(TextBo x2.Text, 3)
    Dim lin = 3
    Dim a1
    Dim a2
    Dim a3
    Dim a4
    Dim xxa = 0
    Dim yya = 0
    Dim colora As Color
    lp:
    If ReadLine(TextBo x2.Text, lin) = "ENDOFFILE" Then

    End If
    a1 = Convert.ToInt32 (ReadLine(TextB ox2.Text, lin + 1))
    a2 = Convert.ToInt32 (ReadLine(TextB ox2.Text, lin + 2))
    a3 = Convert.ToInt32 (ReadLine(TextB ox2.Text, lin + 3))
    a4 = ReadLine(TextBo x2.Text, lin + 4)
    a4 = Replace(a4, "B", "") ' replace comma+space with just comma
    a4 = Replace(a4, "=", "") ' replace comma+space with just comma
    a4 = Convert.ToInt32 (a4)
    Dim mybitmap As New Bitmap(CurDir() + "\controller.bm p")
    colora = System.Drawing. Color.FromArgb( a1 + a2 + a3 + a4)
    mybitmap.SetPix el(xxa, yya, colora)
    If xxa = x2 - 1 Then
    fn = True
    xxa = 0
    GoTo lp
    Else
    xxa = xxa + 1
    End If
    If yya = y2 - 1 Then
    GoTo ends
    Else
    If fn = True Then
    fn = False
    yya = yya + 1
    End If
    End If
    GoTo lp
    ends:
    PictureBox2.Ima geLocation = CurDir() + "\controller.bm p"
    End Function[/CODE]
    Last edited by Killer42; Feb 6 '08, 03:16 AM. Reason: Added CODE=vbnet tag
  • Dawoodoz
    New Member
    • Oct 2006
    • 14

    #2
    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.

    Comment

    • patr0805
      New Member
      • Sep 2007
      • 48

      #3
      its not an error the color just dont appear on the picturebox nomatter if I set the x & y manually or not.

      Comment

      • Dawoodoz
        New Member
        • Oct 2006
        • 14

        #4
        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.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          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.

          Comment

          Working...