I wrote a quick splash to test performance using WPF, although I canβt say for sure that it uses a GPU.
However, see below. This scales the image to 33.5 (or something else) from its original size.
public void Resize() { double scaleFactor = 33.5; var originalFileStream = System.IO.File.OpenRead(@"D:\SkyDrive\Pictures\Random\Misc\DoIt.jpg"); var originalBitmapDecoder = JpegBitmapDecoder.Create(originalFileStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); BitmapFrame originalBitmapFrame = originalBitmapDecoder.Frames.First(); var originalPixelFormat = originalBitmapFrame.Format; TransformedBitmap transformedBitmap = new TransformedBitmap(originalBitmapFrame, new System.Windows.Media.ScaleTransform() { ScaleX = scaleFactor, ScaleY = scaleFactor }); int stride = ((transformedBitmap.PixelWidth * transformedBitmap.Format.BitsPerPixel) + 7) / 8; int pixelCount = (stride * (transformedBitmap.PixelHeight - 1)) + stride; byte[] buffer = new byte[pixelCount]; transformedBitmap.CopyPixels(buffer, stride, 0); WriteableBitmap transformedWriteableBitmap = new WriteableBitmap(transformedBitmap.PixelWidth, transformedBitmap.PixelHeight, transformedBitmap.DpiX, transformedBitmap.DpiY, transformedBitmap.Format, transformedBitmap.Palette); transformedWriteableBitmap.WritePixels(new Int32Rect(0, 0, transformedBitmap.PixelWidth, transformedBitmap.PixelHeight), buffer, stride, 0); BitmapFrame transformedFrame = BitmapFrame.Create(transformedWriteableBitmap); var jpegEncoder = new JpegBitmapEncoder(); jpegEncoder.Frames.Add(transformedFrame); using (var outputFileStream = System.IO.File.OpenWrite(@"C:\DATA\Scrap\WPF.jpg")) { jpegEncoder.Save(outputFileStream); } }
The image I tested was 495 x 360. It resized to 16k x 12k in a couple of seconds, including saving.
It resizes to 1.5x about 165 times per second in single-core mode. On i7 and the GPU, it would seem to do nothing, the processor is 20% I expect to get 5 times more with multithreading.
Performance profiling shows a hot way to wpfgfx_v0400.dll , which is the native WPF graphics library and is close to DirectX (look-up 'milcore' on Google).
So it can accelerate, I donβt know.
Luke
source share