0
在一個位圖上,我需要顯示圖形和文本值。所以我做的是用點創建一個位圖,並用這個文本創建另一個位圖並放置在大位圖上。在另一個位圖上覆蓋位圖
我試着用刷子寫文本,但即使設置了透明度,我也無法看到底層圖形。
相反,我想爲文本位圖設置透明度,但我創建的位圖是24位rgb。那麼我們可以設置24位地圖的透明度。
Bitmap textBitmap = null; textBitmap = new Bitmap(10,10,PixelFormat.Format24bppRgb);
using (Graphics memoryGrahics =
Graphics.FromImage(textBitmap))
{
memoryGrahics.FillRectangle(Brushes.Black, new Rectangle(0, 0, 100, 100));
memoryGrahics.DrawString(result, f, Brushes.White, x, y);
}
//placing the text bitmap on the graphbitmap
using (Graphics g = Graphics.FromImage(GraphBitmap))
{
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
textBitmap.MakeTransparent();
g.DrawImage(textBitmap, 0, 0);
return GraphBitmap;
}
你在說什麼類型的位圖? – thumbmunkeys
我想創建的位圖是PixelFormat.Format24bppRgb – Racs
發佈迄今爲止的代碼將有助於徵求答案。 –