2012-07-27 8 views

Antwort

1
  • die Grenze in ein Bild zeichnen etwas größer als die Grenze selbst.
  • Verwischen Sie es.
  • Löschen Sie die Innenseite der Umrandung.
  • Zeichnen Sie die Grenze über das unscharfe Bild.
  • Zeichnen Sie das Bild zum Ziel.
1

Mit GDI +, würde ich empfehlen, einen PathGradientBrush zu verwenden. Mit dieser Option können Sie eine Region mit einer Reihe von Farben um die Kante füllen, die alle zu einer mittleren Farbe verschmelzen. Sie benötigen in diesem Fall wahrscheinlich nur eine Randfarbe. Erstellen Sie ein Graphic für ein Rechteck mit abgerundeten Ecken und verwenden FillPath() mit einem PathGradientBrush zu füllen:

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

ähnlich, aber nicht ganz der gleiche Effekt, den ich will ... und ich kann das Glühen nicht gut kontrollieren ...... Danke auch – toki

Verwandte Themen