2012年5月16日 星期三

Visual Studio Debug Web Server

I've been asked to create a web interface structure for a site still being planned. I guess my supervisor only expect me to make an outer shell to encase whatever he is developing. So I've been making webpages in VS2008. In the process I realized that when I open the pages with browsers from the debug mode, a lot of redirections end up with page 404. I searched online for some answers, but didn't find any. I guess other developers are smart enough to find out what the problem was.

Well, after delving into this problem for a while, I realize how stupid i was. The url displayed in the browser when I redirect from the default page to other pages I made was wrong. It somehow included the folder them that I place my file.

Normally, if I save my site in a folder called MySite. When I host this up, I expect that http://localhost would point to MySite. And indeed the default page would work. But clicking on links to other pages would result in http://localhost/MySite/xxx.html while http://localhost/xxx.html is correct url. Why?

After looking through some settings, I realized that VS2008 automatically set the virtual path of the site to "/MySite/", which make all the virtual paths to automatically include "MySite/" when it shouldn't, causing the annoying page 404. Note that this only happens when you run with visual studio's developer server. When you host the files on IIS, it does not get affected. So I think it's a setting only for the developer server program.

Fix: In the solution explorer, select your site (usually the very top item with the full path to the working folder). Then in the Properties panel, under Developer Web Server, change the virtual path from whatever to "/" (usually you just need to delete the folder name portion). Then you should find the developer server working properly.

2012年5月10日 星期四

Re-sizing images for website

With my super short image re-sizing procedure in my last post, I wrote a class the abstract an image file into an object. Within it, is a function to scale the image. Then I ran into a problem:
Say we have a image that's 800 x 600, and I want to resize it to fit a 600 x 200 rectangle. By using my procedures, the code:
new Bitmap(img, new Size( 600, 200));
create a image that's 600x200 from the original image. Well... the problem is that the image scale is off.
If we are indeed resizing pictures to fit a predefined windows size of 800x600, or perhaps 400x300, with my old procedures, the result would have some photos being stretched. Who would want to actually view their photos like that?
So a different method is needed that would check the original picture size against the desired size, and attempt to fit the picture in it without changing the aspect ratio. Which should be rather simple to implement.

2012年5月9日 星期三

Very simple image re-sizing in C#

Today I did some research on re-sizing images in c#. Most guides offer some lengthy code to scale the image using the Graphics object. While this allow us to set the qualities of the scaling, it has a lot of code (well.. for a lazy guy like me... 50 lines of code with long method names is very hard to read). Moreover, I really don't need the scaled-down image to be of good quality. I just want the process fast, and the result small. So I came up with this:

First you need to reference System.Drawing.dll if it's not reference by default. Then put these in the referencing section:

using System.Drawing;
using System.Drawing.Imaging;

In my test program I did this:

Image img = Image.Fromfile("... source file address");
Size newSize = Size( img.Width/2, img.Height/2);
Image newImg = new Bitmap( img, newSize);
newImg.Save("... new file address", ImageFormat.Jpeg);
img.Dispose();
newImg.Dispose();

And as simple as that, would read in the source image file of any format, and save to the new file address in jpeg format and half the original size. Simple enough!!

Of course, if image quality is a concern, using the Graphics object should yield better results. 

2011年3月29日 星期二

コミネリサ

最近看了一部叫Gosick的動畫
老實說動畫本身我是覺得還算可以而已啦
不過那個片尾曲倒是讓我覺得驚豔
就去查了一下
歌手叫小峰理紗
詳細資料就不說了
唱過一些有名的動畫歌曲
有過兩張專輯...
可惜找不到載點...原版貨一張要價快一千塊


Gosick Ed
目前只有這麼長的版本
其他更長的版本似乎都只是重覆剪接出來的 (雖然我想正式版可能也不會差太多吧)

2010年6月5日 星期六

Shrek 4

Shrek 4 is probably the last thing I expected to be entertaining this year, or at least the last thing I expected to be fun that I'd actually watch. I mean, when Shrek 2 was barely acceptable and Shrek the third was simply awful, I thought Shrek 4 would just be there only for the 3D effects and some lame jokes. Well..  I guess I was very wrong. Although I think it still is no where near as good as the first movie, it did somewhat made par with the second movie, if not surpassing it. Well.. it's been quite a while since I watched it. I really don't know how much I can comment on it. But, at least I think it's a movie that won't waste your money and time.
... Of course, this whole Shrek 4 is a good movie idea may well be an side effect of seeing fat puss...










On the other hand, Prince of Persia seem to be pretty good reviews from various sources (ugh... tho most of my sources are questionable), maybe I should find some time and money to watch it. Time isn't too much of an issue right now, but money... Ugh, I need financial aid.

2010年5月2日 星期日

鋼鐵人 II

我第一次聽說鋼鐵人要拍成電影的時候,我是抱著相當懷疑的態度的。沒想到鋼鐵人第一集還蠻好看的。沒有什麼很深的理念,就很單純的一部展示科技的商業片。而鋼鐵人2 似乎也是走著同樣的路線。
這部電影的節奏、劇情都還算拿捏得不錯,笑點也蠻多的,花了280去看也不會覺得有什麼不值得的地方,反正就是一部放鬆了去看看特效的影片。不過,看完了之後,我室友和我的感想差不多,都是覺得這部電影其實也沒有什麼主題可言。在那些還算精彩的戰鬥特效背後,感覺不出這部片想要表達的東西。如果是對劇情啦、電影中心的思想這些比較重視的話,我想就不需要特別去看這部片了(這個應該從第一部就很明顯了)。
不過,一部商業片基本該有的東西他似乎也都有了,華麗的特效、性感的正妹、緊湊的打鬥畫面、邪惡的反派人物、和一些明顯的丑角人物之類的,應有盡有,不排斥看商業片的人應該會覺得這電影還算是好看吧。

感想1: Samual Jackson 也太喜歡去客串演出了吧...
感想2: Scarlett Johansson 也太辣了吧
感想3: Lisa 你不要對感想2太在意啦 :p

2010年4月26日 星期一

KICK-ASS

oops... sorry for all caps...
This past sunday I went to Taipei. Went to chill with a friend and watched a movie.
Kick-Ass, is the title of the movie. Apparently it had been on theaters for over a week now, though I haven't been paying attention to movies lately. So, when my friend linked me the trailer of the movie, I decided that I'll actually go watch it in theaters.
Well, the trailer was interesting, and reading movie reviews before I actually see the movie is not something i do. So, I was actually quite surprised at the quality of this movie. It's... well not perfect, there are will some details and some cut scenes that deserve a little more improvement. But, overall, I think it's one of the best movies I've seen recently. The pace of the movie is pretty tight, leaving perhaps only minutes of the movie without some sort of action or purpose. The humor in the movie is pretty well delivered. To that, I have to say the the antagonist big boss of the movie is well portrayed. And the amount of parody in this film is quite worth noting. So yeah... to those of you who haven't seen it, go watch it asap!!

But be warned... There are some vivid display of blood and violence... and yes.. Hit-Girl is only twelve. I guess child labor laws do not apply to superhero works.