Click here to Skip to main content
Licence CPOL
First Posted 21 Feb 2007
Views 34,597
Downloads 203
Bookmarked 59 times

ReflectionPicture

By | 21 Feb 2007 | Article
A Vista-Style control that shows an image and its gradient-opactity reflection.

Screenshot - screen.jpg

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;
    }
}

License

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

CEO

Spain Spain

Member

I'm a young entrepreneur from Cartagena (Spain). I'm the creator and owner of some popular websites like Chuletas and Wikiteka.
 
Visit my blog at DigitalEstudio.es

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionVB PinmemberILESKev10:11 5 Feb '12  
QuestionLicence PinmemberJulian-w4:25 30 Dec '07  
GeneralRe: Licence [modified] PinmemberFco. Javier Marin4:27 30 Dec '07  
Yes, you can use it, it's totally free and open for everyone
 
----
Chuletas y apuntes

GeneralRe: Licence PinmemberJulian-w4:42 30 Dec '07  
GeneralTremendo!! [modified] PinmemberParanosh1:16 15 Apr '07  
GeneralVery nice! PinmemberAndrejV23:18 1 Mar '07  
GeneralExcellent PinmvpColin Angus Mackay0:34 22 Feb '07  
GeneralWhy not use BitmapData? [modified] PinmembereisernWolf23:34 21 Feb '07  
GeneralRe: Why not use BitmapData? PinmemberFco. Javier Marin9:04 22 Feb '07  
GeneralArticle Pinmembernorm .net21:17 21 Feb '07  
GeneralRe: Article PinmemberFco. Javier Marin9:03 22 Feb '07  
GeneralRe: Article Pinmembernorm .net20:40 22 Feb '07  
GeneralRe: Article PinadminChris Maunder6:41 1 Mar '07  
GeneralRe: Article PinmemberFco. Javier Marin6:48 1 Mar '07  
GeneralGreat Job Pinmembertim_mcgwyn10:11 21 Feb '07  
GeneralVery Slick!! Pinmemberjconwell7:16 21 Feb '07  
GeneralBien hecho! PinmemberUnRusoDeCaracas7:01 21 Feb '07  
GeneralLook a like Pinmembergamon026:04 21 Feb '07  
GeneralRe: Look a like PinmemberFco. Javier Marin6:12 21 Feb '07  
GeneralRe: Look a like Pinmembergamon027:08 21 Feb '07  

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.

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