Click to See Complete Forum and Search --> : fade in pictures
wehttam13
Sep 5th, 2002, 08:44 PM
I am making a little video clip that I have coded. I am looking for how to make pictures fade in and out very smoothly, just like a 3d rendering game would. But, i don't have that capability.
Any ideas?
thanks
CornedBee
Sep 6th, 2002, 06:45 AM
I can only assume how you coded the video clip and how you display it, but if you're using BitBlt, there is a related function called AlphaBlt which can handle alpha values. Just blit the image often while increasing/decreasing the alpha values to get the picture fading in and out.
AlphaBlt is not available for Win95/NT4-.
wehttam13
Sep 6th, 2002, 06:32 PM
As far as the video clip is concerned, it is pretty much a picture with words underneath it. They fade in and out using the print function and the forecolor, so I fade to from black to red to black, so it looks like it's really fading in.
I have never used Alpha blit or alphavalues before, would you be so kind as to explain it?
thanks
CornedBee
Sep 9th, 2002, 02:38 AM
The alpha value tells the degree of transparency. In 2D, this effectively means how much of the underlying color the drawer should mix in. E.g. an alpha value of 255 means that 100% of the resulting color is the underlying color (100% transparent). This might be inverse, I'm not sure. An alpha value of 128 would mean that the underlying color and the painted color are mixed in equal parts. 0 means OPAQUE.
The function I mean is AlphaBlend. To use it with nomal bitmaps, see this call.
HDC hSrc, hDest; // hSrc = MemDC with bitmap selected in.
// hDest = any DC used as destination
int bmWidth, bmHeight; // size of img
int destX, destY; // target pos
int alpha; // alpha value from 0 (transparent) to 255 (OPAQUE)
BLENDFUNCTION blfnc; // Additional information
blfnc.BlendOp = AC_SRC_OVER; // only possible value
blfnc.BlendFlags = 0; // no flags possible
blfnc.SourceConstantAlpha = alpha; // general alpha (for all pixels)
blfnc.AlphaFormat = 0; // Bitmap does not contain an alpha channel
// the call
BOOL bRes = AlphaBlend(hDest, destX, destY, bmWidth, bmHeight,
hSrc, 0, 0, bmWidth, bmHeight, blfnc);
Zaei
Sep 9th, 2002, 06:05 AM
Yeah, CornedBee, invert that. Alpha 255 means that none of the underlying color should show through, 0, means all of it.
Z.
CornedBee
Sep 9th, 2002, 06:49 AM
ok
The maximum value for the alpha channel is usually the same as the maximum value of a color channel. This means if colors are measured in floats from 0.0 to 100.0 (doesn't D3D do that?), the maximum alpha value would be 100.0 too.
Some color formats like RGBA16 have other keys.
wehttam13
Sep 9th, 2002, 10:12 AM
all right.
is the vb code or is that C++?
CornedBee
Sep 9th, 2002, 11:37 AM
It's C++.
Mushroom Realm
Sep 9th, 2002, 05:23 PM
get ur hands on a copy of animagic, and read the help file, save as a compressed gif, it will be smaller than jpeg
or
use a brightness algorithm, and apply to constantly(will draw slow)
brighten
Red = Red - (txtBrightness.Text * Red)
Green = Green - (txtBrightness.Text * Green)
Blue = Blue - (txtBrightness.Text * Blue)
darken
Red = Red + (txtBrightness.Text * (255 - Red))
Green = Green + (txtBrightness.Text * (255 - Green))
Blue = Blue + (txtBrightness.Text * (255 - Blue))
actually i think i got those mixed up try them both. im assuming that u can use getpixel/setpixel. Red,Green,Blue are bytes to which u fed the color. This is slower than my internet connection(which is saying something). txtBrightness is a textbox containg a percent(in decimal form)
...and corned bee, the big give away that ur in the wrong forum, see at the top where it says Visual Basic > Games and Graphics programming...
wehttam13
Sep 9th, 2002, 06:46 PM
Yeah, yeah, i know that's c++, just lettin you know.
But, for the fade in picture part, I can't use a getpixel and draw each one out. That would go far too slow.
I need something like when you see a game and pictures fade in and out during the credits or something like that.
It needs to be fast, and smooth, so I don't think i can use a byte by byte method.
thanks for your help though
Sastraxi
Sep 9th, 2002, 08:32 PM
Good old DIB sections will see you through :)
CornedBee
Sep 10th, 2002, 04:04 AM
When you have 10 mails saying "Reply to topic..." in your mailbox and the first 9 are in the C++ forum and then the tenth sends you directly down to the post it's easy to forget where you are.
DIB sections...
This could be a fast way to accomplish what mush said. Get the pixel buffer, manipulate (this should be fast), select into memdc and blit over.
Sastraxi
Sep 10th, 2002, 03:02 PM
Do you have me on ignore or something Corned Bee? I've already suggested DIBs :)
CornedBee
Sep 11th, 2002, 03:19 AM
Yeah, but I explained (a little bit) more what should be done.
Good old DIB sections will see you through.
Maybe he hasn't ever heard of DIB sections. They're not so common...
Sastraxi
Sep 11th, 2002, 07:02 AM
Oh they're common. They are very common :D
CornedBee
Sep 11th, 2002, 07:26 AM
Anyway, I did not steal your idea, I elaborated it :)
Maybe I should have said "they're not so trivial".
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.