an other-other image processing
-
excuse me firends, have you ever seen what happens when you open 'start' from taskbar and then 'turn off computer' or 'log off'? when you click on them, the environment start to become white and black. and i have an image in my form and i want to make a similar process to make that image start becoming white and black like you have seen in turning off your computer. how can i do that please? thanks
-
excuse me firends, have you ever seen what happens when you open 'start' from taskbar and then 'turn off computer' or 'log off'? when you click on them, the environment start to become white and black. and i have an image in my form and i want to make a similar process to make that image start becoming white and black like you have seen in turning off your computer. how can i do that please? thanks
This requires some math, albeit some very simple math. You need two pictures (actually, you can calculate the luma value on the fly inside the lerp method, but this one is a bit simpler and faster, but uses twice the memory): 1) the colored version 2) the grayscale/bw version Then, based on a timer for the fading transition (let's say 5 seconds from colored to BW) you simply do a linear interpolation[^] between the colored pixel value to the BW pixel value on a time range from 0 to 1. In a timer, you could do this (pseudocode):
const float transitionTime = 5000f; // 5 seconds
float normalizedTransitionTime = millsecondsSinceTransitionStart / transitionTime;red = (byte)Lerp(normalizedTransitionTime , coloredPixelR, bwPixelR);
green = (byte)Lerp(normalizedTransitionTime , coloredPixelG, bwPixelG);
blue = (byte)Lerp(normalizedTransitionTime , coloredPixelB, bwPixelB);What the method Lerp[^] does is simply a interpolation in the form
value1 + (value2 - value1) * amount
as used in the XNA framework (for example)
float Lerp(float amount, float value1, float value2)
{
return value1 + (value2 - value1) * amount;
}regards
modified on Sunday, June 8, 2008 12:51 PM
-
This requires some math, albeit some very simple math. You need two pictures (actually, you can calculate the luma value on the fly inside the lerp method, but this one is a bit simpler and faster, but uses twice the memory): 1) the colored version 2) the grayscale/bw version Then, based on a timer for the fading transition (let's say 5 seconds from colored to BW) you simply do a linear interpolation[^] between the colored pixel value to the BW pixel value on a time range from 0 to 1. In a timer, you could do this (pseudocode):
const float transitionTime = 5000f; // 5 seconds
float normalizedTransitionTime = millsecondsSinceTransitionStart / transitionTime;red = (byte)Lerp(normalizedTransitionTime , coloredPixelR, bwPixelR);
green = (byte)Lerp(normalizedTransitionTime , coloredPixelG, bwPixelG);
blue = (byte)Lerp(normalizedTransitionTime , coloredPixelB, bwPixelB);What the method Lerp[^] does is simply a interpolation in the form
value1 + (value2 - value1) * amount
as used in the XNA framework (for example)
float Lerp(float amount, float value1, float value2)
{
return value1 + (value2 - value1) * amount;
}regards
modified on Sunday, June 8, 2008 12:51 PM
thanks for your consideratoin. i know i'm too lazy but could you explain a bit more for me? the links couldn't help (:)) i want sth that makes a smooth conversion with an optimum speed and timings. my problem is what should the fields 'red', 'green' and 'blue' assigned to? what are them? i wonder if you help me a bit more clear. thanks again