Path: blob/master/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h
41149 views
/*1* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526#ifndef MLIB_IMAGECHECK_H27#define MLIB_IMAGECHECK_H2829#include <stdlib.h>30#include <mlib_image.h>3132#ifdef __cplusplus33extern "C" {34#endif3536/***************************************************************/3738#define MLIB_IMAGE_CHECK(image) \39if (image == NULL) return MLIB_NULLPOINTER4041#define MLIB_IMAGE_SIZE_EQUAL(image1,image2) \42if (mlib_ImageGetWidth(image1) != mlib_ImageGetWidth(image2) || \43mlib_ImageGetHeight(image1) != mlib_ImageGetHeight(image2)) \44return MLIB_FAILURE4546#define MLIB_IMAGE_TYPE_EQUAL(image1,image2) \47if (mlib_ImageGetType(image1) != mlib_ImageGetType(image2)) \48return MLIB_FAILURE4950#define MLIB_IMAGE_CHAN_EQUAL(image1,image2) \51if (mlib_ImageGetChannels(image1) != mlib_ImageGetChannels(image2)) \52return MLIB_FAILURE5354#define MLIB_IMAGE_FULL_EQUAL(image1,image2) \55MLIB_IMAGE_SIZE_EQUAL(image1,image2); \56MLIB_IMAGE_TYPE_EQUAL(image1,image2); \57MLIB_IMAGE_CHAN_EQUAL(image1,image2)5859#define MLIB_IMAGE_HAVE_TYPE(image, type) \60if (mlib_ImageGetType(image) != type) \61return MLIB_FAILURE6263#define MLIB_IMAGE_HAVE_CHAN(image, channels) \64if (mlib_ImageGetChannels(image) != channels) \65return MLIB_FAILURE6667#define MLIB_IMAGE_HAVE_3_OR_4_CHAN(image) \68if (mlib_ImageGetChannels(image) != 3 && \69mlib_ImageGetChannels(image) != 4) \70return MLIB_FAILURE7172#define MLIB_IMAGE_CHAN_SRC1_OR_EQ(src, dst) \73if (mlib_ImageGetChannels(src) != 1) { \74if (mlib_ImageGetChannels(src) != mlib_ImageGetChannels(dst)) \75return MLIB_FAILURE; \76}7778#define MLIB_IMAGE_TYPE_DSTBIT_OR_EQ(src, dst) \79if ((mlib_ImageGetType(src) != mlib_ImageGetType(dst)) && \80(mlib_ImageGetType(dst) != MLIB_BIT)) { \81return MLIB_FAILURE; \82}8384#define MLIB_IMAGE_GET_ALL_PARAMS(image, type, nchan, width, height, stride, pdata) \85type = mlib_ImageGetType(image); \86nchan = mlib_ImageGetChannels(image); \87width = mlib_ImageGetWidth(image); \88height = mlib_ImageGetHeight(image); \89stride = mlib_ImageGetStride(image); \90pdata = (void*)mlib_ImageGetData(image)9192/***************************************************************/9394#ifdef __cplusplus95}96#endif97#endif /* MLIB_IMAGECHECK_H */9899100