Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create an Image which fades

Posted on 1998-10-28
3
238 Views
Last Modified: 2010-04-02
I am trying to create a bmp which will fade to black.  I am in 16-bit color mode - so I cannot use palette manipulation.  My attempt was to use a mask which goes from white to black and then SRCAND it with my image in memory and then finally Blt to the screen.  This works but it doesn't create a smooth fade.  I have also tried manipulating pixels - but it has very poor performance. Sure would be nice if I could use some alpha blending.  Any help would be great.  
0
Comment
Question by:gpaige
3 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1176422
Haven't you seen the new AlphaBlend function yet?  It's available for Win98 and WinNT?

Reject if you have... :)
0
 

Author Comment

by:gpaige
ID: 1176423
Yes I did - but I am trying to keep compatibility with 95 and NT 4.0.
0
 
LVL 1

Accepted Solution

by:
bculver earned 200 total points
ID: 1176424
Simply subtracting fixed values from the rgb componets doesn't do very well for the reason that  the amount of rgb in a pixel cannot be decremented (faded) proportionally. Try this rgb to grayscale and back algorithm with your pixel manipulating routine.

gray = .30*red + .59*green + .11*blue;
gray=gray-x                // 0>x<255  try different fading step values to your liking
red=gray*.30;
green=gray*.59
blue=gray*.11


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Should CArray be used for a list of pointers in C++? 19 116
Unresolved External Symbols 3 102
max float value 3 51
C++ Code Issue 4 23
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question