Click here to Skip to main content
Licence CPOL
First Posted 21 Feb 2007
Views 33,525
Downloads 168
Bookmarked 59 times

ReflectionPicture

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

1

2
2 votes, 15.4%
3
2 votes, 15.4%
4
9 votes, 69.2%
5
4.72/5 - 13 votes
2 removed
μ 4.52, σa 1.36 [?]

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 PinmemberILESKev11:11 5 Feb '12  
QuestionLicence PinmemberJulian-w5:25 30 Dec '07  
GeneralRe: Licence [modified] PinmemberFco. Javier Marin5:27 30 Dec '07  
GeneralRe: Licence PinmemberJulian-w5:42 30 Dec '07  
GeneralTremendo!! [modified] PinmemberParanosh2:16 15 Apr '07  
GeneralVery nice! PinmemberAndrejV0:18 2 Mar '07  
GeneralExcellent PinmvpColin Angus Mackay1:34 22 Feb '07  
GeneralWhy not use BitmapData? [modified] PinmembereisernWolf0:34 22 Feb '07  
GeneralRe: Why not use BitmapData? PinmemberFco. Javier Marin10:04 22 Feb '07  
GeneralArticle Pinmembernorm .net22:17 21 Feb '07  
GeneralRe: Article PinmemberFco. Javier Marin10:03 22 Feb '07  
GeneralRe: Article Pinmembernorm .net21:40 22 Feb '07  
GeneralRe: Article PinadminChris Maunder7:41 1 Mar '07  
GeneralRe: Article PinmemberFco. Javier Marin7:48 1 Mar '07  
GeneralGreat Job Pinmembertim_mcgwyn11:11 21 Feb '07  
GeneralVery Slick!! Pinmemberjconwell8:16 21 Feb '07  
GeneralBien hecho! PinmemberUnRusoDeCaracas8:01 21 Feb '07  
GeneralLook a like Pinmembergamon027:04 21 Feb '07  
GeneralRe: Look a like PinmemberFco. Javier Marin7:12 21 Feb '07  
GeneralRe: Look a like Pinmembergamon028: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
Web04 | 2.5.120209.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