5

gdi/gdi+ を使用して、このような明るい境界線を描画するにはどうすればよいですか? ここに画像の説明を入力

誰でも私に一連の考えを与えることができますか?ありがとう。

4

2 に答える 2

2

GDI+ を使用する場合は、PathGradientBrush を使用することをお勧めします。中央の色に向かってすべてブレンドされたエッジの周りの一連の色で領域を塗りつぶすことができます。この場合、必要なエッジ カラーはおそらく 1 つだけです。角丸四角形の GraphicsPath を作成し、FillPath() を使用して 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);
于 2012-07-27T15:35:35.957 に答える
1
  • 境界線自体よりも少し大きい画像に境界線を描画します。
  • ぼかします。
  • 枠の内側を消去します。
  • ぼやけた画像の上に境界線を描きます。
  • そのイメージを目的地まで描く。
于 2012-07-27T15:40:24.280 に答える