5
A
回答
1
- 繪製邊界進入圖像比邊界本身稍大。
- 模糊它。
- 清除邊框內部。
- 在模糊圖像上繪製邊框。
- 將該圖像繪製到目的地。
1
使用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);
+0
相似,但效果不太一樣,我想...我無法控制發光的有條不紊......謝謝你 – toki 2012-07-31 12:06:37
相關問題
- 1. 邊界外發光效果
- 2. 如何在位圖周圍製作外部發光效果?
- 3. WinRT中TextBlock的外部發光效果
- 4. WPF內部發光效果
- 5. Flex發光效果定製
- 6. 如何在ImageView上設置外部發光效果?
- 7. 如何在HTML/CSS中爲外部發光效果添加列?
- 8. UISegmentedControl發光效果
- 9. WebGL發光效果
- 10. 如何使用HLSL製作外發光效果?
- 11. 發光效果對PNG的脈動發光效果
- 12. 按鈕的內部發光效果
- 13. TextBlock發光效果內部按鈕
- 14. WPF中的內部發光效果
- 15. ImageView帶有陰影角落,實心邊框和發光效果
- 16. HTML,CSS和Javascript非常酷的邊框旋轉發光效果
- 17. 如何繪製「發光」線在OpenGL ES
- 18. 製作發光效果字體
- 19. 除了使用閃光燈之外,如何實現發光效果
- 20. iOS/GLES2:如何實現發光效果
- 21. 如何獲得與CSS發光效果
- 22. 如何隱藏發光效果?
- 23. 在InkCanvas中繪製線條的發光效果
- 24. 對MouseEnter發光效果WPF
- 25. UITextView中的發光效果
- 26. DirectX 9 HLSL發光效果
- 27. 發光風格效果
- 28. 圍繞NSView發光效果
- 29. 綻放和發光效果
- 30. Directx 11 HLSL發光效果
這需要一個LinearGradientBrush。或DrawImage()。 – 2012-07-27 13:15:50