Serialize and deserialize BITMAP object in MFC/Win32

09/07/2009

Download the source code

Lately, in one of my project, I have to save an BITMAP object into an XML document. The problem is I can only save an CString into the XML document. So I have to find a way to convert BITMAP data (in a HBITMAP) into CString.

It’s pretty easy if I serialize the BITMAP to an byte[] array, and then convert the result byte[] array into CString format. So I will consequently discuss on these 2 problems.

Read the rest of this entry »


An CFG for Roman numerals

19/05/2009

In one of my assignments for Compiler course at my university, I have to deal with this problem: build an attributed grammar tree in order to recognize Roman numbers, and convert it into Arabic format. Well, it doesn’t seem a simple mission.

Read the rest of this entry »


Funny stuffs

25/11/2008

Đọc được mấy câu hay hay khi đang đi tìm tài liệu, không ghi lại thì thật là phí:

Programs must be written for people to read, and only incidentally for machines to execute.
(Abelson & Sussman, Structure and Interpretation of Computer Programs)

Easier to Ask Forgiveness than Permission

–> tròng vòng lặp, thay vì check bound thì cứ read đại rồi try catch (???)

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
(Brian W. Kernighan, cùng tác giả của The C Programming Language và là chữ “K” trong “AWK”)

Câu này nghe hay nhất :) )


CG_Thuật toán Quay lơ (Weiler)

08/10/2008

Bài tập môn CG của tớ, 2 ngày code cái này thật là… !%^&$#@@#$%&

Những kinh nghiệm rút ra như sau:

1/ Trừ khi bị ép buộc, ko cài những thứ gì liên quan tới con trỏ bằng C++ nữa! Cái cảm giác 1 object nhưng có tới 3-4 con trỏ trong mấy cái list thật là… >”< Cuối cùng thì tớ cứ viết ẩu, new ào ào mà chả thèm delete…. hix… Cảm thấy có lỗi với thầy Phương, thầy Khiết, thầy Thư… nhiều wá… :”>

2/ Tớ đã ngồi cài lại cái hàng đợi bằng dslk đôi. Ngu thế là cùng!

3/ Post lên đây chơi ha!

http://cid-75f5081ae5375f06.skydrive.live.com/self.aspx/Shared%20source%20code/0612578|_Weiler.rar