MagickCore  7.1.0
Convert, Edit, Or Compose Bitmap Images
resample-private.h
Go to the documentation of this file.
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 
22 
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26 
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
#define ThrowFatalException(severity, tag)
VirtualPixelMethod
Definition: cache-view.h:27
MagickExport ResampleFilter * AcquireResampleFilter(const Image *image, ExceptionInfo *exception)
Definition: resample.c:208
Definition: image.h:151
MagickBooleanType
Definition: magick-type.h:161
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:665
MagickExport MagickBooleanType SetResampleFilterVirtualPixelMethod(ResampleFilter *resample_filter, const VirtualPixelMethod method)
Definition: resample.c:1443
MagickExport MagickSizeType GetMagickResourceLimit(const ResourceType type)
Definition: resource.c:795
MagickExport ResampleFilter * DestroyResampleFilter(ResampleFilter *resample_filter)
Definition: resample.c:262
MagickExport void SetResampleFilter(ResampleFilter *resample_filter, const FilterType filter)
Definition: resample.c:1241
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1162
static ResampleFilter ** AcquireResampleFilterTLS(const Image *image, const VirtualPixelMethod method, const MagickBooleanType interpolate, ExceptionInfo *exception)
static ResampleFilter ** DestroyResampleFilterTLS(ResampleFilter **filter)