Click here to Skip to main content
Click here to Skip to main content


, 21 Feb 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
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 PinmemberILESKev5-Feb-12 11:11 
QuestionLicence PinmemberJulian-w30-Dec-07 5:25 
GeneralRe: Licence [modified] PinmemberFco. Javier Marin30-Dec-07 5:27 
GeneralRe: Licence PinmemberJulian-w30-Dec-07 5:42 
GeneralTremendo!! [modified] PinmemberParanosh15-Apr-07 2:16 
GeneralVery nice! PinmemberAndrejV2-Mar-07 0:18 
GeneralExcellent PinmvpColin Angus Mackay22-Feb-07 1:34 
GeneralWhy not use BitmapData? [modified] PinmembereisernWolf22-Feb-07 0:34 
GeneralRe: Why not use BitmapData? PinmemberFco. Javier Marin22-Feb-07 10:04 
GeneralArticle Pinmembernorm .net21-Feb-07 22:17 
GeneralRe: Article PinmemberFco. Javier Marin22-Feb-07 10:03 
GeneralRe: Article Pinmembernorm .net22-Feb-07 21:40 
GeneralRe: Article PinadminChris Maunder1-Mar-07 7:41 
GeneralRe: Article PinmemberFco. Javier Marin1-Mar-07 7:48 
GeneralGreat Job Pinmembertim_mcgwyn21-Feb-07 11:11 
GeneralVery Slick!! Pinmemberjconwell21-Feb-07 8:16 
GeneralBien hecho! PinmemberUnRusoDeCaracas21-Feb-07 8:01 
GeneralLook a like Pinmembergamon0221-Feb-07 7:04 
GeneralRe: Look a like PinmemberFco. Javier Marin21-Feb-07 7:12 
GeneralRe: Look a like Pinmembergamon0221-Feb-07 8:08 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 21 Feb 2007
Article Copyright 2007 by Fco. Javier Marin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid