Solved

PictureBox and Transparent

Posted on 2003-12-09
14
918 Views
Last Modified: 2008-02-01
Hi,

I am using VC.net 2003.  I have a WinForm and on that I put a picturebox.  I am trying to show a round LED with a 16x16 bmp.  The problem is, since the corners are some color, in my case olive, the picture doesn't look right.  I am used to Delphi/Borland C++ Builder where I just need to set the Transparent property to true.  How do I accomplish the same thing in VC.net?  I want to be able to change the color of the form (or whatever I eventually place the picturebox on) and still only see the round image.

Thank you,
Joe
0
Comment
Question by:joeslow
[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
  • 8
  • 6
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9915128
I am a VB programmer, with a little experience with C++.  I wouldn't be afraid to try to help, since no one else seems to want to get involved, if you are still having problems?
0
 

Author Comment

by:joeslow
ID: 9915524
I think I figured it out how to do it programmatically:

First, I load the image in an imagelist because that lets me select the transparent color (olive in my case).  Then I assign it to the picture box at runtime like this:

pictureBox1->Image = imageList1->Images->Item[0];

This seems to work.  I don't see a way to do it at design time however.  If you have any ideas, let me know.

Thanks,
Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9915530
My first question would be, could you use a transparent GIF?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 9930609
Are you still having a problem with this?  Did my question make sense?
0
 

Author Comment

by:joeslow
ID: 9941936
I guess so.  Although I have access to more bmp files...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9942598
I can't think of any other way to do it in design-mode right now.
0
 

Author Comment

by:joeslow
ID: 9945020
So, the solution I came up with is OK?

Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9945107
Most of the time I don't concern myself with design-time issues, and I get into placing controls where I want them at run-time.  Your solution is OK as far as I am concerned.  I was just trying to show you an alternative with transparent GIFs or icons that would give you the transparency that you want at design time.  I understand, though, having bitmaps, and not wanting to convert them all.

My normal mode of operation is to keep around a huge collection of 16 x 16 bit icons whenever I need them, and not to use bitmaps.
0
 

Author Comment

by:joeslow
ID: 9950866
Go ahead and show me.  I'm not opposed to icons or gifs I just don't have as many to choose from (maybe you know of some good free sources).

Thanks,
Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9950882
Show you what?  How to convert bitmaps to transparent GIFs/Icons?
0
 

Author Comment

by:joeslow
ID: 9951205
Are you saying you can create icons and gifs that are already have transparent regions and you can't do that with bitmaps?  If that's the case, I guess you don't have to do anything when you add them to a picture box...

Joe
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 9951240
Icons and GIFs have the ability for transparency, where bitmaps do not.  I have tools, such as ImageEdit (from VB6), and the image editor in VS.NET (I don't use this one very much), to create icons.

When I need to create a transparent GIF, then I use something like Micro$oft's PhotoDraw 2000.  It has the ability to set transparency for GIF files.

With images that have a transparency, the picture box will draw them with the transparency, so what you see is what you get.
0
 

Author Comment

by:joeslow
ID: 9952167
Thanks for the info - I guess I'll try to find some good ones for my app, otherwise, I'll set it at run time...

Joe
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9952178
Have fun!

Bob
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

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