thumbnail.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: thumbnail.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-images is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #include <cassert>
00028 #include <iostream>
00029 
00030 #include <stdio.h>
00031 #include <string.h>
00032 #include <stdlib.h>
00033 #include <sys/time.h>
00034 #include <time.h>
00035 
00036 #include <gdk-pixbuf/gdk-pixbuf-transform.h>
00037 
00038 // This is a simple test unit 
00039 // to see time cosumption when get thumbnail image.
00040 // thumbnail /data/wa/uds/yehong/sample/images/1.JPG 200 300
00041 int main(int argc, char * argv[])
00042 {
00043     if (argc != 4)
00044     {
00045         return -1;
00046     }
00047     
00048     g_type_init();
00049 
00050     GdkPixbuf * loader = gdk_pixbuf_new_from_file(argv[1], 0);
00051     if (loader)
00052     {
00053         printf("Do Scaling...");
00054         struct timeval tv_start, tv_end;
00055 
00056         gettimeofday(&tv_start, NULL);
00057 
00058         int w = atoi(argv[2]);
00059         int h = atoi(argv[3]);
00060         GdkPixbuf * tmp = gdk_pixbuf_scale_simple(loader, w, h,
00061                                                   GDK_INTERP_NEAREST);
00062         if (tmp)
00063         {
00064             g_object_unref(tmp);
00065         }
00066 
00067         gettimeofday(&tv_end, NULL);
00068 
00069         printf("%ld \n", 
00070                 (tv_end.tv_sec - tv_start.tv_sec) * 1000000
00071               + (tv_end.tv_usec - tv_start.tv_usec));
00072 
00073         g_object_unref(loader);
00074     }
00075 
00076     return 0;
00077 }
00078 
00079 
Generated by  doxygen 1.6.2-20100208