Friday, June 18, 2010

Build SDL Library for PellesC and Use it in SDL project

Download SDL source and SDL runtime library from SDL homepage.

Extract all header files in include folder from SDL source package into PellesC installation directory, include/sdl sub folder

Extract SDL.dll to PellesC installation folder, bin sub folder.
run command polib sdl.dll /OUT:sdl.lib to create the SDL.lib file
copy SDL.lib to PellesC installation folder, lib sub folder.

To Build Library:
  • Create Pelles C project, select "Win32 Static Library (.lib)" project type, project name set as "sdlmain"
  • Extract SDL_win32_main.c file from src/main/win32 directory, and add this file into the new project
  • Set the include directory to include include/sdl  directory.
  • Set compiler option: Go to Project->Project Options->Compiler and tick the box that says "Enable Microsoft Extensions" and set "Calling conv" to "__cdecl" in the drop down box.
  • Build library file
  • Copy the output file sdlmain.lib into PellesC installation directory, lib sub folder.

TO Use SDL Library In Project:
  • Create a Project
  • Create a new project (either a Win32 Console or Win32 Program).
  • Include sdl.h
  • Create your sdl program (i.e. write your source code), making sure that you #include <sdl.h>
  • Set Compiler Options
  • In Project->Project Options->Compiler, set the __cdecl calling convention from the drop down list. Also select the "Enable Microsoft extensions" option.
  • Set Linker Options
  • In Project->Project Options->Linker (if this doesn't show up you haven't created a project properly yet), add "sdl.lib" and "sdlmain.lib" (just write the filenames with a space separating them) to the list of "Library and object files".


Wednesday, June 2, 2010

(zz)『绝对收藏』你不可不知的12条经典摄影技巧——Photography Tips Top12

Open in new window摄影是一门技术,同样也是经验的积累。下面是无数摄影师的经验汇聚而成的12条最经典、实 用的摄影技巧Tips,将其熟记于心,将帮助你应对很多难以掌控的拍摄场景。

1.Sunny 16 Rule (阳光十六法则)
“Sunny 16 Rule”是在没有测光表时,正确估算日光下曝光数值的方法,所以这条法则只有在阳光充足的情况下适合使用。将光圈设为F/16,快门与ISO同步,或者 略快。如,ISO设为100时,快门应该设为1/100秒(1/125秒)。所以,根据这个法则,在海滩上摄影时,应该使用F/22光圈,在多云时应使用 F/11光圈。

2.Moony 11,8, and 5.6 Rules  (月光11,8和5.6法则)
如 果你想拍摄月亮,那么这里有一条很好的法则。快门与ISO同步的时候,拍摄满月用F/11光圈,弦月的时候用F/8光圈,新月则使用F/5.6光圈。

3.Camera Shake Rule  (相机抖动法则)
当你手持相机拍摄时,快门的速度不能小于镜头焦距的倒数。如果快门速度越慢,那么 拍摄抖动时就越可能降低锐度。如果用50mm焦距的话,快门就要达到1/60秒以上为宜,只有当环境实在昏暗时,用闪光灯、脚架或者把相机放在硬物上防止 抖动。

4.Anatomical Gray Card  (灰板法则)
随身携带18%的中灰 度板是拍摄的利器。可是如果身上没有灰度板怎么办呢?可以将手掌摊开面向阳光,对手掌进行测光,然后加一档曝光。 http://www.leica.org.cn/

5.Depth of Field Rules  (景深法则)
当被摄无题比较深的时候,应该对焦点选择在景深的前1/3处,因为这样,对焦 点后的景深是之前的2倍。各种光圈和焦段组合都可以使用这个法则。记住,光圈越小,焦距越短,距离被摄物体越远,景深就越大。

6.Largest Digital Print Rule  (数码冲印尺寸法则)
如果你想把你的作品打印成大尺寸的照片时,照片的尺寸不能大 于数码图片的长宽像素各除以200.如果你对作品要求很高,那么至少得除以250。

7.Exposure Rules (曝光法则)
在处理数码照片时,最普遍的法则是保证高光区曝光准确,低光区随他去。可是当处理负片,特别是彩色负片的时候,你 最好增曝一档。http://www.leica.org.cn/

8.Quick Flash-fill Rule  (快速闪光输出法则)
当你的相机不能自动输出控制的闪光灯时,将闪光灯的感光度设为胶卷 的二被。如果对主体测光,机身选择光圈整档,闪光灯设为同样的光圈。这样,照片的阴影区会比主体的亮度低一档。

9.Flash Range Rule (闪光距离法则)
这个法则很简单:距离乘以2,感光度乘以4。例如,你的闪光灯在ISO 100时,有效距离为20英尺。如果你想使闪光灯的距离达到40英尺时,则需要ISO 400。

10.Megapixel Multiplier Rule (像素翻倍法则)
如果你想使数码相机的分辨率增倍,那么很简单,就是要像素翻两番。

11.Action-stopping Rule (捕捉动态法则)
这条法则是根据角度与速度的经验公式而来的。如果物体沿着镜头的轴线运动你能够用1/125的快 门捕捉下,那么它追至于镜头轴线的运动能用1/500捕捉下来。也就是说,如果物体沿镜头轴线称45度运动,只需要1/250的快门速度。

12.Sunset Rule  (日落法则)
拍摄落日时,要对落日上部测光,但是不能让太阳出现在你的取景器中。如果想让日落看上去比实际晚一 小时,可以在曝光补偿中减1。

Tuesday, March 23, 2010

Python真的是一个不错的语言

没有系统的学习Python,因为网友都说Python很不错,所以决定用Python来做几个小东西,做下来发现Python真的很不错。
  • 代码简洁,清晰
  • 丰富的库支持
因为发现到它的好处,所以这次学校的一个project因为要在PC上跑一些GUI程序来连接目标板,就选择Python+wxPython来,再加上wxGlade的帮忙,软件可以很快就构建完成。

到现在用Python做的几个小东西:
  1. 因为公司的电脑慢,不想跑很费内存的Realview Development Suite, 就写了一个读Realview Development Suite 的.cproject文件的程序,用来生成CMake用的CMakeLists文件,然后用CMake来生产makefile。
  2. 因为找不到免费使用的下载股票EOD数据的软件,就自己写了一个GUI程序来下载SGX的EOD数据。数据是从Yahoo Finance下载的。GUI的库用的是wxPython
  3. 学校的project,一个PC端运行的GUI,根据用户不同的设置,通过Serial发数据到目标板上
  4. 学校的project,一个PC端运行的GUI,通过网络拿目标板的数据,然后根据这些数据更新GUI上显示的信息

推荐一个 代码托管的地方

做学校的project,因为有5个人一起做,每个人做不同的部分,不想每次通过email来共享代码。就想到有没有免费的代码托管的地方,最后还真的给我找到一个不错的。bitbucket.org, 这个和sourceforge与google code的区别是这个有提供一个private的仓库,这一点对我最有吸引力。免费账户有1G的空间,足够我们所有的学校project了。

bitbuckt还有提供issue tracker和wiki,所以是很不错的一个免费代码托管服务。

Friday, February 12, 2010

推荐的一款超赞的原型设计工具-Balsamiq Mockups

最近做一个project需要设计GUI,为了在组里面讨论的时候有比较直观的演示,要找一个做界面原型的软件。上网google了一下,发现很多人头推荐“Balsamiq Mockups”,而它的设计风格也的确是让我让我眼前一亮!迫不急待,进行了一翻在线试用,真的是很赞。

=====================================================================
以下内容为转帖
=====================================================================


网址:http://www.balsamiq.com/

在线演示地址:http://www.balsamiq.com/products/mockups

试用网址:http://www.balsamiq.com/demos/mockups/Mockups.html

整体截图:


功能和亮点:

   1. 操作方面:拖拽,控件分组,甚至元素之间的对齐都做得很到位;
   2. 预制了六十多个界面元素,从简单的输入框,下拉框,到经常用得到的导航条,日历,表格,到复杂的Tag Cloud,Cover Flow, 地图,WYSWYG的格式工具栏等,有了这些不用从头画起,其实比用白板都快;
   3. 界面元素的修改很简单,比如导航条的几个标签页的label,就是用逗号分隔的文字,下拉框的选项就是分行的文字;
   4. 使用xml语言来记录和保存界面元素和布局,从而使其能够快速的导入到你所需的任何一个项目中,或其他工具中。
   5. 可以将设计导出成PNG格式的图片;
   6. 随着使用的熟练,快捷键便派上用场,超过一半的元素均有快捷方式,这更有助于原型的快速构造,几乎几分钟便可实现一个满意的而复杂的原型设计;
   7. 跨平台,Balsamiq Mokups是用Flex和Air实现的,所以在Mac OS, Linux和Windows下都能使用;
   8. 不仅仅有桌面版本,还有能集成在Confluence,JIRA,和XWiki中的版本,使得异地在线协作更方便有效;







可惜这么好的软件不是免费的,价格还不便宜,要79美刀。非注册版本不能保存和导出为图片,而且还会不定时的跳出提示框。不过作者算是比较大方的,主页上有提到了多种免费获取 key 的方法,其一就是写一篇 blog 推荐这款软件。嘿嘿,终于暴露目的了…… 不过这么好的软件,不推荐一下也实在说不过去。

Tuesday, February 9, 2010

Recover from a frozen system with the magic SysRq key (zz)

What is The magic SysRq key ?

The magic SysRq is a key combination understood by the Linux kernel, which allows the user to perform various low level commands regardless of the system's state. It is often used to recover from freezes, or to reboot a computer without corrupting the filesystem.
 
How to use the magic SysRq to recover from a frozen system ?

If you see that using Ctrl+Alt+Backspace does nothing, then is the time to use The magic SysRq key.

1. Hold down the Alt and SysRq (Print Screen) keys.
2. While holding those down, type the following in order. Nothing will appear to happen until the last letter is pressed: REISUB
3. Watch your computer reboot magically.

To remember the word REISUB the mnemonic is "Raising Elephants Is So Utterly Boring", "Reboot Even If System Utterly Broken" or simply remembering the word "BUSIER" .

The magic SysRq to recover is advised to be used for emergencies only, for example when the system absolutely locks up and freeze This is not to be used on potentially still busy machines which are still writing stuff to disk for example or on machines that could still do a proper shutdown if you only were patient enough to wait. This is only for systems which have already died a horrible death.
 
Activate The magic SysRq key in Ubuntu/Debian/CentOS/RHEL/Fedora
If you are using Ubuntu,Debian you can not use The magic SysRq key because it is desactivated by default.
If you want to activate it, you have to edit the file /etc/sysctl.conf :

vi /etc/sysctl.conf
and then add this line :
kernel.sysrq = 1

save and close

 If you are using Fedora /CentOS/ Redhat, edit the file /etc/sysctl.config and change the value of kernel.sysrq to 1
# Controls the System Request debugging functionality of the kernel
# kernel.sysrq = 1

and is done.