/* * The Npic library * * Copyright (C) 2003 Edouard Thiel * * This library is free software under the terms of the * GNU Lesser General Public License (LGPL) version 2.1. */ /* DO NOT EDIT !!! Generated by npic-templa from "image_check.ct" */ /* * image_check.c - 25/11/2008 * * Check images */ #include /*--------------------- P U B L I C - I N T E R F A C E ----------------------*/ /* * Check if image is not null, has correct type and is ok. * Return NPIC_SUCCESS, else print message and return error code. */ int NpicImageIsOK (Npic_image *np, const char *funcname) { if (np == NULL) return NpicError (funcname, NPIC_ERR_NULL_PTR, ""); if (np->type < NPIC_IMAGE_BB || np->type > NPIC_IMAGE_EE) return NpicError (funcname, NPIC_ERR_UNEX_TYPE, ""); if (np->gen.ok != NPIC_SUCCESS) return NpicError (funcname, NPIC_ERR_NOT_OK, ""); return NPIC_SUCCESS; } /* * Check if all images are ok ; set not ok for dest on error. * Return NPIC_SUCCESS, else print message and return error code. */ int NpicImageIsOK_DS1 (Npic_image *dest, Npic_image *src1, const char *funcname) { int k; k = NpicImageIsOK (dest, funcname); if (k != NPIC_SUCCESS) return k; k = NpicImageIsOK (src1, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; return NPIC_SUCCESS; } int NpicImageIsOK_DS2 (Npic_image *dest, Npic_image *src1, Npic_image *src2, const char *funcname) { int k; k = NpicImageIsOK (dest, funcname); if (k != NPIC_SUCCESS) return k; k = NpicImageIsOK (src1, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; k = NpicImageIsOK (src2, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; return NPIC_SUCCESS; } int NpicImageIsOK_DS3 (Npic_image *dest, Npic_image *src1, Npic_image *src2, Npic_image *src3, const char *funcname) { int k; k = NpicImageIsOK (dest, funcname); if (k != NPIC_SUCCESS) return k; k = NpicImageIsOK (src1, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; k = NpicImageIsOK (src2, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; k = NpicImageIsOK (src3, funcname); if (k != NPIC_SUCCESS) return dest->gen.ok = k; return NPIC_SUCCESS; } /* * Check if np1 is a square image. * return error code, set not ok. */ int NpicImageIsSquare (Npic_image *np1, const char *funcname) { int L, k; k = NpicImageIsOK (np1, funcname); if (k != NPIC_SUCCESS) return k; L = np1->gen.xmax; if ( np1->gen.ymax != L || (np1->gen.dim >= 3 && np1->gen.zmax != L) || (np1->gen.dim >= 4 && np1->gen.tmax != L) || (np1->gen.dim >= 5 && np1->gen.smax != L) || (np1->gen.dim >= 6 && np1->gen.rmax != L) ) return np1->gen.ok = NpicError (funcname, NPIC_ERROR, ": not a square image"); return NPIC_SUCCESS; } /* * Test if the two images have same type, dimension, size or border * (even if they are not ok). * "what" is a bitwise OR of NPIC_TYPE, NPIC_DIM, NPIC_SIZE, NPIC_BORD. * * Return NPIC_SUCCESS, else error code. Silent. */ int NpicSameImage (Npic_image *np1, Npic_image *np2, int what) { if (np1 == NULL || np2 == NULL) return NPIC_ERR_NULL_PTR; if (what & NPIC_TYPE && np1->type != np2->type) return NPIC_ERROR; if (what & NPIC_DIM && np1->gen.dim != np2->gen.dim) return NPIC_ERROR; if (what & NPIC_SIZE && ( np1->gen.rmax != np2->gen.rmax || np1->gen.smax != np2->gen.smax || np1->gen.tmax != np2->gen.tmax || np1->gen.zmax != np2->gen.zmax || np1->gen.ymax != np2->gen.ymax || np1->gen.xmax != np2->gen.xmax )) return NPIC_ERROR; if (what & NPIC_BORD && ( np1->gen.rbor != np2->gen.rbor || np1->gen.sbor != np2->gen.sbor || np1->gen.tbor != np2->gen.tbor || np1->gen.zbor != np2->gen.zbor || np1->gen.ybor != np2->gen.ybor || np1->gen.xbor != np2->gen.xbor )) return NPIC_ERROR; return NPIC_SUCCESS; } /*-------------------- P R I V A T E - F U N C T I O N S ---------------------*/ /*---------------------------------------------------------------------------*/