Home > Archive > Visual Basic > May 2004 > picturebox fade
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi.
I have two pictureboxes, pic1 and pic2 (each box contains only the picture property, no controls). I want to create a fade animation from pic1 to pic2, with the help of API. If that's not possible, is there a way to simply create a fade-in animation for p
ic2?
I have been using an AVI file to do the fade, but it has turned into a pretty large file and I would hope that I could significantly cut down on the program size.
Thanks!
| |
|
| It depends on how large they are.
If they're small (size of a large postage stamp or smaller?) then
you could probably get away with doing a pixel-by-pixel 'morph'
from one to the other, at a reasonable frame rate.
Use the HDC property of the pictureboxes, and use GetPixel /
SetPixel, each of the RGB components of a given pixel
on the 'fade to' picturebox gets the value
pt = ps + (qs - ps) * f / T
and each component of a given pixel's color on the 'fade from'
picturebox gets the value
qt = qs - (qs - ps) * f / T
where pt and qt are the RGB values w.r.t. time of a given pixel
in the 'fade to' and 'fade from' pictureboxes, ps and qs are the values
those RGB values start out at, f is the current frame and T is
the total number of frames (work out the frame rate - adjust it
accordingly) and the time over which you want it to run.
Get the idea? Just dreamt it up off the top of my head but it might
work.
Oh - and by the way. Use a back buffer.
"x" <anonymous@discussions.microsoft.com> wrote in message
news:243D47E9-0805-4C81-B468-5818402B7B63@microsoft.com...
> Hi.
>
> I have two pictureboxes, pic1 and pic2 (each box contains only the picture
property, no controls). I want to create a fade animation from pic1 to pic2,
with the help of API. If that's not possible, is there a way to simply
create a fade-in animation for pic2?
>
> I have been using an AVI file to do the fade, but it has turned into a
pretty large file and I would hope that I could significantly cut down on
the program size.
>
> Thanks!
| |
|
| Thanks a lot for your help.
My image was pretty big - the company logo.
I found a way to fade an image to black, and from black to an image:
http://www.codeguru.com/vb/gen/vb_g...icle.php/c2385/
thank you!
----- B0nj wrote: -----
It depends on how large they are.
If they're small (size of a large postage stamp or smaller?) then
you could probably get away with doing a pixel-by-pixel 'morph'
from one to the other, at a reasonable frame rate.
Use the HDC property of the pictureboxes, and use GetPixel /
SetPixel, each of the RGB components of a given pixel
on the 'fade to' picturebox gets the value
pt = ps + (qs - ps) * f / T
and each component of a given pixel's color on the 'fade from'
picturebox gets the value
qt = qs - (qs - ps) * f / T
where pt and qt are the RGB values w.r.t. time of a given pixel
in the 'fade to' and 'fade from' pictureboxes, ps and qs are the values
those RGB values start out at, f is the current frame and T is
the total number of frames (work out the frame rate - adjust it
accordingly) and the time over which you want it to run.
Get the idea? Just dreamt it up off the top of my head but it might
work.
Oh - and by the way. Use a back buffer.
"x" <anonymous@discussions.microsoft.com> wrote in message
news:243D47E9-0805-4C81-B468-5818402B7B63@microsoft.com...[color=darkred]
> Hi.
property, no controls). I want to create a fade animation from pic1 to pic2,
with the help of API. If that's not possible, is there a way to simply
create a fade-in animation for pic2?[color=darkred]
pretty large file and I would hope that I could significantly cut down on
the program size.[color=darkred]
| |
| Jay Feldman 2004-05-31, 12:30 pm |
| I know that this is a little late, but how about using the AlphaBlend API w/ a timer (probably interval 50) and increasing the amount of alpha every time (I did +5)? To fade out a picture, just lower the amount of alpha by 5 each time.
I tried this out @ home and it worked fine on XP pro.
Jay Feldman
----- x wrote: -----
Hi.
I have two pictureboxes, pic1 and pic2 (each box contains only the picture property, no controls). I want to create a fade animation from pic1 to pic2, with the help of API. If that's not possible, is there a way to simply create a fade-in animation
for pic2?
I have been using an AVI file to do the fade, but it has turned into a pretty large file and I would hope that I could significantly cut down on the program size.
Thanks!
|
|
|
|
|