Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a transparant bitmap

Status
Not open for further replies.

edderic

Programmer
Joined
May 8, 1999
Messages
628
Ho create i a transparant bitmap ?

example : two pictureboxs and the picturebox2 make transparant with picturebox1

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Transparency is not supported by bitmaps (though I swear I've seen one before). You could use GIF format though.

A simple product such as Microsoft Photo Editor allows you to add transparancy to a particular color and save it as a GIF. Most all major photo and graphic applications support transparency.
 
Here are a couple of links:


VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Alt255

The first Link is not 32 bits programming of Api's

The Link 2 is Transparent with a Form background and not with a picturebox

Eric
Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Just wanted to mention that you can mask a bitmap, searching on any site (ie planetsourcecode.com) will give you an example program of this. The mask requires what you want transparent and what not based on black and white values.
 
Sorry about that Eric. I shouldn't have posted the links without trying the code.
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
No problems Alt255

The answer to do it :

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long

Const cWidth = 361 'Sprite width
Const cHeight = 416 'Sprite height
Const cMidX = 181 'Central horizontal point of sprite
Const cMidY = 233 'Cebtral vertical point of sprite

Private Sub PicDest_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If Working Then Exit Sub 'Prevent multiple-redraws causing stack overflows

'Working = True
With PicDest
.Cls 'Clear old image and draw new one
PicDest.PaintPicture PicSrce, X - cMidX, Y - cMidY, cWidth, cHeight, , , , , vbSrcAnd
.Refresh
End With
'Working = False
End Sub

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top