Results 1 to 10 of 10

Thread: [RESOLVED] paint picture

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Resolved [RESOLVED] paint picture

    Hi, i'im using paintpicture to prevent flickering on my image, but when i do, the white background that wasn't in my image (it was gif with transparent background) is back. How can i get rid of it?
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: paint picture

    Code:
    PaintPicture: Draws the contents of a graphics file (.bmp, .wmf, .emf, .ico, or .dib) on a Form, PictureBox, or Printer. Doesn't support named arguments.
    Hence it cannot be used to draw *.gif. The best way is to make the gif into an icon, hence it will be retain its transparent properties when drawn on screen.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Re: paint picture

    well, is there another way to get transparency without needing icons without flicker?
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: paint picture

    Yes but u'll need to have a picturebox on the form with the picture (or something with a handle)

    From API Guide
    VB Code:
    1. 'This project needs 2 pictureboxes
    2. 'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
    3. Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
    4. Private Sub Form_Load()
    5.     'KPD-Team 1999
    6.     'URL: [url]http://www.allapi.net/[/url]
    7.     'E-Mail: [email][email protected][/email]
    8.     Picture1.AutoSize = True
    9.     'API uses pixels
    10.     Picture1.ScaleMode = vbPixels
    11.     Picture2.ScaleMode = vbPixels
    12. End Sub
    13. Private Sub Picture2_Paint()
    14.     'If we don't call DoEvents first, our transparent image will be completely wrong
    15.     DoEvents
    16.     TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbRed
    17. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Re: paint picture

    ok... that didn't really work...
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Re: paint picture

    could you maybe make me an example? because i can't get that to work. ty
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

  7. #7
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: paint picture

    I made an example but found out it was too slow to draw the picture, so i changed it bit.

    You'll need a picturebox with the gif loaded as a picture. This ensures that the gif has a transparent background. Then use

    VB Code:
    1. Me.PaintPicture Picture1.Image, 0, 0
    You might also need to set the Form's autodraw as true.


    Also if you are planning to make a game, i would suggest you check out JR's DirectX tutorial, cause it has an example of image transformations etc which might help. JR's Tutorial

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Re: paint picture

    this still doesn't work, it takes the background color of the picture box along with it
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

  9. #9
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: paint picture

    Ok this should work
    Attached Files Attached Files
    Last edited by Andrew G; Jun 19th, 2006 at 08:07 PM.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    129

    Re: paint picture

    wow, thx
    Resizing
    System Balloons

    If your question is answered, please mark the thread resolved by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.

    Remember to rate a post if you find it helpful

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