Solved

Image Transparency

Posted on 2003-10-27
7
177 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now