Link to home
Start Free TrialLog in
Avatar of tentavarious
tentavarious

asked on

transparent gifs have blue lines on winform vb.net?

Hello experts, I dont know why this is happening, but all my transparent gif on my win form have blue lines around the border.  I took the same image and put it on a web page and it looks fine. I have been messing around with image editting tools trying to get my images right, but I think the problem is the win form.  I am using an image list for all my images could that be the problem?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

WinForms does not, by it's very nature, support "true" transparency, unfortunately.  So, you get weird effects like you described.

Bob
Avatar of tentavarious
tentavarious

ASKER

Ok, so how could i change the background of the image, to match the back ground of the form.
Where are you drawing this image?

Bob
Within a toolbar on my winform.
Actually, I am using a image list first.
If you don't add the image to the ImageList, but draw it directly on the ToolBar button (<-- assumption), does it draw correctly?

Bob
Don't you have to use an image list with a toolbar?  Anyways I can add an picture box on the form with the same image and it show up fine.  The problem seems to lie in using the image list.
1) How large are the images?

2) If they are 16 x 16 or 32 x 32, then you can use .ico with transparent colors.

Bob
I could shrink them down to 32 X 32, how can I make my gifs into icons?
1) .NET has an image editor.

2) Add New Item | Icon

3) Copy and paste the image from the GIF to the icon file

4) You will get an Image menu.  

5) Some important menu items are Image | New Image Type, Current Icon Image Types ->, and Delete Image type.  

6) There are rudimentary tools that you can use to either edit an existing image, or create your own icons.

Bob
forgive me for I am slow, but I am having problems with the icon editor, how exactly do I paste my gif to the newly created icon file?  And I am not seeing the menu items you have listed.
What .NET version do you have?

Bob
I am using visual studio.net 2003
Take a look at this .jpg showing the Image Editor:

   https://filedb.experts-exchange.com/incoming/ee-stuff/51-Image-Editor.jpg

Bob
Ok, I got that far, but I am not sure how to paste a transparent gif into this file.
1) Open the file in a program that can copy the GIF file (i.e. M$ Paint)
2) Copy the image
3) Go to the Image Editor, can paste.

Bob
Ok, I got the gif into a icon.  I added the icon to the image list and I still get the blue line its about 1px wide.  I have no idea why this isn't working.
1) Did you edit the background of the icon to use transparency, and not depending on the GIF to do that?  

2) Does the icon show the line?

3) Here is a place to upload any example images, forms, etc:

http://ee-stuff.com/Expert/Upload/upload.php?Question=21831389

Bob
I tried both methods and neither worked.  I uploaded one of the images causing the problem.
>>I uploaded one of the images causing the problem.
Interesting, I only see the .jpg file that I uploaded.

Bob
Ok, do I need anything other then the question number?  I tried uploading it again.  It should be a pdf.gif
I guess you need to tell me what file ID (fid) is.  That site is a work-in-progress, so it takes some time, but it a pretty cool way of sharing.  

After you upload, you should get a URL back, like this:
   http://www.ee-stuff.com/Expert/Upload/getFile.php?fid=54

Bob
Yep, my question number is there then i browse to the file and click upload it seems to be working.
Oh, I am getting an invalid file type.  It is a .gif so I dont know why that would be.
Yeah the file is 1.91k in size and its a gif,  it doesnt seem to be going through
If you notice the upload screen, the allowed file types are zip, tiff, txt, png, jpg, pdf.  I posted a question to the page creator about the .gif file type.

Bob
I guess when I used the filter in openfiledialog gifs were allowed.  I can convert to jpg
JPGs can leave remnants, can you convert to .PNG? Windows XP M$ Paint can save a .PNG.

Bob
Here are the steps that I used to create the icon:

1) Navigated to http://images.google.com/images?svnum=100&hl=en&lr=lang_en&newwindow=1&q=pdf+icon+32
2) Make sure that the 43 x 38 pixels - 1k  - gif, www.bielek.com image is visible.
3) Hit the <PrtScn> button to grab the image
4) Open Micro$oft Paint
5) Paste the screen shot into Paint.
6) Highlight the image inside the box for the selected icon image, at a size of 32 x 32, and copy that to the clipboard.
7) From the VB.NET 2003 IDE, select the 'Add New Item | Icon' option.
8) Select 'Image | New Image Type' to add a new image type=32 x 32, 256 colors.
9) Select 'Image | Current Icon Image Types' to select the 32 x 32, 16 color image.
10) Select 'Image | Delete Image Type' to remove the 16 color image, and left the 256 color image.
11) Select 'Edit | Paste' to paste the image copied from Paint.
12) Click on the paint can tool
13) Select the transparent color from the color palette (the color shown in a screen button)
14) Paint the background with the transparent color
15) Use the pencil tool for tighter control
16) Select 'File | Save Icon1.ico As...' to save the .ico file with the real file name.

Bob
Yep, i did all that.  Now try adding that icon to a imagelist then binding the imagelist to a toolbar control and see what you get.  I followed all your steps exactly and I have blue outline around the image.
You are going to have to show me what you mean, cuz I can't seem to duplicate this.

Bob
Ok, the lines are only 1 px thick.  I created a .png of my application toolbar.  How do I get to the upload page again?
Look up to get the same link (from 05/09/2006)  ^^^^^

Bob
Dope, sorry its Monday.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nope, some are smaller then others
That solved it, I just have to make sure they are the same as the imagelist properities