MagickCore  6.7.5
resample-private.h
Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004 
00005   You may not use this file except in compliance with the License.
00006   obtain a copy of the License at
00007 
00008     http://www.imagemagick.org/script/license.php
00009 
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore image resampling private methods.
00017 */
00018 #ifndef _MAGICKCORE_RESAMPLE_PRIVATE_H
00019 #define _MAGICKCORE_RESAMPLE_PRIVATE_H
00020 
00021 #if defined(__cplusplus) || defined(c_plusplus)
00022 extern "C" {
00023 #endif
00024 
00025 #include "MagickCore/thread-private.h"
00026 
00027 static inline ResampleFilter **DestroyResampleFilterThreadSet(
00028   ResampleFilter **filter)
00029 {
00030   register ssize_t
00031     i;
00032 
00033   assert(filter != (ResampleFilter **) NULL);
00034   for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
00035     if (filter[i] != (ResampleFilter *) NULL)
00036       filter[i]=DestroyResampleFilter(filter[i]);
00037   filter=(ResampleFilter **) RelinquishMagickMemory(filter);
00038   return(filter);
00039 }
00040 
00041 static inline ResampleFilter **AcquireResampleFilterThreadSet(
00042   const Image *image,const VirtualPixelMethod method,
00043   const MagickBooleanType interpolate,ExceptionInfo *exception)
00044 {
00045   register ssize_t
00046     i;
00047 
00048   ResampleFilter
00049     **filter;
00050 
00051   size_t
00052     number_threads;
00053 
00054   number_threads=GetOpenMPMaximumThreads();
00055   filter=(ResampleFilter **) AcquireQuantumMemory(number_threads,
00056     sizeof(*filter));
00057   if (filter == (ResampleFilter **) NULL)
00058     return((ResampleFilter **) NULL);
00059   (void) ResetMagickMemory(filter,0,number_threads*sizeof(*filter));
00060   for (i=0; i < (ssize_t) number_threads; i++)
00061   {
00062     filter[i]=AcquireResampleFilter(image,exception);
00063     if (filter[i] == (ResampleFilter *) NULL)
00064       return(DestroyResampleFilterThreadSet(filter));
00065     if (method != UndefinedVirtualPixelMethod)
00066       (void) SetResampleFilterVirtualPixelMethod(filter[i],method);
00067     if (interpolate != MagickFalse)
00068       SetResampleFilter(filter[i],PointFilter,1.0);
00069   }
00070   return(filter);
00071 }
00072 
00073 #if defined(__cplusplus) || defined(c_plusplus)
00074 }
00075 #endif
00076 
00077 #endif