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?
Printable View
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?
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.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.
well, is there another way to get transparency without needing icons without flicker?
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:
'This project needs 2 pictureboxes 'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color) 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 Private Sub Form_Load() 'KPD-Team 1999 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] Picture1.AutoSize = True 'API uses pixels Picture1.ScaleMode = vbPixels Picture2.ScaleMode = vbPixels End Sub Private Sub Picture2_Paint() 'If we don't call DoEvents first, our transparent image will be completely wrong DoEvents TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbRed End Sub
ok... that didn't really work...
could you maybe make me an example? because i can't get that to work. ty
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
You might also need to set the Form's autodraw as true.VB Code:
Me.PaintPicture Picture1.Image, 0, 0
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
this still doesn't work, it takes the background color of the picture box along with it
Ok this should work :)
wow, thx