MagickCore 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
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)
24extern "C" {
25#endif
26
27static inline ResampleFilter **DestroyResampleFilterTLS(ResampleFilter **filter)
28{
29 ssize_t
30 i;
31
32 for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
33 if (filter[i] != (ResampleFilter *) NULL)
34 filter[i]=DestroyResampleFilter(filter[i]);
35 filter=(ResampleFilter **) RelinquishMagickMemory(filter);
36 return(filter);
37}
38
39static inline ResampleFilter **AcquireResampleFilterTLS(const Image *image,
40 const VirtualPixelMethod method,const MagickBooleanType interpolate,
41 ExceptionInfo *exception)
42{
43 ssize_t
44 i;
45
47 **filter;
48
49 size_t
50 number_threads;
51
52 number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
53 filter=(ResampleFilter **) AcquireQuantumMemory(number_threads,
54 sizeof(*filter));
55 if (filter == (ResampleFilter **) NULL)
56 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
57 (void) memset(filter,0,number_threads*sizeof(*filter));
58 for (i=0; i < (ssize_t) number_threads; i++)
59 {
60 filter[i]=AcquireResampleFilter(image,exception);
61 if (method != UndefinedVirtualPixelMethod)
62 (void) SetResampleFilterVirtualPixelMethod(filter[i],method);
63 if (interpolate != MagickFalse)
64 SetResampleFilter(filter[i],PointFilter);
65 }
66 return(filter);
67}
68
69#if defined(__cplusplus) || defined(c_plusplus)
70}
71#endif
72
73#endif