2012-07-27 11 views

Respuesta

1
  • dibujar el borde en una imagen ligeramente más grande que la propia frontera.
  • Desenfoque.
  • Borre el interior del borde.
  • Dibuje el borde sobre la imagen borrosa.
  • Dibuja esa imagen en el destino.
1

Usando GDI +, le recomendaría que use un PathGradientBrush. Le permite llenar una región con una serie de colores alrededor del borde que se mezclan hacia un color central. Probablemente solo necesite 1 color de borde en este caso. Crear un GraphicsPath para un rectángulo redondeado y utilizar FillPath() para llenarlo con un PathGradientBrush:

GraphicsPath graphicsPath; 

//rect - for a bounding rect 
//radius - for how 'rounded' the glow will look 
int diameter = radius * 2; 

graphicsPath.AddArc(Rect(rect.X, rect.Y, diameter, diameter) 180.0f, 90.0f); 
graphicsPath.AddArc(Rect(rect.X + rect.Width - diameter, rect.Y, diameter, diameter), 270.0f, 90.0f); 
graphicsPath.AddArc(Rect(rect.X + rect.Width - diameter, rect.Y + rect.Height - diameter, diameter, diameter), 0.0f, 90.0f); 
graphicsPath.AddArc(Rect(rect.X, rect.Y + rect.Height - diameter, diameter, diameter), 90.0f, 90.0f); 
graphicsPath.CloseFigure(); 

PathGradientBrush brush(&graphicsPath); 
brush.SetCenterColor(centerColor); //would be some shade of blue, following your example 
int colCount = 1; 
brush.SetSurroundColors(surroundColor, &colCount); //same as your center color, but with the alpha channel set to 0 

//play with these numbers to get the glow effect you want 
REAL blendFactors[] = {0.0, 0.1, 0.3, 1.0}; 
REAL blendPos[] = {0.0, 0.4, 0.6, 1.0}; 
//sets how transition toward the center is shaped 
brush.SetBlend(blendFactors, blendPos, 4); 
//sets the scaling on the center. you may want to have it elongated in the x-direction 
brush.SetFocusScales(0.2f, 0.2f); 

graphics.FillPath(&brush, &graphicsPath); 
+0

similar, pero no del todo el mismo efecto que quiero ... y no puedo controlar el resplandor de forma exacta ...... gracias también – toki

Cuestiones relacionadas