Leptonica 1.68
C Image Processing Library

pixaatest.c

Go to the documentation of this file.
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  *   pixaatest.c
00018  *
00019  *     Syntax:  pixaatest
00020  */
00021 
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include "allheaders.h"
00025 
00026 static const l_int32  nx = 10;
00027 static const l_int32  ny = 10;
00028 static const l_int32  ncols = 3;
00029 
00030 main(int    argc,
00031      char **argv)
00032 {
00033 l_int32      w, d, tilewidth;
00034 PIX         *pixs;
00035 PIXA        *pixa, *pixad1, *pixad2;
00036 PIXAA       *pixaa1, *pixaa2;
00037 static char  mainName[] = "pixaatest";
00038 
00039     if (argc != 1)
00040         exit(ERROR_INT(" Syntax: pixaatest", mainName, 1));
00041 
00042         /* Read in file; generate tiled pixaa; write pixaa to file */
00043     pixs = pixRead("test24.jpg");
00044     pixGetDimensions(pixs, &w, NULL, &d);
00045     tilewidth = w / nx;
00046     pixa = pixaSplitPix(pixs, nx, ny, 0, 0);
00047     pixaa1 = pixaaCreateFromPixa(pixa, nx, L_CHOOSE_CONSECUTIVE, L_CLONE);
00048     pixaa2 = pixaaCreateFromPixa(pixa, nx, L_CHOOSE_SKIP_BY, L_CLONE);
00049     pixaaWrite("/tmp/junkpixaa1", pixaa1);
00050     pixaaWrite("/tmp/junkpixaa2", pixaa2);
00051     pixaDestroy(&pixa);
00052     pixaaDestroy(&pixaa1);
00053     pixaaDestroy(&pixaa2);
00054 
00055         /* Read pixaa from file; tile/scale; write result; convert to PS */
00056     pixaa1 = pixaaRead("/tmp/junkpixaa1");
00057     pixaa2 = pixaaRead("/tmp/junkpixaa2");
00058     pixad1 = pixaaDisplayTiledAndScaled(pixaa1, d, tilewidth, ncols, 0, 10, 0);
00059     pixad2 = pixaaDisplayTiledAndScaled(pixaa2, d, tilewidth, ncols, 0, 10, 0);
00060     pixaWriteFiles("/tmp/junksplit1.", pixad1, IFF_JFIF_JPEG);
00061     pixaWriteFiles("/tmp/junksplit2.", pixad2, IFF_JFIF_JPEG);
00062     convertFilesToPS("/tmp", "junksplit1", 40, "/tmp/junkout1.ps");
00063     convertFilesToPS("/tmp", "junksplit2", 40, "/tmp/junkout2.ps");
00064     pixDestroy(&pixs);
00065     pixaaDestroy(&pixaa1);
00066     pixaaDestroy(&pixaa2);
00067     pixaDestroy(&pixad1);
00068     pixaDestroy(&pixad2);
00069     return 0;
00070 }
00071 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines