By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

JButton in c#

P: 12
I've been asked to give my .NET app the same look and feel to another app written using Java/Swing.

My main issue is to do with button/icons. The JButton used by the other app has an icon with a transparent background - this may a consequence of using GIF as the source format.

Now I just want to knock-up some simple icons for my app using VS2005 image editor and add them to the buttons. Cannot see how to add transparent pixels.
<gripe>
The icon editor has a transparent colour but the image editor doesn't! Guess this is to do with the file format but if the Bitmap class has a MakeTransparent method, why doesn't the editor?
</gripe>
Some buttons have state so I need an imagelist.
How do I create an Imagelist using VS2005? (Not programmatically)
Sep 12 '07 #1
Share this Question
Share on Google+
9 Replies


kenobewan
Expert 2.5K+
P: 4,871
There is no such thing as a transparent pixel, a color appears transparent when its opacity is set below 100%. I have never used VS2005 image editor, but I guarantee you wont end up with the effect unless you start with a transparent background - no colors - and can adjust the opacity of subsequent layers.

Btw - does anyone know the speed of dark? ;).
Sep 12 '07 #2

Plater
Expert 5K+
P: 7,872
Generally speaking a "transparent pixel" just means that for that particular pixel, nothing is done to it when your picture is drawn.
If it was already "red" it stays red, "blue" stays blue and so on.
You could make (234,254,244) be your "invisible" color just by not drawing it.
Sep 12 '07 #3

P: 12
Ok guys we've gone overboard on my use of the phrase "transparent pixel". You know what I'm after - I need the image to blend nicely with the button its sitting on, just like icons do on the toolbar,menus etc..
Sep 12 '07 #4

Plater
Expert 5K+
P: 7,872
My buttons have:
BackColor
BackgroundImage
BackgroundImageLayout
Image
ImageAlign
ImageIndex
ImageKey
ImageList
FlatSyle
FlatAppearance
TextImageRelation

Seems like you should be able to accomplish your goals with those properties
Sep 12 '07 #5

kenobewan
Expert 2.5K+
P: 4,871
Generally speaking a "transparent pixel" just means that for that particular pixel, nothing is done to it when your picture is drawn.
If it was already "red" it stays red, "blue" stays blue and so on.
You could make (234,254,244) be your "invisible" color just by not drawing it.
Sorry, a pixel is a unit of measurement. Whether it is transparent or not depends on whether anything translucent is covering it, another layer. That's why your transparent pixel is not transparent at all, it is empty. What is transparent are the layers above it.

Ok - if white noise isn't silent how much does nothing weigh? :)
Sep 13 '07 #6

P: 12
Well I've tried:
Expand|Select|Wrap|Line Numbers
  1.         private void MainForm_Load(object eventSender, System.EventArgs eventArgs)
  2.         {
  3.  
  4.             foreach (Bitmap bmp in MyButton.ImageList.Images)
  5.             {
  6.                 bmp.MakeTransparent(bmp.GetPixel(1, 1));
  7.             }
  8.  
But this had no effect. Further suggestions?
Sep 19 '07 #7

Plater
Expert 5K+
P: 7,872
Ok so you are assigning that color in the (1,1) location be the transparent color.
That's only for that EXACT RGB value (so if you have fancy color blending then it won't work)

And are you assigning those images as the background image?

You basicly want buttons that are customly shaped in the shape of your images right?
Sep 19 '07 #8

P: 12
Ok so I have finally found the key property.
It's ImageList.TransparentColor.
Now, the default for is Transparent (!). I could change this to something else and fill my image with that where needed (which is how I know it works) but it would make more sense to use this Transparent. Any idea how to get it into the image editor in VS2005? Some experimentation shows the alpha channel is set to 0, how to do that in VS2005 image editor?
Sep 20 '07 #9

Plater
Expert 5K+
P: 7,872
Add image to project.
Open image.
Sep 20 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.