Click here to Skip to main content
14,304,598 members


Rate this:
4.75 (16 votes)
Please Sign up or sign in to vote.
4.75 (16 votes)
21 Feb 2007CPOL
A Vista-Style control that shows an image and its gradient-opactity reflection.

Screenshot - screen.jpg


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()
        actualizando = true;
        this.reflejo = null;

        Bitmap volteada = new Bitmap(imagen, ObtenerAreaImagen().Size);
        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)

                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));
        this.reflejo = null;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Fco. Javier Marin
Spain Spain
I'm a young entrepreneur from Cartagena (Spain). I'm the creator and owner of some popular websites like Chuletas and Wikiteka.

Currently, I'm working on Ideatic, a company for Internet and software develop.

Comments and Discussions

QuestionVB Pin
ILESKev5-Feb-12 10:11
memberILESKev5-Feb-12 10:11 
QuestionLicence Pin
Julian-w30-Dec-07 4:25
memberJulian-w30-Dec-07 4:25 
GeneralRe: Licence [modified] Pin
Fco. Javier Marin30-Dec-07 4:27
memberFco. Javier Marin30-Dec-07 4:27 
GeneralRe: Licence Pin
Julian-w30-Dec-07 4:42
memberJulian-w30-Dec-07 4:42 
GeneralTremendo!! [modified] Pin
Paranosh15-Apr-07 1:16
memberParanosh15-Apr-07 1:16 
GeneralVery nice! Pin
AndrejV1-Mar-07 23:18
memberAndrejV1-Mar-07 23:18 
GeneralExcellent Pin
Colin Angus Mackay22-Feb-07 0:34
memberColin Angus Mackay22-Feb-07 0:34 
GeneralWhy not use BitmapData? [modified] Pin
eisernWolf21-Feb-07 23:34
membereisernWolf21-Feb-07 23:34 
GeneralRe: Why not use BitmapData? Pin
Fco. Javier Marin22-Feb-07 9:04
memberFco. Javier Marin22-Feb-07 9:04 
GeneralArticle Pin
NormDroid21-Feb-07 21:17
professionalNormDroid21-Feb-07 21:17 
GeneralRe: Article Pin
Fco. Javier Marin22-Feb-07 9:03
memberFco. Javier Marin22-Feb-07 9:03 
GeneralRe: Article Pin
NormDroid22-Feb-07 20:40
professionalNormDroid22-Feb-07 20:40 
GeneralRe: Article Pin
Chris Maunder1-Mar-07 6:41
adminChris Maunder1-Mar-07 6:41 
GeneralRe: Article Pin
Fco. Javier Marin1-Mar-07 6:48
memberFco. Javier Marin1-Mar-07 6:48 
GeneralGreat Job Pin
Mc Gwyn21-Feb-07 10:11
memberMc Gwyn21-Feb-07 10:11 
GeneralVery Slick!! Pin
jconwell21-Feb-07 7:16
memberjconwell21-Feb-07 7:16 
Nice control! I really like that faded out reflection!

John Conwell

GeneralBien hecho! Pin
UnRusoDeCaracas21-Feb-07 7:01
memberUnRusoDeCaracas21-Feb-07 7:01 
GeneralLook a like Pin
gamon0221-Feb-07 6:04
membergamon0221-Feb-07 6:04 
GeneralRe: Look a like Pin
Fco. Javier Marin21-Feb-07 6:12
memberFco. Javier Marin21-Feb-07 6:12 
GeneralRe: Look a like Pin
gamon0221-Feb-07 7:08
membergamon0221-Feb-07 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 21 Feb 2007


61 bookmarked