# Visual Basic image fade



## cowplopmorris (Jun 7, 2006)

Hi,
I've seen bits of answers around on this topic, but am still quite lost. If anyone could point me in the right direction, that would be great.

Basically what I have is a Visual Basic Windows Forms project in Visual Studio 2008 with 2 PictureBoxes on top of one another and I want to be able to fade smoothly between them. At the moment I just have the top one have its visibility toggled, but is there any way to get them to fade?

Any pointers or suggestions would be much appreciated.

Thanks in advance.

Edit: I'm looking at using 2 forms, each with a picture box, and changing the opacity of one of them using the Opactiy property. However, it's quite jerky unless you want to do a very slow fade, since the minimum timer interval is 1ms. If there's a better solution, I'd still be interested.


----------



## Ent (Apr 11, 2009)

I understand that the best way is to manipulate the two images directly, having dimensioned both as images or arrays of pixels. The final picturebox contents is set to the result after all the fiddling is done. I've been messing around with the same thing, but can't work out how to avoid doing each pixel individually (which slows EVERYTHING down for large images.)


----------



## Ent (Apr 11, 2009)

Also, don't criticise a 1ms timer interval, which is 1000 fps. The problem is that the computer can't render the blend that fast, hence my need for a more efficient manipulation routine.


----------



## cowplopmorris (Jun 7, 2006)

Ent said:


> I understand that the best way is to manipulate the two images directly, having dimensioned both as images or arrays of pixels. The final picturebox contents is set to the result after all the fiddling is done. I've been messing around with the same thing, but can't work out how to avoid doing each pixel individually (which slows EVERYTHING down for large images.)


Yeah. I've found a bit of info ColorMatrix and the like, so I'll take a deeper look into that. I will be using full screen images for this, so I'm not sure what to do about the doing each pixel individually part.



Ent said:


> Also, don't criticise a 1ms timer interval, which is 1000 fps. The problem is that the computer can't render the blend that fast, hence my need for a more efficient manipulation routine.


I realised this a while after posting. After doing some calculations and adjusting of figures, it seems that indeed it isn't actually running the code every ms, as the computer can't keep up.


----------



## Ent (Apr 11, 2009)

I don't know whether you've sorted it out yet. I've managed to do this though, and figured I may as well share it. It's not polished (it actually seems to *fade too* quickly!) but I hope it'll help.


----------



## cowplopmorris (Jun 7, 2006)

Ent said:


> I don't know whether you've sorted it out yet. I've managed to do this though, and figured I may as well share it. It's not polished (it actually seems to *fade too* quickly!) but I hope it'll help.


That looks good! I'll have a play with it and see if I can use it.

I actually used another method. It was a bit of a bodge but worked. Basically a web browser object containing a simple web page with one function in, which used the proprietory MS filter. style.filter = "blendTrans(duration=0.7)"; etc. The app then passed it the next image url which it would display.

But thanks anyway, I'll take a look.


----------

