2013-02-28 34 views

回答

1

您可以創建一個位圖,從它創建一個Graphics對象,用任何顏色填充它。

Bitmap^ bmp = gcnew Bitmap(WIDTH, HEIGHT); 
Graphics^ g = Graphics::FromImage(bmp); 
g->FillRectangle(
    gcnew SolidBrush(Color::FromArgb(alfa, red, green, blue)), 
    Rectangle(Point.Empty, bmp.Size()); 

這麼容易。

1

爲您的按鈕創建一個正確大小的位圖並將像素的顏色更改爲您的rbga顏色。

例如:

 Bitmap image1 = gcnew Bitmap(160,160); 
    int x; 
    int y; 

    Color pixelColor = Color::FromArgb(A, R, B, G); 
    // Loop through the images pixels to reset color. 
    for (x = 0; x < image1->Width; x++) 
    { 
     for (y = 0; y < image1->Height; y++) 
     { 
      image1->SetPixel(x, y, pixelColor); 

     } 

    } 

你也可以得到爲位圖圖形上下文,並使用Graphics.FillRectangle方法來填充它。

位圖是一個形象,所以你就可以將其設置爲你的按鈕的圖像