Gamedev Geeks....

only geeks allowed :P...
See also: Other Geeks@INDC

April 2008 - Posts

Thank You Everyone!! (on Behalf of Antarmuka Team - Butterfly Project)

Well, I'm very sorry for this very late post.. I think I spend too much time sleeping lately (got fever lately.. side effects of 3 weeks non-stop working..)
In this oppurtunity I (on behalf of Team Antarmuka) want to say thank you very much, especially for (random order..):
- Pak Dwi (as our mentor he did the best for us)
- Pak Iping (thanks for the notebook that we borrowed at Regional Final)
- Bung Naren (he gives us many support, suggestion, and also we borrowed his 3G Modem and notebook at Regional Final)
- Bung Zeddy & Bung Umar (they did a great job in the imagine cup this year, I think it's the best ever, thank you very much)
- All the Judges - Mr.Risman, Mr. Norman, Mr. Rene, Mr. Tahir (thanks for choosing us, we will give our best in the world finals..)
- Octa cs (From the beginning we asked their help so much, thank you for everything..)
- Kak Igor (we borrowed his PDA for about a week... Thank you very much)
- Khoirush (we borrowed his 3G also for the Regional Final)
- Omnya Ella - Pak Direkta (Thank for borrowing us notebook :D)
- Fajar (we held captive this guy to help us set up our hardware >:D, thank you very much bro..)
- Ronald (our Boss @MIC ITB, which very willingly to accompany us on every step we made, we also borrowed MIC for about 3 weeks XD)
- MIC Crews (thank you for your continous support, and also special thanks to our lead safety division, Heryanto Totot :D)
- Temen2 IF (we don't know we will make it or not without your support to our team.. thanks everyone..)
- Dosen2 IF (please forgive us for not attending college for about three weeks XD..)
- Supporter team (especially to Mbak Desy who coordinates all the supporters)
- Kementrian Lingkungan Hidup (thank for the cooperation with our team)
- WALHI (thank for your support and time for us from the very begining)
And also many more that we can't describe one by one here.. Thank you very much everyone...

Share this post: | | | |
What is Butterfly Project actually? (Team Antarmuka - Imagine Cup 2008)

[english version]
Butterfly is an integrated system for reporting, documentation, and publication of environmental problems. Butterfly can receive a report from public through sms, phone calls, Butterfly website, and Butterfly mobile application. After Butterfly receives a report, it will classify the problem according to the category and priority through report keyword analysis. Therefore, a report would have a priority value and category, which determine where it would be sent. After that, the report would be forwarded to the proper authority that can handle the problem. The authority has to decide what to do with the report, whether it would be processed, postponed, or ignored. Whatever he decides, he has to put a reason why he decides that. The report then would be published on the Internet through Butterfly website, so the society can see the environmental that is currently happening, and how the responsible authority handles it.

[indonesian version]
Butterfly adalah sistem terintegrasi yang berfungsi menerima, mendokumentasikan, dan menampilkan laporan mengenai masalah lingkungan. Butterfly dapat menerima laporan dari masyarakat melalui sms, telepon, website, maupun aplikasi mobile yang diinstal di PDA. Setelah laporan diterima, Butterfly akan menentukan kategori dan prioritas masalah melalui analisis kata kunci yang terdapat pada laporan. Dengan demikian, sebuah laporan akan memiliki nilai prioritas dan kategori jenis laporan, yang menentukan ke mana laporan tersebut akan sampaikan. Setelah itu, laporan akan disampaikan ke pihak yang berwenang dalam menangani masalah yang dilaporkan. Pihak penerima laporan harus memutuskan penanganan terhadap laporan tersebut, apakah segera diproses, ditunda, atau diabaikan. Apapun penanganan yang dilakukan, pihak penerima harus memberikan alasan pilihannya. Laporan yang telah diproses akan ditampilkan di internet, sehingga masyarakat dapat mengetahui masalah lingkungan yang terjadi beserta penanganan yang telah dilakukan oleh pihak yang bertanggung jawab.

Share this post: | | | |
Resize Bitmap Tutorial in .NET CF

As we know, .NET CF doesn't have standard routine to resize Bitmap (Don't know why...). I'm looking for a tutorial online, but it seems noone already wrote this. So I decide to do it by myself (that's why I wrote this post in English. I hope I can help everyone in need). Actually I need this code for my Butterfly Project (Imagine Cup 2008 - Software Design)

Well, let's get started..

The basic (and silly) idea of resizing image is by mapping pixel one by one based on the width and height ratio. So if we defined originalBitmap is a Bitmap file referencing to the original bitmap to be resized, and resultBitmap is a Bitmap reference where we should write it, the code should look like this: (assuming resultBitmap already referenced to an instance with a defined width and height)


for (int y = 0; y < resultBitmap.Height; ++y) {
   for (int x = 0; x < resultBitmap.Width; ++x) {
      resultBitmap.SetPixel(x, y, originalBitmap.GetPixel( (int)Math.Round(x * originalBitmap.Width / resultBitmap.Width), (int)Math.Round(y * originalBitmap.Height / resultBitmap.Height) ));
   } 


But we should forget the above code as soon as possible. We mustn't implement those kind of code. It looks like O(n*m) with n = height and m = width, but let's see... In every loop pass it calls SetPixel and GetPixel which will iterate the bitmap to get the pixel value we need (this was done every pass), and also there are many redundant value which is can be pre-computed to increase effectivity. Let's assume a setPixel and GetPixel pass consume O(n*m) too so the total will be O(n^3 * m^3).... -______- (it still use so many mathematical function inside..)

To decrease any redundant value, let's just use a temporary variable which stores the precomputed value (and also do this also for class parameter that was accessed badly every loop pass. It will be much efficient fecthing a value from stack than from calling an method.. Properties is a method too.) 

And for the SetPixel and GetPixel issue, I think we should go back using the traditional way, POINTER :D (I don't know why but I love pointer :P). Before we start using pointer in C# we should use unsafe tag in code containing the pointer and then use /unsafe when building or check the unsafe build in build properties when using visual studio.

The Final Code should looks like this:


public static void ResizeImage(Bitmap originalBitmap, Bitmap resultBitmap) {
    int newWidth = resultBitmap.Width;
    int newHeight = resultBitmap.Height;
    int originalWidth = originalBitmap.Width;
    int originalHeight = originalBitmap.Height;

    BitmapData originalData = originalBitmap.LockBits(
        new Rectangle(0, 0, originalWidth, originalHeight),
        ImageLockMode.ReadOnly,
        PixelFormat.Format32bppRgb);
    BitmapData resultData = resultBitmap.LockBits(
        new Rectangle(0, 0, resultBitmap.Width, resultBitmap.Height),
        ImageLockMode.WriteOnly,
        PixelFormat.Format32bppRgb);

    double xFactor = originalWidth / newWidth;
    double yFactor = originalHeight / newHeight * originalWidth;

    unsafe
    {
        int* originalPointer = (int*)originalData.Scan0.ToPointer();
        int* resultPointer = (int*)resultData.Scan0.ToPointer();

        for (int y = 0; y < newHeight; ++y) {
            for (int x =0; x < newWidth; ++x) {
                int sourcePosition = (int)(Math.Round(x * xFactor) + Math.Round(y * yFactor));
                int destinationPosition = (x + y * newWidth);
                resultPointer[destinationPosition] =
                    originalPointer[sourcePosition];
            }
        }
        originalBitmap.UnlockBits(originalData);
        resultBitmap.UnlockBits(resultData);
    }
}


Well, I don't think this was the optimal code.But I think I don't have any time to develop it further (its 6 AM... limit of zombie skills.. time to have 2-3 hours of sleep). Besides I think I'm a bit lazy to deploy this code to PDA (Thanks for Igor IF2004 for borrowing me the PDA..) every time I want to debug it.. So I hope all of you can improve this silly code :P. Let's see... Look at the line contain "int destinationPosition = (x + y * newWidth);". Do you think it's neccessary? We could just use a temp variable to contain the value and increase the value every pass, OR we could just increase the pointer every pass (its very efficient) :D. 

Thanks for reading :D :D :D 

P.S. Just Curious, Is there any tag to post code? like <code> in phpBB? 

Share this post: | | | |