I am new on Windows phone development. I am scaling an image, first time it scale image good but when I am choose another picture and implement scale on image so I get a System.OutOfMemoryException
. On this line
ScaleTransform t = new ScaleTransform() { ScaleX = 5, ScaleY = 5 };
My code where I am trying to scale image.
Image uiElement = new Image() { Source = blurImage };
ScaleTransform t = new ScaleTransform() { ScaleX = 5, ScaleY = 5 };
WriteableBitmap writeableBitmap = new WriteableBitmap(uiElement, t);
using (MemoryStream ms = new MemoryStream())
{
writeableBitmap.SaveJpeg(ms, (int)blurImage.PixelWidth, (int)blurImage.PixelHeight, 0, 100);
bmp.SetSource(ms);
imgholder.Source = null;
imgholder.Source = bmp;
ms.Dispose();
}
t = null;
writeableBitmap = null;
uiElement.Source = null;
uiElement = null;
GC.Collect();
How can I solve it?
You are scaling the image by 500%. Is this really what you want? The image or the second image could be too big after this operation.
Values between 0 and 1 decrease the width of the scaled object; values greater than 1 increase the width of the scaled object. A value of 1 indicates that the object is not scaled in the x-direction.
Negative values flip the scaled object horizontally. Values between 0 and -1 flip the scale object and decrease its width. Values less than -1 flip the object and increase its width. A value of -1 flips the scaled object but does not change its horizontal size.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.