Trick to resize transparent images

I wanted to make a small image resize function in my website, and everything worked fine, but i faced a problem resizing transparent .png and .gif images.

After resizing done, i find that the output resized images transparent parts become white color and not transparent anymore.

This was my code:


And searched to find a solution for this problem with no hope for a complete easy solution.


And while trying to find a way, i remembered that i did a small resize tool “windows application” 4 years ago, i decided to try it and see the output, and i found after resize the image, the output is very nice and preserve transparent :).

I traced the code, and found the only difference is that in my windows application i was using the PictureBox control not the Graphics class.

I copies the code from there and put in my “sure needed to import System.Windows.Forms library in my to use the PictureBox control”.


And the Code became:



I believe that using Windows form control in is odd, but it solved my current problem, it may need some more testing for performance issues.

Deploying ajax wcf service on shared hosting.

2 day ago i suffered from launching a testing website version on my shared hosting account, what i suffered from is that the website had a wcf ajax service which i was using in ajax calls from jquery to server.

I faced a lot of small problem in configuring the website to work the same as it works local.

The main problem i faced, that i didn’t find anyone on the internet talking about how to solve this problem completely.

After reading many articles and editing my web.config many times, i got it, and here is the result web.config which is running now on server and everything is working fine with wfc.



My hosting was shared hosting godaddy, with IIS7 installed.


Also check this article, you may face this problem as me:


Edit: after some days trying with ajax wcf on my shared hosting in my current project, i decided to remove it and get back to normal webservices, i don’t have time for “shared hosting-wcf” hassles, at least for now.