我想繪製一個白色的矩形(100 x 200),並在中間放置一個較小的圖像(50 x 75),以便它看起來類似於紙牌的背面。在另一個頂部覆蓋圖像
使用下面的代碼,我得到的只是周圍有邊框的圖塊,但沒有圖像。
//generate temporary control to render image
Image temporaryImage = new Image { Source = emptyTileWatermark, Width = destWidth, Height = destHeight };
//create writeableBitmap
WriteableBitmap wb = new WriteableBitmap(outputWidth, outputHeight);
wb.Clear(Colors.White);
// Closed green polyline with P1(0, 0), P2(outputWidth, 0), P3(outputWidth, outputHeight) and P4(0, outputHeight)
var outline = new int[] { 0, 0, outputWidth, 0, outputWidth, outputHeight, 0, outputHeight, 0, 0};
wb.DrawPolyline(outline, Colors.Black);
wb.Invalidate();
wb.Render(temporaryImage, new TranslateTransform { X = destX, Y = destY });
wb.Invalidate();
我應該指出要做.Clear(),我正在使用WriteableBitmapEx項目。
任何想法???
完美地工作!謝謝! – 2011-06-14 05:14:48