【发布时间】:2017-11-29 15:38:15
【问题描述】:
我使用以下代码将图像文件转换为 96 DPI 并将其用作背景。
BitmapSource bitmapSource = ConvertBitmapTo96Dpi(CompleteBackgroundImage);
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
MemoryStream memoryStream = new MemoryStream();
encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
encoder.Save(memoryStream);
memoryStream.Position = 0;
CompleteBackgroundImage = new BitmapImage();
CompleteBackgroundImage.BeginInit();
CompleteBackgroundImage.StreamSource = memoryStream;
CompleteBackgroundImage.CacheOption = BitmapCacheOption.OnLoad;
CompleteBackgroundImage.DecodePixelHeight = (int)Math.Round(finalHeight, MidpointRounding.AwayFromZero);
CompleteBackgroundImage.DecodePixelWidth = (int)Math.Round(finalWidth, MidpointRounding.AwayFromZero);
CompleteBackgroundImage.EndInit();
memoryStream.Close();
现在,如果屏幕比文件大,我想将图像乘以一个图像,这样我就可以将其用作背景。
所以如果我的屏幕是1920 x 1080,而图片只有500 x 500,我希望那张图片和2000 x 1500一样大,并且原图必须从左到右显示4次,从上到下显示3次。
但是我应该怎么做呢?
【问题讨论】:
标签: c# wpf image memorystream bitmapimage