MagickCore  7.1.0
Convert, Edit, Or Compose Bitmap Images
resample-private.h
1 /*
2  Copyright @ 2007 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore image resampling private methods.
17 */
18 #ifndef MAGICKCORE_RESAMPLE_PRIVATE_H
19 #define MAGICKCORE_RESAMPLE_PRIVATE_H
20 
21 #include "MagickCore/thread-private.h"
22 
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26 
27 static inline ResampleFilter **DestroyResampleFilterTLS(ResampleFilter **filter)
28 {
29  ssize_t
30  i;
31 
32  assert(filter != (ResampleFilter **) NULL);
33  for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
34  if (filter[i] != (ResampleFilter *) NULL)
35  filter[i]=DestroyResampleFilter(filter[i]);
36  filter=(ResampleFilter **) RelinquishMagickMemory(filter);
37  return(filter);
38 }
39 
40 static inline ResampleFilter **AcquireResampleFilterTLS(const Image *image,
41  const VirtualPixelMethod method,const MagickBooleanType interpolate,
42  ExceptionInfo *exception)
43 {
44  ssize_t
45  i;
46 
48  **filter;
49 
50  size_t
51  number_threads;
52 
53  number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
54  filter=(ResampleFilter **) AcquireQuantumMemory(number_threads,
55  sizeof(*filter));
56  if (filter == (ResampleFilter **) NULL)
57  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
58  (void) memset(filter,0,number_threads*sizeof(*filter));
59  for (i=0; i < (ssize_t) number_threads; i++)
60  {
61  filter[i]=AcquireResampleFilter(image,exception);
62  if (method != UndefinedVirtualPixelMethod)
63  (void) SetResampleFilterVirtualPixelMethod(filter[i],method);
64  if (interpolate != MagickFalse)
65  SetResampleFilter(filter[i],PointFilter);
66  }
67  return(filter);
68 }
69 
70 #if defined(__cplusplus) || defined(c_plusplus)
71 }
72 #endif
73 
74 #endif
Definition: image.h:152