Blend Transitions between two images

  • Thread starter Thread starter Nuno Esculcas
  • Start date Start date
N

Nuno Esculcas

Hello,

Is there any special functionality in C# to make a blend transition
between two images like the messager 6 do.

If no, does any one now how its done? how the guys that implemented
messager 6 do the transition from a old display picture to a new one?

Thanks
Nuno
 
Nuno, I'm not exactly sure what you are trying to do or referring to. Could
you give a few more details?
 
Hello again,

I want to make a small animation to switch bettween to images, like a
blend transition between the two images (the first one fades and the
second appears).
In VC++6 i use the AnimateWindow() function to make the same transition
but with Windows.

Now i only ask if there is any functionality like the AnimateWindow in
C# or anything like this.

Note: I'm afraid that this question is more for GDI+ but i can't call
the AnimateWindow in C# too, i'm afraid that i ve to make a platform
invoke to call the Win32 AnimateWindow function :(

Thanks
Nuno
 
I don't know how to do the transition automatically, but I know you
can do it manually. The Bitmap object has a GetPixel function which
will return the RGB value of a particular pixel of a picture. If you
get the RGB values of both pictures at the same pixel, it would be
possible to transition between the two pixel colors. This would be
processor intensive, so you may save off the resulting images to
display if you are going to show the transition multiple times.
I did something similar here, which you can modify to make the
transition.

public Bitmap PicAdd(Bitmap FirstImage, Bitmap SecondImage)
{
Bitmap bmp = (Bitmap)FirstImage.Clone();
byte red;
byte green;
byte blue;
for (int row = 0; row < SecondImage.Height; row++)
{
for (int col = 0; col < SecondImage.Width; col++)
{
red = (byte)(FirstImage.GetPixel(col, row).R &
SecondImage.GetPixel(col,row).R);
green = (byte)(FirstImage.GetPixel(col, row).G &
SecondImage.GetPixel(col,row).G);
blue = (byte)(FirstImage.GetPixel(col, row).B &
SecondImage.GetPixel(col,row).B);
Color color = Color.FromArgb(red, green, blue);
bmp.SetPixel(col, row, color);
}
}
return bmp;
}
 
Toby Nance said:
I don't know how to do the transition automatically, but I know you
can do it manually. The Bitmap object has a GetPixel function which
will return the RGB value of a particular pixel of a picture. If you
get the RGB values of both pictures at the same pixel, it would be
possible to transition between the two pixel colors. This would be
processor intensive, so you may save off the resulting images to
display if you are going to show the transition multiple times.
I did something similar here, which you can modify to make the
transition.

I would recommend NOT using GetPixel / SetPixel as they are really slow. If
you have to do it manually, then the only way to go is unsafe code with
bitmap.LockPixels and some pointer arithmetic. Here's a good example of
that:

http://www.codeproject.com/cs/media/csharpgraphicfilters11.asp

On a smallish picture (maybe 100x100 pixes) performance will probably be
acceptable. If you're doing full screen fades, I think you'll find it hard
to get more than about two frames per second. DirectX would probably have
some routines to do it faster, but that's getting to be a lot of work for
just simple image transition.

I'm betting that P/Invoke is the way to go...
 
Back
Top