ReflectionPicture






4.75/5 (14 votes)
A Vista-Style control that shows an image and its gradient-opactity reflection.
Introduction
This control tries to simulate the reflection of an image with lower opacity, like it appears in the above image. The control is very easy to use.
In order to create the reflection, the control calls the function SubActualizarReflejo
, that creates the reflection image.
private void SubActualizarReflejo()
{
try
{
actualizando = true;
this.reflejo = null;
Bitmap volteada = new Bitmap(imagen, ObtenerAreaImagen().Size);
volteada.RotateFlip(RotateFlipType.RotateNoneFlipY);
Bitmap reflejo = new Bitmap(volteada.Width,
volteada.Height, PixelFormat.Format32bppArgb);
for (int y = 0; y < volteada.Height; y++)
{
//Opacidad resultante para un pixel totalmente opaco
int opacidad = (int)Math.Round(((double)255 / volteada.Height) *
(volteada.Height - y)) - indiceOpacidad;
if (opacidad < 0) opacidad = 0;
if (opacidad > 255) opacidad = 255;
for (int x = 0; x < volteada.Width; x++)
{
Color color = volteada.GetPixel(x, y);
if (color.A == 0)
continue;
int opacidadPixel =
(int)Math.Round((opacidad / (double)255) * color.A);
reflejo.SetPixel(x, y, Color.FromArgb(opacidadPixel,
color.R, color.G, color.B));
}
}
this.reflejo = reflejo;
actualizando = false;
this.Invoke(new EventHandler(refrescar));
}
catch
{
this.reflejo = null;
}
}