Leptonica 1.68
C Image Processing Library
|
00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 /* 00017 * scaletest1.c 00018 * 00019 * scaletest1 filein scalex scaley fileout 00020 * where 00021 * scalex, scaley are floating point input 00022 */ 00023 00024 #include "allheaders.h" 00025 00026 main(int argc, 00027 char **argv) 00028 { 00029 char *filein, *fileout; 00030 l_int32 d; 00031 l_float32 scalex, scaley; 00032 PIX *pixs, *pixd; 00033 static char mainName[] = "scaletest1"; 00034 00035 if (argc != 5) 00036 return ERROR_INT(" Syntax: scaletest1 filein scalex scaley fileout", 00037 mainName, 1); 00038 00039 filein = argv[1]; 00040 scalex = atof(argv[2]); 00041 scaley = atof(argv[3]); 00042 fileout = argv[4]; 00043 00044 if ((pixs = pixRead(filein)) == NULL) 00045 return ERROR_INT("pixs not made", mainName, 1); 00046 00047 /* choose type of scaling operation */ 00048 #if 1 00049 pixd = pixScale(pixs, scalex, scaley); 00050 #elif 0 00051 pixd = pixScaleLI(pixs, scalex, scaley); 00052 #elif 0 00053 pixd = pixScaleSmooth(pixs, scalex, scaley); 00054 #elif 0 00055 pixd = pixScaleAreaMap(pixs, scalex, scaley); 00056 #elif 0 00057 pixd = pixScaleBySampling(pixs, scalex, scaley); 00058 #else 00059 pixd = pixScaleToGray(pixs, scalex); 00060 #endif 00061 00062 d = pixGetDepth(pixd); 00063 00064 #if 1 00065 if (d <= 8) 00066 pixWrite(fileout, pixd, IFF_PNG); 00067 else 00068 pixWrite(fileout, pixd, IFF_JFIF_JPEG); 00069 #else 00070 pixWrite(fileout, pixd, IFF_PNG); 00071 #endif 00072 00073 pixDestroy(&pixs); 00074 pixDestroy(&pixd); 00075 return 0; 00076 } 00077