1e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen/* 2e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * Copyright (C) 2011 The Android Open Source Project 3e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * 4e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * Licensed under the Apache License, Version 2.0 (the "License"); 5e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * you may not use this file except in compliance with the License. 6e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * You may obtain a copy of the License at 7e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * 8e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * http://www.apache.org/licenses/LICENSE-2.0 9e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * 10e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * Unless required by applicable law or agreed to in writing, software 11e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * distributed under the License is distributed on an "AS IS" BASIS, 12e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * See the License for the specific language governing permissions and 14e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen * limitations under the License. 15e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen */ 16e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 17e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen// Pyramid.h 18e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 19e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen#ifndef PYRAMID_H 20e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen#define PYRAMID_H 21e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 22e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen#include "ImageUtils.h" 23e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 24e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chentypedef unsigned short int real; 25e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 26e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen// Structure containing a packed pyramid of type ImageTypeShort. Used for pyramid 27e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen// blending, among other things. 28e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 29e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chenclass PyramidShort 30e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen{ 31e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 32e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chenpublic: 33e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 34e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen ImageTypeShort *ptr; // Pointer containing the image 35e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen real width, height; // Width and height of input images 36e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen real numChannels; // Number of channels in input images 37e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen real border; // border size 38e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen real pitch; // Pitch. Used for moving through image efficiently. 39e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 40e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static PyramidShort *allocatePyramidPacked(real width, real height, real levels, real border = 0); 41e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static PyramidShort *allocateImage(real width, real height, real border); 42e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static void createPyramid(ImageType image, PyramidShort *pyramid, int last = 3 ); 43e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static void freeImage(PyramidShort *image); 44e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 45e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static unsigned int calcStorage(real width, real height, real border2, int levels, int *lines); 46e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 47e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static void BorderSpread(PyramidShort *pyr, int left, int right, int top, int bot); 48e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static void BorderExpandOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr, int mode); 49e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static int BorderExpand(PyramidShort *pyr, int nlev, int mode); 50e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static int BorderReduce(PyramidShort *pyr, int nlev); 51e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen static void BorderReduceOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr); 52e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen}; 53e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen 54e295e32b68cf04f0d99138bf4a6d25555f3aef99Wei-Ta Chen#endif 55