工程師嘛,圖片加工也要會是很自然不過的事了,特別是你有用到平面圖的機制時
「I am here」標示本來是不需要半透明的,基於方便參考其他地標時,還是給個半透明的版本好了
===================================================
...
...
...
var Alpha=0.55f;
Bitmap bmpIamHere = new Bitmap(imgIamHereIcon);
Color background = bmpIamHere.GetPixel(0, 0);
//設定透明色為.....
bmpIamHere.MakeTransparent(background);
Graphics gfxMap = Graphics.FromImage(imgMap);
//set alpha value.
ColorMatrix cm = new ColorMatrix();
cm.Matrix33 = Alpha;
ImageAttributes ia = new ImageAttributes();
ia.SetColorMatrix(cm);
//沒有 Alpha值時,直接繪製,gfxMap.DrawImage(bmpIamHere, (float)markAtX, (float)markAtY, bmpIamHere.Width, bmpIamHere.Height);
//有alpha值時,請用以下方式
gfxMap.DrawImage(bmpIamHere, new Rectangle((int)markAtX, (int)markAtY, bmpIamHere.Width, bmpIamHere.Height), 0, 0, bmpIamHere.Width, bmpIamHere.Height, GraphicsUnit.Pixel, ia);
...
...
...
=================================================
來源在此
加油了
沒有留言:
張貼留言