Time flies, I am half way through my 12 weeks internship. I started my week by looking back at my first task which is the email template. After showing Dr Shawn what I have done last week, he told me that I have to modify the code so that there is no hard coding. Besides, he wanted to add some new information in the email content which are the type of competition and venue. Last week, I was struggling to get the new information from the database. I then approached my colleague Wen Yan to ask for some help. After explaining to him what my problem was, he told me that to access a certain table in the database, we must have a pointer linking to that table. After looking at the code, we realized that the function we are calling to generate the email content does have the pointer pointing to the table we want. Therefore, what I have to do was using the pointer to get the information I needed. I am very thankful to Wen Yan, he saved my day. After I was able to get the information from the database, I then added in the new place holders in the email template file and also the code to bind the new information into the place holders. Finally, my first task was done!

I moved on to my second task which is to generate the registration slip by using WTemplate. Now I am pretty familiar with the application and also how WTemplate works, therefore I have a very clear idea on what I should do. After looking into the original code, I have decided to remove some of the functions that were used previously to generate the registration slip. After removing the codes that I do not need, I started writing the new codes to generate the registration slip using WTemplate. With Dr Shawn’s word in mind, I tried to avoid hard coding inside my code and write it as general as possible, so that the codes will be easier to maintain. After writing the code, it was time to test whether it works! Thankfully, the code passed the test script. So, second task checked! It was a productive week as I have done the first two tasks given to me.

Now, I am moving into my third task. Which is to include a QR code inside the registration slip. The information in the QR code is going to be the registration ID. Again, new thing to learn! Dr Shawn told me that I can use “libqrencode” to generate the QR code symbol and then use “png++” to generate a PNG image of the QR code. I started by looking into the documentation of “libqrencode”. Basically,  what it does is generating the QR code symbol data but not the PNG image. Therefore, I have to use “png++” (a c++ wrapper for libpng library) to draw the PNG image of the QR code using the data generated by “libqrencode”. It sound complicated to me but yeah, it would be amazing if I can produce the QR code with few lines of code. With the online documentation, I am able to produce the QR code symbol data. Here comes the hard part, I have to produce the QR code image in PNG format. Since png++ is just a c++ wrapper for the libpng library, I couldn’t find any example of producing QR code image using it. The example that I found used libpng to generate the QR code and it was written in C language. I tried to follow the example and it did give me a QR code in PNG format. However, when I tried to include the QR code in the registration slip, the image just broke. I don’t know what happened and Dr Shawn told me that the reason might be something related to the PNG format. Forget about libpng, Dr Shawn asked me to use “png++” instead. I then wrote some code to draw the QR code using “png++”. I did manage to produce the QR code image but it was so small (25 x 25 pixels). Actually the width of the QR code is related to the version of it, and I am thinking whether it is possible to generate a larger QR code image using the same version. Honestly, I am a little confused between “libpng” and “png++” now. Most of the information I got from the internet was all using C language and “libpng”, but the image just broke when I tried to add it in the slip. So, what I am going to do next week is start from the basic. I have to really understand how the library works and figure out a way to do it my way. Let’s get the third task done!


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.