Results 1 to 16 of 16

Thread: fade in pictures

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    7

    fade in pictures

    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

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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-.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    7
    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

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    Code:
    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);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yeah, CornedBee, invert that. Alpha 255 means that none of the underlying color should show through, 0, means all of it.

    Z.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    7
    all right.
    is the vb code or is that C++?

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's C++.
    Last edited by CornedBee; Sep 10th, 2002 at 04:05 AM.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    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...

  10. #10

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    7
    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

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Good old DIB sections will see you through
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Do you have me on ignore or something Corned Bee? I've already suggested DIBs
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Oh they're common. They are very common
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  16. #16
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Anyway, I did not steal your idea, I elaborated it


    Maybe I should have said "they're not so trivial".
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width