I have made transparent gif images using photoshop hoping that when i use them in windows forms picturebox the background won't be visible . They blend with the different backgrounds but still there is a rectangular background around the picture with the same color of the picturebox background. why is this happenning?
And also when I overlap two images I want them to be see through so that the picture beneath is visible.
Re: why Transparent image background is still shown?
Hello Sai!
Did you follow these steps for creating a transparent gif :
In Photoshop select New
Select Transparent in the Contents groupbox, select OK
Then, when saving:
File, Save for Web
Make sure GIF is selected for file type
Transparency checkbox is selected ¿
When I do the above it's fine in VB
Re: why Transparent image background is still shown?
Originally Posted by HanneSThEGreaT
Hello Sai!
Did you follow these steps for creating a transparent gif :
In Photoshop select New
Select Transparent in the Contents groupbox, select OK
Then, when saving:
File, Save for Web
Make sure GIF is selected for file type
Transparency checkbox is selected ¿
When I do the above it's fine in VB
Does it help ¿
hello Hannes,
Well Actually I converted gif images i had already to transparent gif images using photoshop .
I followed the following steps:
file ->open->open abd.gif file
using Magic eraser tool clicked on background which then converted into checkered background.
file->save for web
Made sure transparency and gif were selected
then save it as def.gif
Did I miss anything here?
for your reference i am attaching 2 images one before the transparency and another after making it transparent.
Re: why Transparent image background is still shown?
Hello Sai!
I looked at both your pictures. The converted one does have a transparent background, so there is nothing wrong with the picture. The reason you see the picturebox's background is because the picture's background is transparent. The problem lies with the pictureboxes and not the pictures.
Do you want a complete transparent background for the Picturebox ¿
Re: why Transparent image background is still shown?
Originally Posted by HanneSThEGreaT
Hello Sai!
I looked at both your pictures. The converted one does have a transparent background, so there is nothing wrong with the picture. The reason you see the picturebox's background is because the picture's background is transparent. The problem lies with the pictureboxes and not the pictures.
Do you want a complete transparent background for the Picturebox ¿
Hello Hannes
Thank you very much for taking time to look at my problem.
As we know there is nothing wrong with the pictures i think it's worth explaning what is happenning in my case then,Actually i am using RImage control I found in the following article:
it just acts like a picturebox. " showthrough" property should work for me as author says that "ShowThrough will determine whether or not space not used by the image will be transparent and show the control below it. This is accomplished using regions."
but this doesn't seem to be working in my case.
I am attaching this part of my project here could you please have a look at it?
CreateTransRegion function is called if showthrough property is set.
I know it looks confusing but once u look at the project you will understand a bit i guess
Re: why Transparent image background is still shown?
Hello again Sai!
I added the RImage control to my project. I added the GIF you made Transparent to it. What I then did, was to set the RImage's BackColor to Transparent, by clicking on the BackColor property, selected the Web tab, then Transparent is on top of the list. I then set the Form's backcolor to a different color (blue), and both the picture and the form had the same color. have a look at the screenshot.
Does that help ¿
Last edited by HanneSThEGreaT; December 19th, 2008 at 03:09 AM.
Re: why Transparent image background is still shown?
Is this what you mean?
I did this (see screenshot) by
1. Creating a panel to hold the picture box.
2. Set the BackColor property of the panel.
3. Set the TransparencyKey for the form to the same colour as the the BackColor of the panel.
4. Placed a picture box inside the panel with your transparent background image and voila!
Re: why Transparent image background is still shown?
Originally Posted by HanneSThEGreaT
Hello again Sai!
I added the RImage control to my project. I added the GIF you made Transparent to it. What I then did, was to set the RImage's BackColor to Transparent, by clicking on the BackColor property, selected the Web tab, then Transparent is on top of the list. I then set the Form's backcolor to a different color (blue), and both the picture and the form had the same color. have a look at the screenshot.
Does that help ¿
Thanks hannes
But try to add two Rimages and when you overlap them (as RImage has drag and drop abilities in the project I attached) you can see the blue (in your case) rectangular background and you won't be able to see the picture beneath it.
Re: why Transparent image background is still shown?
Originally Posted by AnimalX
Is this what you mean?
I did this (see screenshot) by
1. Creating a panel to hold the picture box.
2. Set the BackColor property of the panel.
3. Set the TransparencyKey for the form to the same colour as the the BackColor of the panel.
4. Placed a picture box inside the panel with your transparent background image and voila!
Or have I missed the mark?
Hey ANimalX,
Thanks for your reply Trasparency key seems to be working but it shows mainform or what ever is behind this child form how can i overcome this? Any idea?
And also if i overlap two images they are not transparent again and for example after placing the images on panel if i want Mouseclick events it is not possible.
Thanks
sai
Last edited by saibaba111; August 11th, 2006 at 10:17 AM.
Re: why Transparent image background is still shown?
Hello again Sai!
This was not easy
There is a process called AlphaBlending, which enables us to blend colors from a "background" to colors from a "foreground". Meaning that if we have 2 images, which is the case here, we can blend them into one another.
I am attaching a sample (which kept me up again all night) which blends 2 drawn shapes OR 2 Images.
The more you click the Draw Shapes button, or the Draw Image button, the more it blends.
Have a look at it please, and see if it can help you out, but I honestly think that you will be more than satissfied with the results.
PS: I told you don't worry, we'll get it fixed - like Guns n' Roses say : All we need is Patience
Have fun
Last edited by HanneSThEGreaT; December 19th, 2008 at 03:09 AM.
Re: why Transparent image background is still shown?
Hannes:
That is a nice piece of code! Essentially, you are drawing the the pictures a multiple times with the same value of i. So I put the last draw statement in a loop and the desired effect can be achieved in one click of the button.
Dim k As Integer
For k = 0 To 10
pic.CreateGraphics.DrawImage(img2, New Rectangle(50, 50, 200, 150), 0, 0, img2.Width, _
img2.Height, GraphicsUnit.Pixel, i)
Next
All we need is to adjust the maximum value of k in the loop to get the desired effect.
Re: why Transparent image background is still shown?
Sorry, correction to my last reply: in the loop, we have to put draw both images to get the desired effect:
Dim k As Integer
For k = 0 To 10
pic.CreateGraphics.DrawImage(img, 0, 0, 200, 150)
pic.CreateGraphics.DrawImage(img2, New Rectangle(50, 50, 200, 150), 0, 0, img2.Width, _
img2.Height, GraphicsUnit.Pixel, i)
Next
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.