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 * graphicstest.c 00018 * 00019 */ 00020 00021 #include "allheaders.h" 00022 00023 main(int argc, 00024 char **argv) 00025 { 00026 char *filein, *fileout; 00027 l_int32 d; 00028 BOX *box1, *box2, *box3, *box4; 00029 BOXA *boxa; 00030 PIX *pixs, *pixt1, *pixt2, *pixt3; 00031 PTA *pta; 00032 static char mainName[] = "graphicstest"; 00033 00034 if (argc != 3) 00035 exit(ERROR_INT(" Syntax: graphicstest filein fileout", mainName, 1)); 00036 00037 filein = argv[1]; 00038 fileout = argv[2]; 00039 if ((pixs = pixRead(filein)) == NULL) 00040 exit(ERROR_INT(" Syntax: pixs not made", mainName, 1)); 00041 d = pixGetDepth(pixs); 00042 if (d <= 8) 00043 pixt1 = pixConvertTo32(pixs); 00044 else 00045 pixt1 = pixClone(pixs); 00046 00047 /* Paint on RGB */ 00048 pixRenderLineArb(pixt1, 450, 20, 850, 320, 5, 200, 50, 125); 00049 pixRenderLineArb(pixt1, 30, 40, 440, 40, 5, 100, 200, 25); 00050 pixRenderLineBlend(pixt1, 30, 60, 440, 70, 5, 115, 200, 120, 0.3); 00051 pixRenderLineBlend(pixt1, 30, 600, 440, 670, 9, 215, 115, 30, 0.5); 00052 pixRenderLineBlend(pixt1, 130, 700, 540, 770, 9, 255, 255, 250, 0.4); 00053 pixRenderLineBlend(pixt1, 130, 800, 540, 870, 9, 0, 0, 0, 0.4); 00054 box1 = boxCreate(70, 80, 300, 245); 00055 box2 = boxCreate(470, 180, 150, 205); 00056 box3 = boxCreate(520, 220, 160, 220); 00057 box4 = boxCreate(570, 260, 160, 220); 00058 boxa = boxaCreate(3); 00059 boxaAddBox(boxa, box2, L_INSERT); 00060 boxaAddBox(boxa, box3, L_INSERT); 00061 boxaAddBox(boxa, box4, L_INSERT); 00062 pixRenderBoxArb(pixt1, box1, 3, 200, 200, 25); 00063 pixRenderBoxaBlend(pixt1, boxa, 17, 200, 200, 25, 0.4, 1); 00064 pta = ptaCreate(5); 00065 ptaAddPt(pta, 250, 300); 00066 ptaAddPt(pta, 350, 450); 00067 ptaAddPt(pta, 400, 600); 00068 ptaAddPt(pta, 212, 512); 00069 ptaAddPt(pta, 180, 375); 00070 pixRenderPolylineBlend(pixt1, pta, 17, 25, 200, 200, 0.5, 1, 1); 00071 pixWrite(fileout, pixt1, IFF_JFIF_JPEG); 00072 pixDisplay(pixt1, 200, 200); 00073 00074 pixDestroy(&pixs); 00075 pixDestroy(&pixt1); 00076 boxDestroy(&box1); 00077 boxaDestroy(&boxa); 00078 ptaDestroy(&pta); 00079 pixDestroy(&pixs); 00080 return 0; 00081 } 00082 00083