5,702,067 members and growing! (14,880 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate License: The Code Project Open License (CPOL)

ReflectionPicture

By Fco. Javier Marin

A Vista-Style control that shows an image and its gradient-opactity reflection
C#, Windows, .NET 2.0, .NET, Visual Studio, Dev

Posted: 21 Feb 2007
Updated: 21 Feb 2007
Views: 19,063
Bookmarked: 54 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
12 votes for this Article.
Popularity: 4.86 Rating: 4.50 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
2 votes, 16.7%
3
2 votes, 16.7%
4
8 votes, 66.7%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Screen:

Screenshot - screen.jpg

Introduction - English

This control tries to simulate the reflection of an image with degrading of opacity, like which it appears in the viewfinder of photographies of Windows. The control is very easy to use, it is possible to be used with the designer of Studio Line of vision, and to be formed from him.

In order to create the reflection, the control calls the function SubActualizarReflejo, that creates the image reflected and with the applied degraded one. That function is called to traves of a subprocess to avoid that the system is affected by the high consumption of CPU that is needed to generate it, reason why the image can take moments in appearing

Introducción -Español

Este control intenta simular el reflejo de una imagen con un degradado de opacidad, como el que aparece en el visor de fotografías de Windows. El control es muy fácil de utilizar, se puede usar con el diseñador de Visual Studio, y configurar desde él.

Para crear el reflejo, el control llama a la funcion SubActualizarReflejo, que crea la imagen reflejada y con el degradado aplicado. Esa funcion es llamada a traves de un subproceso para evitar que el sistema se vea afectado por el alto consumo de CPU que se necesita para generarla, por lo que la imagen puede tardar unos instantes en aparecer cuando se crea el control, sobre todo si es una imagen grande.

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


I am a young student of Cartagena, Spain. I like much the programming, I program since I was 14, and I dominate languages like C #, PHP, Javascript and C.

At the moment, I'm studying engineering of Telecommunications in the university of my city and I maintain some popular websites like Xuletas and SayToMe
Occupation: Software Developer
Location: Spain Spain

Other popular Miscellaneous articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
QuestionLicencememberJulian-w5:25 30 Dec '07  
GeneralRe: Licence [modified]memberFco. Javier Marin5:27 30 Dec '07  
GeneralRe: LicencememberJulian-w5:42 30 Dec '07  
GeneralTemendo!!memberParanosh2:16 15 Apr '07  
GeneralVery nice!memberAndrejV0:18 2 Mar '07  
GeneralExcellentmvpColin Angus Mackay1:34 22 Feb '07  
GeneralWhy not use BitmapData? [modified]membereisernWolf0:34 22 Feb '07  
GeneralRe: Why not use BitmapData?memberFco. Javier Marin10:04 22 Feb '07  
GeneralArticlemembernorm .net22:17 21 Feb '07  
GeneralRe: ArticlememberFco. Javier Marin10:03 22 Feb '07  
GeneralRe: Articlemembernorm .net21:40 22 Feb '07  
GeneralRe: ArticleadminChris Maunder7:41 1 Mar '07  
GeneralRe: ArticlememberFco. Javier Marin7:48 1 Mar '07  
GeneralGreat Jobmembertim_mcgwyn11:11 21 Feb '07  
GeneralVery Slick!!memberjconwell8:16 21 Feb '07  
GeneralBien hecho!memberUnRusoDeCaracas8:01 21 Feb '07  
GeneralLook a likemembergamon027:04 21 Feb '07  
GeneralRe: Look a likememberFco. Javier Marin7:12 21 Feb '07  
GeneralRe: Look a likemembergamon028:08 21 Feb '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 21 Feb 2007
Editor:
Copyright 2007 by Fco. Javier Marin
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project