UPDATE : This code doesn't work properly, go here for a properly working one.
I needed to resize an image in Silverlight and then save it out as a JPEG. I could have just used a transform on it then rendered it to a WriteableBitmap but the transforms were optimized for realtime performance and doesn't work too well when you need to maintain quality.
I stumbled upon a Bicubic Resize code in a library called AForge.Net and it was in C#, so it was simple enough for me to convert it to VB for me to use it in Silverlight. And since I DIDN'T find a lot of Bicubic Interpolation .Net resize code on the net, I'm gonna just put this copy up here.
As a bonus I kept on my comments in so you guys can see what was going through my head as I was working my way through the code.
There's one caveat though, I didn't do any Alpha premultiplication with this code, which basically means if your images have a non FULLY opaque region, the results won't be pretty. Here's your homework assignment if you want to have that functionality.
I learnt 2 things while porting this code.
After my little exercise in dabbling with this, THEN I find a WriteBitmapEx library which pretty much seems to be a very useful class for raw manipulation of images in Silverlight, check it out!
Tweet
Powered by: newtelligence dasBlog 2.1.8102.813
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Marauderz
E-mail