/* $Id: cpl_image_io-test.c,v 1.24 2007/11/13 13:13:02 llundin Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2004 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * $Author: llundin $ * $Date: 2007/11/13 13:13:02 $ * $Revision: 1.24 $ * $Name: $ */ /*----------------------------------------------------------------------------- Includes -----------------------------------------------------------------------------*/ #include #include "cpl_image_io.h" #include "cpl_image_gen.h" #include "cpl_image_bpm.h" #include "cpl_tools.h" #include "cpl_memory.h" /*----------------------------------------------------------------------------- Defines -----------------------------------------------------------------------------*/ #define IMAGESZ 512 #define MAGIC_PIXEL 42 /*----------------------------------------------------------------------------- Main -----------------------------------------------------------------------------*/ int main(void) { cpl_image * imf1 ; cpl_image * imf2 ; cpl_image * imd1 ; cpl_image * imd2 ; cpl_image * imi1 ; cpl_image * imi2 ; float * fbuf ; double * dbuf ; int * ibuf ; void * vbuf ; const int nbad = 5; int bad_pos_x[nbad]; int bad_pos_y[nbad]; int i; cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); /* Insert tests below */ /* First create cpl_image_test.fits */ cpl_msg_info(cpl_func,"Create cpl_image_test.fits on disk."); imd1 = cpl_image_fill_test_create(IMAGESZ, IMAGESZ); /* Must be positive */ cpl_image_add_scalar(imd1, 1.00) ; /* Normal image */ cpl_image_save(imd1, "cpl_image_test.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT); /* Append extension */ cpl_image_save(imd1, "cpl_image_test.fits", CPL_BPP_16_UNSIGNED, NULL, CPL_IO_EXTEND); /* Append NULL */ cpl_image_save(NULL, "cpl_image_test.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_EXTEND); /* Append extension */ cpl_image_save(imd1, "cpl_image_test.fits", CPL_BPP_16_SIGNED, NULL, CPL_IO_EXTEND); /* Append extension */ cpl_image_save(imd1, "cpl_image_test.fits", CPL_BPP_IEEE_DOUBLE, NULL, CPL_IO_EXTEND); /* Check */ cpl_assert (cpl_error_get_code() == CPL_ERROR_NONE) ; /* Check the image type size */ cpl_assert( cpl_type_get_sizeof(CPL_TYPE_DOUBLE) == (int)sizeof(double) ); /* Test cpl_image_get_data() */ cpl_assert( (vbuf=cpl_image_get_data(imd1)) ); /* Create a bad pixel map for this image */ bad_pos_x[0] = 20 ; bad_pos_y[0] = 30 ; bad_pos_x[1] = 200 ; bad_pos_y[1] = 100 ; bad_pos_x[2] = 300 ; bad_pos_y[2] = 200 ; bad_pos_x[3] = 301 ; bad_pos_y[3] = 200 ; bad_pos_x[4] = 100 ; bad_pos_y[4] = 220 ; for (i=0 ; i