180
180
image->y_resolution=DefaultResolution;
181
181
image->units=PixelsPerInchResolution;
182
182
GetTimerInfo(&image->timer);
183
image->ping=MagickFalse;
184
183
image->cache=AcquirePixelCache(0);
185
184
image->blob=CloneBlobInfo((BlobInfo *) NULL);
186
185
image->debug=IsEventLogging();
253
252
image->border_color=image_info->border_color;
254
253
image->matte_color=image_info->matte_color;
255
254
image->transparent_color=image_info->transparent_color;
256
image->ping=image_info->ping;
257
255
image->progress_monitor=image_info->progress_monitor;
258
256
image->client_data=image_info->client_data;
259
257
if (image_info->cache != (void *) NULL)
269
% A c q u i r e I m a g e C o l o r m a p %
273
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
275
% AcquireImageColormap() allocates an image colormap and initializes
276
% it to a linear gray colorspace. If the image already has a colormap,
277
% it is replaced. AcquireImageColormap() returns MagickTrue if successful,
278
% otherwise MagickFalse if there is not enough memory.
280
% The format of the AcquireImageColormap method is:
282
% MagickBooleanType AcquireImageColormap(Image *image,
283
% const unsigned long colors)
285
% A description of each parameter follows:
287
% o image: the image.
289
% o colors: the number of colors in the image colormap.
293
static inline unsigned long MagickMax(const unsigned long x,
294
const unsigned long y)
301
static inline unsigned long MagickMin(const unsigned long x,
302
const unsigned long y)
309
MagickExport MagickBooleanType AcquireImageColormap(Image *image,
310
const unsigned long colors)
319
Allocate image colormap.
321
assert(image != (Image *) NULL);
322
assert(image->signature == MagickSignature);
323
if (image->debug != MagickFalse)
324
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
325
image->colors=MagickMin(colors,MaxColormapSize);
326
length=(size_t) colors;
327
if (image->colormap == (PixelPacket *) NULL)
328
image->colormap=(PixelPacket *) AcquireQuantumMemory(length,
329
sizeof(*image->colormap));
331
image->colormap=(PixelPacket *) ResizeQuantumMemory(image->colormap,length,
332
sizeof(*image->colormap));
333
if (image->colormap == (PixelPacket *) NULL)
334
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
336
for (i=0; i < (long) image->colors; i++)
341
pixel=(unsigned long) (i*(QuantumRange/MagickMax(colors-1,1)));
342
image->colormap[i].red=(Quantum) pixel;
343
image->colormap[i].green=(Quantum) pixel;
344
image->colormap[i].blue=(Quantum) pixel;
345
image->colormap[i].opacity=OpaqueOpacity;
347
return(SetImageStorageClass(image,PseudoClass));
351
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271
355
% A c q u i r e I m a g e I n f o %
463
545
append_view=AcquireCacheView(append_image);
464
for (n=0; n < (MagickOffsetType) number_images; n++)
546
for (n=0; n < (long) number_images; n++)
466
548
SetGeometry(append_image,&geometry);
467
549
GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
506
588
indexes=GetCacheViewVirtualIndexQueue(image_view);
507
589
append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
508
for (x=0; x < (ssize_t) image->columns; x++)
590
for (x=0; x < (long) image->columns; x++)
510
592
SetRedPixelComponent(q,GetRedPixelComponent(p));
511
593
SetGreenPixelComponent(q,GetGreenPixelComponent(p));
700
782
% The format of the CloneImage method is:
702
% Image *CloneImage(const Image *image,const size_t columns,
703
% const size_t rows,const MagickBooleanType orphan,
784
% Image *CloneImage(const Image *image,const unsigned long columns,
785
% const unsigned long rows,const MagickBooleanType orphan,
704
786
% ExceptionInfo *exception)
706
788
% A description of each parameter follows:
717
799
% o exception: return any errors or warnings in this structure.
720
MagickExport Image *CloneImage(const Image *image,const size_t columns,
721
const size_t rows,const MagickBooleanType detach,
802
MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
803
const unsigned long rows,const MagickBooleanType detach,
722
804
ExceptionInfo *exception)
791
873
clone_image->blob=ReferenceBlob(image->blob);
793
875
clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
794
clone_image->ping=image->ping;
795
876
clone_image->debug=IsEventLogging();
796
877
clone_image->semaphore=AllocateSemaphoreInfo();
797
878
if ((columns == 0) && (rows == 0))
809
890
return(clone_image);
811
892
scale=(MagickRealType) columns/(MagickRealType) image->columns;
812
clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
813
clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
814
clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
893
clone_image->page.width=(unsigned long) (scale*image->page.width+0.5);
894
clone_image->page.x=(long) (scale*image->page.x+0.5);
895
clone_image->tile_offset.x=(long) (scale*image->tile_offset.x+0.5);
815
896
scale=(MagickRealType) rows/(MagickRealType) image->rows;
816
clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
817
clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
818
clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
897
clone_image->page.height=(unsigned long) (scale*image->page.height+0.5);
898
clone_image->page.y=(long) (image->page.y*scale+0.5);
899
clone_image->tile_offset.y=(long) (scale*image->tile_offset.y+0.5);
819
900
clone_image->columns=columns;
820
901
clone_image->rows=rows;
821
902
clone_image->cache=ClonePixelCache(image->cache);
1562
1641
% The format of the GetReferenceCount method is:
1564
% ssize_t GetImageReferenceCount(Image *image)
1643
% long GetImageReferenceCount(Image *image)
1566
1645
% A description of each parameter follows:
1568
1647
% o image: the image.
1571
MagickExport ssize_t GetImageReferenceCount(Image *image)
1650
MagickExport long GetImageReferenceCount(Image *image)
1574
1653
reference_count;
1576
1655
assert(image != (Image *) NULL);
1856
1935
indexes=GetCacheViewVirtualIndexQueue(image_view);
1858
for (x=0; x < (ssize_t) image->columns; x++)
1937
for (x=0; x < (long) image->columns; x++)
1860
1939
SetMagickPixelPacket(image,p,indexes+x,&pixel);
1861
1940
if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
2040
2119
% The format of the NewMagickImage method is:
2042
2121
% Image *NewMagickImage(const ImageInfo *image_info,
2043
% const size_t width,const size_t height,
2122
% const unsigned long width,const unsigned long height,
2044
2123
% const MagickPixelPacket *background)
2046
2125
% A description of each parameter follows:
2057
2136
MagickExport Image *NewMagickImage(const ImageInfo *image_info,
2058
const size_t width,const size_t height,
2137
const unsigned long width,const unsigned long height,
2059
2138
const MagickPixelPacket *background)
2616
2693
if (image->colorspace == CMYKColorspace)
2618
2695
indexes=GetCacheViewAuthenticIndexQueue(image_view);
2619
for (x=0; x < (ssize_t) image->columns; x++)
2696
for (x=0; x < (long) image->columns; x++)
2620
2697
indexes[x]=index;
2622
2699
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2778
2855
status=MagickFalse;
2781
for (x=0; x < (ssize_t) image->columns; x++)
2858
for (x=0; x < (long) image->columns; x++)
2783
2860
if (image->colorspace == CMYKColorspace)
2785
2862
indexes=GetCacheViewAuthenticIndexQueue(image_view);
2786
for (x=0; x < (ssize_t) image->columns; x++)
2863
for (x=0; x < (long) image->columns; x++)
2787
2864
indexes[x]=index;
2789
2866
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2801
% S e t I m a g e C o l o r %
2805
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2807
% SetImageColor() set the entire image canvas to the specified color.
2809
% The format of the SetImageColor method is:
2811
% MagickBooleanType SetImageColor(Image *image,
2812
% const MagickPixelPacket *color)
2814
% A description of each parameter follows:
2816
% o image: the image.
2818
% o background: the image color.
2821
MagickExport MagickBooleanType SetImageColor(Image *image,
2822
const MagickPixelPacket *color)
2836
assert(image != (Image *) NULL);
2837
if (image->debug != MagickFalse)
2838
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2839
assert(image->signature == MagickSignature);
2840
assert(color != (const MagickPixelPacket *) NULL);
2841
image->colorspace=color->colorspace;
2842
image->matte=color->matte;
2843
image->fuzz=color->fuzz;
2844
image->depth=color->depth;
2846
exception=(&image->exception);
2847
image_view=AcquireCacheView(image);
2848
#if defined(MAGICKCORE_OPENMP_SUPPORT)
2849
#pragma omp parallel for schedule(dynamic,4) shared(status)
2851
for (y=0; y < (ssize_t) image->rows; y++)
2853
register IndexPacket
2859
register PixelPacket
2862
if (status == MagickFalse)
2864
q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2865
if (q == (PixelPacket *) NULL)
2870
indexes=GetCacheViewAuthenticIndexQueue(image_view);
2871
for (x=0; x < (ssize_t) image->columns; x++)
2873
SetPixelPacket(image,color,q,indexes+x);
2876
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2879
image_view=DestroyCacheView(image_view);
2884
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2888
2878
% S e t I m a g e S t o r a g e C l a s s %
2986
2976
% The format of the SetImageExtent method is:
2988
2978
% MagickBooleanType SetImageExtent(Image *image,
2989
% const size_t columns,const size_t rows)
2979
% const unsigned long columns,const unsigned long rows)
2991
2981
% A description of each parameter follows:
3117
3107
while ((isspace((int) ((unsigned char) *p)) != 0) ||
3120
first=(size_t) strtol(p,&q,10);
3110
first=(unsigned long) strtol(p,&q,10);
3122
3112
while (isspace((int) ((unsigned char) *q)) != 0)
3125
last=(size_t) strtol(q+1,&q,10);
3115
last=(unsigned long) strtol(q+1,&q,10);
3126
3116
if (first > last)
3127
3117
Swap(first,last);
3128
3118
if (first < image_info->scene)
3826
3816
static inline IndexPacket PushColormapIndex(Image *image,
3827
const size_t index,MagickBooleanType *range_exception)
3817
const unsigned long index,MagickBooleanType *range_exception)
3829
3819
if (index < image->colors)
3830
3820
return((IndexPacket) index);
3888
3878
indexes=GetCacheViewAuthenticIndexQueue(image_view);
3889
for (x=0; x < (ssize_t) image->columns; x++)
3879
for (x=0; x < (long) image->columns; x++)
3891
index=PushColormapIndex(image,(size_t) indexes[x],
3881
index=PushColormapIndex(image,(unsigned long) indexes[x],
3892
3882
&range_exception);
3893
pixel=image->colormap[(ssize_t) index];
3883
pixel=image->colormap[(long) index];
3894
3884
q->red=pixel.red;
3895
3885
q->green=pixel.green;
3896
3886
q->blue=pixel.blue;
3897
if (image->matte != MagickFalse)
3898
q->opacity=pixel.opacity;
3901
3889
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
4030
4015
flags=ParseGeometry(option,&geometry_info);
4031
4016
if ((flags & GreaterValue) != 0)
4033
if (image->delay > (size_t) floor(geometry_info.rho+0.5))
4034
image->delay=(size_t) floor(geometry_info.rho+0.5);
4018
if (image->delay > (unsigned long) (geometry_info.rho+0.5))
4019
image->delay=(unsigned long) (geometry_info.rho+0.5);
4037
4022
if ((flags & LessValue) != 0)
4039
if (image->delay < (size_t) floor(geometry_info.rho+0.5))
4040
image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
4024
if (image->delay < (unsigned long) (geometry_info.rho+0.5))
4025
image->ticks_per_second=(long) (geometry_info.sigma+0.5);
4043
image->delay=(size_t) floor(geometry_info.rho+0.5);
4028
image->delay=(unsigned long) (geometry_info.rho+0.5);
4044
4029
if ((flags & SigmaValue) != 0)
4045
image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
4030
image->ticks_per_second=(long) (geometry_info.sigma+0.5);
4047
4032
option=GetImageOption(image_info,"density");
4048
4033
if (option != (const char *) NULL)
4166
4151
option=GetImageOption(image_info,"units");
4167
4152
if (option != (const char *) NULL)
4168
units=(ResolutionType) ParseMagickOption(MagickResolutionOptions,
4153
image->units=(ResolutionType) ParseMagickOption(MagickResolutionOptions,
4169
4154
MagickFalse,option);
4171
units = image_info->units;
4172
if (units != UndefinedResolution)
4155
if (image_info->units != UndefinedResolution)
4174
if (image->units != units)
4157
if (image->units != image_info->units)
4175
4158
switch (image->units)
4177
4160
case PixelsPerInchResolution:
4179
if (units == PixelsPerCentimeterResolution)
4162
if (image_info->units == PixelsPerCentimeterResolution)
4181
4164
image->x_resolution/=2.54;
4182
4165
image->y_resolution/=2.54;
4186
4169
case PixelsPerCentimeterResolution:
4188
if (units == PixelsPerInchResolution)
4171
if (image_info->units == PixelsPerInchResolution)
4190
image->x_resolution=(double) ((size_t) (100.0*2.54*
4191
image->x_resolution+0.5))/100.0;
4192
image->y_resolution=(double) ((size_t) (100.0*2.54*
4193
image->y_resolution+0.5))/100.0;
4173
image->x_resolution*=2.54;
4174
image->y_resolution*=2.54;
4181
image->units=image_info->units;
4202
4183
option=GetImageOption(image_info,"white-point");
4203
4184
if (option != (const char *) NULL)