2015年7月28日 星期二

[C#] Android, iOS App icon generator

When we develop Android or iOS App, we need to design the icon the our App as well.
The annoying problem is that we need to have different resolutions of icons.

There have many free website which can help to us to do that.
However, some websites need to have account to start generating.
Some websites may have slow response time.

So...I decide to write a program using C# for such purpose.
At the same time, I think that there may have many people have similar requirement like me.
I would like to share my program as below:

I suggest that you can design a icon with the resolution of 1024x1024.
That you can open it with generateAppIcon and generate files with different resolutions you need.


By the way, we often use rounded corner in our icon.
In Android, you can design your rounded corner.
The system will show the icon as you design.

However, in iOS, the system will generate the rounded corner itself.
The radius of rounded corner may change for different system version.
I would like to suggest that you can design a icon without rounded corner and let the system to generate the rounded corner itself.

[C#] Android, iOS App icon產生器

當我們開發Android,iOS的App時,需要製作App的icon,
比較麻煩是,我們需要不同解析度的icon,
網路上有許多免費的網站可以幫忙產生不同的解析度,
不過,有的網站需要申請帳號,
有的網站處理速度很慢,

所以,只好自己用C#寫一個來用,
我想可能很多人都有這樣的需求,
所以就分享出來,
下載網址如下:

建議先製作一個1024x1024大小的icon,
然後丟到generateAppIcon去產生不同的解析度,
Launch Images是app還沒開始前會先載入的畫面,
很多人會放公司的logo之類的,
它的大小最大是1242x2208, 1536x2048等等,
最好是製作一個高解析的圖當成原圖,

附帶一提,
很多App icon都會有圓角的設計,
Android,你可以設計自己想要的圓角,
它會按照你產生的icon來顯示,

iOS,系統會自己截取你的icon來產生圓角,
而且它的圓角也可能因為不同版本會改變,
除非你的icon和圓角半徑有關,
不然,建議你可以產生一個沒有圓角的icon,
讓系統自己來產生圓角

[C#] When we use PictureBox to load the picture file,the picture file will be locked?

We often use PictureBox to load the picture file, like below:
try
{
 var srcImage = Image.FromFile("test.jpg");
 myPictureBox.Image = srcImage;
}
catch (System.OutOfMemoryException)
{
 MessageBox.Show("Invalid picture format.");
}
However, you will find that you cannot move or rename this picture file.
That is this picture file is locked.

What if we wish that it will not be locked?
We can solve this problem be using FileStream, as below:
try
{
 FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open);
 var srcImage = Image.FromStream(stream);
 stream.Close();
 myPictureBox.Image = srcImage;
}
catch (System.ArgumentException)
{
 MessageBox.Show("Invalid picture format.");
}

[C#] 圖片檔案載入PictureBox 控制項時,影像檔案會被鎖住?

我們常常會利用PictureBox來載入影像檔案,
例如以下的用法:
try
{
 var srcImage = Image.FromFile("test.jpg");
 myPictureBox.Image = srcImage;
}
catch (System.OutOfMemoryException)
{
 MessageBox.Show("Invalid picture format.");
}
不過,你會發現此時你無法再對這個做移動或者更名等動作,
因為這個檔案已經被鎖住了,

如果我們不希望它被鎖住呢?
我們可以藉用FileStream來解決,如下:
try
{
 FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open);
 var srcImage = Image.FromStream(stream);
 stream.Close();
 myPictureBox.Image = srcImage;
}
catch (System.ArgumentException)
{
 MessageBox.Show("Invalid picture format.");
}