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 * rasteropip_reg.c 00018 * 00019 * Tests in-place operation using the general 2-image pixRasterop(). 00020 * The in-place operation works because there is no overlap 00021 * between the src and dest rectangles. 00022 */ 00023 00024 #include <stdio.h> 00025 #include <stdlib.h> 00026 #include "allheaders.h" 00027 00028 00029 main(int argc, 00030 char **argv) 00031 { 00032 l_int32 i, j, equal; 00033 PIX *pixs, *pixt, *pixd; 00034 static char mainName[] = "rasteropip_reg"; 00035 00036 00037 pixs = pixRead("test8.jpg"); 00038 pixt = pixCopy(NULL, pixs); 00039 00040 /* Copy, in-place and one COLUMN at a time, from the right 00041 side to the left side. */ 00042 for (j = 0; j < 200; j++) 00043 pixRasterop(pixs, 20 + j, 20, 1, 250, PIX_SRC, pixs, 250 + j, 20); 00044 pixDisplay(pixs, 50, 50); 00045 00046 /* Copy, in-place and one ROW at a time, from the right 00047 side to the left side. */ 00048 for (i = 0; i < 250; i++) 00049 pixRasterop(pixt, 20, 20 + i, 200, 1, PIX_SRC, pixt, 250, 20 + i); 00050 pixDisplay(pixt, 620, 50); 00051 00052 /* Test */ 00053 pixEqual(pixs, pixt, &equal); 00054 if (equal) 00055 fprintf(stderr, "OK: images are the same\n"); 00056 else 00057 fprintf(stderr, "Error: images are different\n"); 00058 pixWrite("/tmp/junkpix.png", pixs, IFF_PNG); 00059 pixDestroy(&pixs); 00060 pixDestroy(&pixt); 00061 00062 00063 /* Show the mirrored border, which uses the general 00064 pixRasterop() on an image in-place. */ 00065 pixs = pixRead("test8.jpg"); 00066 pixt = pixRemoveBorder(pixs, 40); 00067 pixd = pixAddMirroredBorder(pixt, 25, 25, 25, 25); 00068 pixDisplay(pixd, 50, 550); 00069 pixDestroy(&pixs); 00070 pixDestroy(&pixt); 00071 pixDestroy(&pixd); 00072 00073 return 0; 00074 } 00075 00076