我想要合併兩個圖像,一個圖像是300x300,另一個是100x100,首先我創建了一個畫布,然後創建了兩個圖像,我添加了到這兩個圖像到畫布和畫布被添加到內容面板,然後我創建了一個writeablebitmap
並呈現畫布並創建了一個方法savejpeg
它將圖像保存到isolated stoarage
,但孤立的存儲不顯示整個圖像它保存一個黑色屏幕。如何在Windows Phone中合併兩個圖像並將其保存到獨立存儲器
首先我創建畫布通過代碼設置其高度寬度和背景顏色然後我創建兩個圖像編程我已經添加到畫布然後畫布加到contentpanel
我的代碼是:
public void CreateImage()
{
Canvas canvas = new Canvas();
canvas.Height = 400;
canvas.Width = 400;
canvas.Background = new SolidColorBrush(Colors.Red);
Image img1 = new Image();
img1.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Image/Desert.jpg");
img1.Height = 300;
img1.Width = 300;
img1.Margin = new Thickness(0, 10, 0, 0);
Image img2 = new Image();
img2.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Image/Jellyfish.jpg");
img2.Height = 50;
img2.Width = 50;
img2.Margin=new Thickness(0,10,300,0);
canvas.Children.Add(img1);
canvas.Children.Add(img2);
ContentPanel.Children.Add(canvas);
WriteableBitmap wb = new WriteableBitmap(400, 400);
wb.Render(canvas, new MatrixTransform());
MemoryStream ms = new MemoryStream();
wb.SaveJpeg(ms,400,400,0,100);
using (var isoFileStream = new IsolatedStorageFileStream("myPicture.jpg", FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication()))
{
wb.SaveJpeg(isoFileStream, 400, 400, 0, 100);
}
}
當我保存圖像,然後我得到孤立存儲中的黑色屏幕。 如何將兩個圖像保存在畫布上?
我現在我的代碼是: – sonia 2013-02-28 11:24:05
@sonia:你是什麼意思? – 2013-02-28 12:31:42
我正在使用這種方法,並將我的畫布傳遞給它總線同樣的錯誤即將到來,只有我的畫布顯示在屏幕上 – sonia 2013-03-01 04:30:24