请教高手 如何用C#和wpf显示图像
要实现多个图片按由上到下的顺序排列,中心对其。请教该如何实现。我现在的代码是
string url = AssemblyHelper.GetUrlBySectionType(entity.SectionType);
if (!string.IsNullOrEmpty(url))
{
Stream stream = File.OpenRead(url);
Stream fs = FileStream.Synchronized(stream);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(fs);
System.Drawing.Bitmap bmp2 = new System.Drawing.Bitmap(100, 92);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp2);
g.Clear(System.Drawing.Color.White);
g.DrawImage(bmp, 0, 0, new System.Drawing.RectangleF(0, 4, 100, 96), System.Drawing.GraphicsUnit.Pixel);
bmp2 = new System.Drawing.Bitmap(bmp2, new System.Drawing.Size(entity.Width, entity.Height));
MemoryStream ms = new MemoryStream();
bmp2.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = new MemoryStream(ms.ToArray());
bitmap.EndInit();
ms.Close();
fs.Close();
entity.ImageSource = bitmap.Clone();
}
如果entity.Width设成常数100,就能顺序排列,要是每一个entity的width不一样,就不能顺序排列。请教大侠们,该如何实现。 --------------------编程问答-------------------- 有没有高手看一下呀?多谢了
补充:.NET技术 , C#