Solved

Image Transparency

Posted on 2003-10-27
7
180 Views
Last Modified: 2010-05-01
Many thanks in advance!

I have a picture that has a red [ RGB(255,0,0) ] background color. How would I go about making it so that the red part is transparent? By transparent, I mean that the red part becomes see through. Thanks everybody!!
0
Comment
Question by:blizzdek
  • 2
7 Comments
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9631848
I suggest converting this picture to GIF format and set the red color as transparent.
You can convert it to WMF format also, but it is for simple graphics only. It's not a bitmaped graphics format - it's vector graphics
0
 
LVL 3

Expert Comment

by:pg_india
ID: 9631901
i think you need a code in program vb

http://www.visualbasicforum.com/showthread.php?t=8118

try this link
0
 

Author Comment

by:blizzdek
ID: 9634627
Uhh... PG_India, all they do on that post is talk about relevant stuff but they never get around to answering the question... I just need code for image transparency; that's all...
0
 
LVL 3

Accepted Solution

by:
pg_india earned 70 total points
ID: 9639706
TransparentBlt API
mask image and use BitBlt

well these are the three functions which they have refereed to...Are you facing any problem in using these 3 functions.

I suggest better try with "TransparentBlt". This will work for u.

An example of this is:

'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: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    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, vbWhite
End Sub
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question