Solved

Image Transparency

Posted on 2003-10-27
7
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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