Results 1 to 10 of 10

Thread: [RESOLVED] picturebox - pset

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Resolved [RESOLVED] picturebox - pset

    Hi guys...

    I have this problem thats really gonna make me mad... so I would be happy if you helped me...

    Problem: When I use picture1.pset, draw the dots and save the image I only get a blank one... It probably doesn't recognize the dots in the picturebox as an image... But still I gotto use the dots. Can you guys help me out with this..

  2. #2

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: picturebox - pset

    When you draw on a PictureBox you're drawing on a canvas that isn't persisted as the Picture property. You must either persist the image in the Picture property or save the canvas, which is available as the Image property of the control.
    VB Code:
    1. 'This will save the canvas:
    2. SavePicture Picture1.[b]Image[/b], "C:\ThePath\TheFileName.bmp"
    3. 'This will persist the canvas:
    4. Set Picture1.Picture = Picture1.Image
    5. '...and then save the picture
    6. SavePicture Picture1.[b]Picture[/b], "C:\ThePath\TheFileName.bmp"

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Re: picturebox - pset

    VB Code:
    1. w = 0
    2. h = 0
    3. If Text3.Text = Empty Then
    4. MsgBox ("Önce şifrele!")
    5. Exit Sub
    6. End If
    7. Text3.Text = Text3.Text & "."
    8. v = 1
    9. k = 2
    10.  
    11. For w = 0 To Shape1.Width
    12.     For h = 0 To Shape1.Height
    13.     Picture1.PSet (w, h)
    14.     Next
    15. Next
    16.        
    17. Do
    18. z = InStr(k, Text3.Text, ".")
    19. z1 = Mid(Text3.Text, k, z - k)
    20. If v = 1 Then
    21. x = Val(z1)
    22. End If
    23. If v = 2 Then
    24. y = Val(z1)
    25. End If
    26. If v = 3 Then
    27. c = Val(z1)
    28.     If c < 0 Then
    29.         Picture1.PSet (x, y), &HFFFFFF
    30.         Picture1.PSet (x + 1, y), &HFFFFFF
    31.     End If
    32.     If c > 0 Then
    33.         Picture1.PSet (x, y), &HFFFFFF
    34.     End If
    35. v = 0
    36. End If
    37. v = v + 1
    38. k = z + 1
    39. Loop Until z = Len(Text3.Text)
    40.  
    41. [B]Set Picture1.Picture = Picture1.Image
    42. SavePicture Picture1.Picture, "c:\sifre.bmp"[/B]
    by the way Joacim your code did the same thing...











    Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: picturebox - pset

    Is the AutoRedraw property of the Picture Box set to True? What ScaleMode are you using for the Form and for the PictureBox? Can you see the plotted image in the PictureBox?

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Re: picturebox - pset

    AutoRedraw = false
    scalemode = twip
    plotted image = yes
    .....

  7. #7

  8. #8
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: picturebox - pset

    When it comes to graphics, always have your scalemode set to 3 - pixels to your forms and pictureboxes. It makes your life easier cause you can work with screen coordinates for a change rather than work in the 1000's range with twips.

    Also, be sure your Picturebox's autoredraw is True.

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Re: picturebox - pset

    VB Code:
    1. For w = 0 To Shape1.Width
    2.     For h = 0 To Shape1.Height
    3.     Picture1.PSet (w, h)
    4.     Next
    5. Next

    after removing this and making autoredraw true it worked!

    and Jacob I know pixels make life easier... But this project is about crypto and ascii has like 216 words so I had to use twip(encrypts image by cordinates)

    Anyways thanks!

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: picturebox - pset

    Quote Originally Posted by alicanSA
    and Jacob I know pixels make life easier... But this project is about crypto and ascii has like 216 words so I had to use twip(encrypts image by cordinates)
    Hmmm... The coordinates of an image is in pixels and not in twips.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width