380
348
Rotate 0 degrees.
356
(void) strlcpy(message,"[%s] Rotate image 0 degrees...",sizeof(message));
357
#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
358
# pragma omp parallel for schedule(static,8) shared(row_count, status)
382
360
for (y=0; y < (long) image->rows; y++)
362
register const PixelPacket
368
register const IndexPacket
377
thread_status=status;
378
if (thread_status == MagickFail)
384
381
p=AcquireImagePixels(image,0,y,image->columns,1,exception);
385
q=SetImagePixels(rotate_image,0,y,rotate_image->columns,1);
382
q=SetImagePixelsEx(rotate_image,0,y,rotate_image->columns,1,exception);
386
383
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
388
(void) memcpy(q,p,image->columns*sizeof(PixelPacket));
389
indexes=GetIndexes(image);
390
rotate_indexes=GetIndexes(rotate_image);
391
if ((indexes != (IndexPacket *) NULL) &&
392
(rotate_indexes != (IndexPacket *) NULL))
393
(void) memcpy(rotate_indexes,indexes,image->columns*
394
sizeof(IndexPacket));
395
if (!SyncImagePixels(rotate_image))
397
if (QuantumTick(y,image->rows))
398
if (!MagickMonitor(RotateImageText,y,image->rows,exception))
384
thread_status=MagickFail;
385
if (thread_status != MagickFail)
387
(void) memcpy(q,p,image->columns*sizeof(PixelPacket));
388
indexes=AccessImmutableIndexes(image);
389
rotate_indexes=AccessMutableIndexes(rotate_image);
390
if ((indexes != (IndexPacket *) NULL) &&
391
(rotate_indexes != (IndexPacket *) NULL))
392
(void) memcpy(rotate_indexes,indexes,image->columns*
393
sizeof(IndexPacket));
395
if (!SyncImagePixelsEx(rotate_image,exception))
396
thread_status=MagickFail;
398
#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
399
# pragma omp critical
403
if (QuantumTick(row_count,image->rows))
404
if (!MagickMonitorFormatted(row_count,image->rows,exception,
405
message,image->filename))
406
thread_status=MagickFail;
408
if (thread_status == MagickFail)
503
581
Rotate 180 degrees.
589
(void) strlcpy(message,"[%s] Rotate image 180 degrees...",sizeof(message));
590
#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
591
# pragma omp parallel for schedule(static,8) shared(row_count, status)
505
593
for (y=0; y < (long) image->rows; y++)
595
register const PixelPacket
601
register const IndexPacket
613
thread_status=status;
614
if (thread_status == MagickFail)
507
617
p=AcquireImagePixels(image,0,y,image->columns,1,exception);
508
q=SetImagePixels(rotate_image,0,(long) (image->rows-y-1),
618
q=SetImagePixelsEx(rotate_image,0,(long) (image->rows-y-1),
619
image->columns,1,exception);
510
620
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
513
indexes=GetIndexes(image);
514
rotate_indexes=GetIndexes(rotate_image);
515
if ((indexes != (IndexPacket *) NULL) &&
516
(rotate_indexes != (IndexPacket *) NULL))
517
for (x=0; x < (long) image->columns; x++)
518
rotate_indexes[image->columns-x-1]=indexes[x];
519
for (x=0; x < (long) image->columns; x++)
521
if (!SyncImagePixels(rotate_image))
523
if (QuantumTick(y,image->rows))
524
if (!MagickMonitor(RotateImageText,y,image->rows,exception))
621
thread_status=MagickFail;
622
if (thread_status != MagickFail)
625
indexes=AccessImmutableIndexes(image);
626
rotate_indexes=AccessMutableIndexes(rotate_image);
627
if ((indexes != (IndexPacket *) NULL) &&
628
(rotate_indexes != (IndexPacket *) NULL))
629
for (x=0; x < (long) image->columns; x++)
630
rotate_indexes[image->columns-x-1]=indexes[x];
631
for (x=0; x < (long) image->columns; x++)
633
if (!SyncImagePixelsEx(rotate_image,exception))
634
thread_status=MagickFail;
636
#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
637
# pragma omp critical
641
if (QuantumTick(row_count,image->rows))
642
if (!MagickMonitorFormatted(row_count,image->rows,exception,
643
message,image->filename))
644
thread_status=MagickFail;
646
if (thread_status == MagickFail)
527
650
page.x=(long) (page.width-rotate_image->columns-page.x);
528
651
page.y=(long) (page.height-rotate_image->rows-page.y);
670
static inline PixelPacket BlendComposite(const PixelPacket *p,
671
const PixelPacket *q,const double alpha)
679
color=((double) p->red*(MaxRGB-alpha)+q->red*alpha)/MaxRGB;
680
composite.red=(Quantum)
681
((color < 0) ? 0 : (color > MaxRGB) ? MaxRGB : color+0.5);
682
color=((double) p->green*(MaxRGB-alpha)+q->green*alpha)/MaxRGB;
683
composite.green=(Quantum)
684
((color < 0) ? 0 : (color > MaxRGB) ? MaxRGB : color+0.5);
685
color=((double) p->blue*(MaxRGB-alpha)+q->blue*alpha)/MaxRGB;
686
composite.blue=(Quantum)
687
((color < 0) ? 0 : (color > MaxRGB) ? MaxRGB : color+0.5);
688
composite.opacity=p->opacity;
692
864
static void XShearImage(Image *image,const double degrees,
693
const unsigned long width,const unsigned long height,const long x_offset,
865
const unsigned long width,const unsigned long height,
866
const long x_offset,long y_offset)
696
#define XShearImageText " X Shear image... "
868
#define XShearImageText "[%s] X Shear image... "
722
882
assert(image != (Image *) NULL);
723
883
is_grayscale=image->is_grayscale;
885
#if defined(HAVE_OPENMP)
886
# pragma omp parallel for schedule(dynamic,8) shared(row_count, status)
726
888
for (y=0; y < (long) height; y++)
729
displacement=degrees*(y-height/2.0);
730
if (displacement == 0.0)
732
if (displacement > 0.0)
736
displacement*=(-1.0);
739
step=(long) floor(displacement);
740
alpha=(double) MaxRGB*(displacement-step);
744
No fractional displacement-- just copy.
916
thread_status=status;
917
if (thread_status == MagickFail)
920
displacement=degrees*(y-height/2.0);
921
if (displacement == 0.0)
923
if (displacement > 0.0)
927
displacement*=(-1.0);
930
step=(long) floor(displacement);
931
alpha=(double) MaxRGB*(displacement-step);
935
No fractional displacement-- just copy.
942
Transfer pixels left-to-right.
946
p=GetImagePixelsEx(image,0,y+y_offset,image->columns,1,&image->exception);
947
if (p == (PixelPacket *) NULL)
949
thread_status=MagickFail;
954
(void) memcpy(q,p,width*sizeof(PixelPacket));
956
for (i=0; i < (long) step; i++)
957
*q++=image->background_color;
963
Transfer pixels right-to-left.
965
p=GetImagePixelsEx(image,0,y+y_offset,image->columns,1,&image->exception);
966
if (p == (PixelPacket *) NULL)
968
thread_status=MagickFail;
973
for (i=0; i < (long) width; i++)
975
for (i=0; i < (long) step; i++)
976
*--q=image->background_color;
980
if (!SyncImagePixelsEx(image,&image->exception))
981
thread_status=MagickFail;
983
#if defined(HAVE_OPENMP)
984
# pragma omp critical
988
if (QuantumTick(row_count,height))
989
if (!MagickMonitorFormatted(row_count,height,&image->exception,
990
XShearImageText,image->filename))
991
thread_status=MagickFail;
993
if (thread_status == MagickFail)
1000
Fractional displacement.
1003
pixel=image->background_color;
751
1009
Transfer pixels left-to-right.
753
1011
if (step > x_offset)
755
p=GetImagePixels(image,0,y_offset,image->columns,1);
1013
p=GetImagePixelsEx(image,0,y+y_offset,image->columns,1,&image->exception);
756
1014
if (p == (PixelPacket *) NULL)
1016
thread_status=MagickFail;
760
(void) memcpy(q,p,width*sizeof(PixelPacket));
762
for (i=0; i < (long) step; i++)
1021
for (i=0; i < (long) width; i++)
1023
if ((x_offset+i) < step)
1029
BlendCompositePixel(q,&pixel,p,alpha);
1033
BlendCompositePixel(q,&pixel,&image->background_color,alpha);
1035
for (i=0; i < (step-1); i++)
763
1036
*q++=image->background_color;
769
1042
Transfer pixels right-to-left.
771
p=GetImagePixels(image,0,y_offset,image->columns,1);
1044
p=GetImagePixelsEx(image,0,y+y_offset,image->columns,1,&image->exception);
772
1045
if (p == (PixelPacket *) NULL)
1047
thread_status=MagickFail;
774
1050
p+=x_offset+width;
776
1052
for (i=0; i < (long) width; i++)
778
for (i=0; i < (long) step; i++)
1056
if ((x_offset+width+step-i) >= image->columns)
1058
BlendCompositePixel(q,&pixel,p,alpha);
1062
BlendCompositePixel(q,&pixel,&image->background_color,alpha);
1063
for (i=0; i < (step-1); i++)
779
1064
*--q=image->background_color;
783
if (!SyncImagePixels(image))
788
Fractional displacement.
791
pixel=image->background_color;
797
Transfer pixels left-to-right.
801
p=GetImagePixels(image,0,y_offset,image->columns,1);
802
if (p == (PixelPacket *) NULL)
806
for (i=0; i < (long) width; i++)
808
if ((x_offset+i) < step)
814
*q++=BlendComposite(&pixel,p,alpha);
817
*q++=BlendComposite(&pixel,&image->background_color,alpha);
818
for (i=0; i < (step-1); i++)
819
*q++=image->background_color;
825
Transfer pixels right-to-left.
827
p=GetImagePixels(image,0,y_offset,image->columns,1);
828
if (p == (PixelPacket *) NULL)
832
for (i=0; i < (long) width; i++)
836
if ((x_offset+width+step-i) >= image->columns)
838
*q=BlendComposite(&pixel,p,alpha);
841
*--q=BlendComposite(&pixel,&image->background_color,alpha);
842
for (i=0; i < (step-1); i++)
843
*--q=image->background_color;
1068
if (!SyncImagePixelsEx(image,&image->exception))
1069
thread_status=MagickFail;
1070
#if defined(HAVE_OPENMP)
1071
# pragma omp critical
1075
if (QuantumTick(row_count,height))
1076
if (!MagickMonitorFormatted(row_count,height,&image->exception,
1077
XShearImageText,image->filename))
1078
thread_status=MagickFail;
1080
if (thread_status == MagickFail)
847
if (!SyncImagePixels(image))
849
if (QuantumTick(y,height))
850
if (!MagickMonitor(XShearImageText,y,height,&image->exception))
853
1084
if (is_grayscale && IsGray(image->background_color))
854
1085
image->is_grayscale=True;
891
1122
static void YShearImage(Image *image,const double degrees,
892
const unsigned long width,const unsigned long height,long x_offset,
1123
const unsigned long width,const unsigned long height,long x_offset,
1124
const long y_offset)
895
#define YShearImageText " Y Shear image... "
1126
#define YShearImageText "[%s] Y Shear image..."
921
1140
assert(image != (Image *) NULL);
922
1141
is_grayscale=image->is_grayscale;
1143
#if defined(HAVE_OPENMP)
1144
# pragma omp parallel for schedule(dynamic,8) shared(row_count, status)
924
1146
for (y=0; y < (long) width; y++)
927
displacement=degrees*(y-width/2.0);
928
if (displacement == 0.0)
930
if (displacement > 0.0)
934
displacement*=(-1.0);
937
step=(long) floor(displacement);
938
alpha=(double) MaxRGB*(displacement-step);
942
No fractional displacement-- just copy the pixels.
1161
register PixelPacket
1174
thread_status=status;
1175
if (thread_status == MagickFail)
1178
displacement=degrees*(y-width/2.0);
1179
if (displacement == 0.0)
1181
if (displacement > 0.0)
1185
displacement*=(-1.0);
1188
step=(long) floor(displacement);
1189
alpha=(double) MaxRGB*(displacement-step);
1193
No fractional displacement-- just copy the pixels.
1200
Transfer pixels top-to-bottom.
1202
if (step > y_offset)
1204
p=GetImagePixelsEx(image,y+x_offset,0,1,image->rows,&image->exception);
1205
if (p == (PixelPacket *) NULL)
1207
thread_status=MagickFail;
1212
(void) memcpy(q,p,height*sizeof(PixelPacket));
1214
for (i=0; i < (long) step; i++)
1215
*q++=image->background_color;
1221
Transfer pixels bottom-to-top.
1223
p=GetImagePixelsEx(image,y+x_offset,0,1,image->rows,&image->exception);
1224
if (p == (PixelPacket *) NULL)
1226
thread_status=MagickFail;
1231
for (i=0; i < (long) height; i++)
1233
for (i=0; i < (long) step; i++)
1234
*--q=image->background_color;
1238
if (!SyncImagePixelsEx(image,&image->exception))
1239
thread_status=MagickFail;
1241
#if defined(HAVE_OPENMP)
1242
# pragma omp critical
1246
if (QuantumTick(row_count,width))
1247
if (!MagickMonitorFormatted(row_count,width,&image->exception,
1248
YShearImageText,image->filename))
1249
thread_status=MagickFail;
1251
if (thread_status == MagickFail)
1258
Fractional displacment.
1261
pixel=image->background_color;
949
1267
Transfer pixels top-to-bottom.
951
1269
if (step > y_offset)
953
p=GetImagePixels(image,x_offset,0,1,image->rows);
1271
p=GetImagePixelsEx(image,y+x_offset,0,1,image->rows,&image->exception);
954
1272
if (p == (PixelPacket *) NULL)
1274
thread_status=MagickFail;
958
(void) memcpy(q,p,height*sizeof(PixelPacket));
960
for (i=0; i < (long) step; i++)
1279
for (i=0; i < (long) height; i++)
1281
if ((y_offset+i) < step)
1287
BlendCompositePixel(q,&pixel,p,alpha);
1291
BlendCompositePixel(q,&pixel,&image->background_color,alpha);
1293
for (i=0; i < (step-1); i++)
961
1294
*q++=image->background_color;
967
1300
Transfer pixels bottom-to-top.
969
p=GetImagePixels(image,x_offset,0,1,image->rows);
1302
p=GetImagePixelsEx(image,y+x_offset,0,1,image->rows,&image->exception);
970
1303
if (p == (PixelPacket *) NULL)
1305
thread_status=MagickFail;
972
1308
p+=y_offset+height;
974
1310
for (i=0; i < (long) height; i++)
976
for (i=0; i < (long) step; i++)
1314
if ((y_offset+height+step-i) >= image->rows)
1316
BlendCompositePixel(q,&pixel,p,alpha);
1320
BlendCompositePixel(q,&pixel,&image->background_color,alpha);
1321
for (i=0; i < (step-1); i++)
977
1322
*--q=image->background_color;
981
if (!SyncImagePixels(image))
986
Fractional displacment.
989
pixel=image->background_color;
995
Transfer pixels top-to-bottom.
999
p=GetImagePixels(image,x_offset,0,1,image->rows);
1000
if (p == (PixelPacket *) NULL)
1004
for (i=0; i < (long) height; i++)
1006
if ((y_offset+i) < step)
1012
*q++=BlendComposite(&pixel,p,alpha);
1015
*q++=BlendComposite(&pixel,&image->background_color,alpha);
1016
for (i=0; i < (step-1); i++)
1017
*q++=image->background_color;
1023
Transfer pixels bottom-to-top.
1025
p=GetImagePixels(image,x_offset,0,1,image->rows);
1026
if (p == (PixelPacket *) NULL)
1030
for (i=0; i < (long) height; i++)
1034
if ((y_offset+height+step-i) >= image->rows)
1036
*q=BlendComposite(&pixel,p,alpha);
1039
*--q=BlendComposite(&pixel,&image->background_color,alpha);
1040
for (i=0; i < (step-1); i++)
1041
*--q=image->background_color;
1326
if (!SyncImagePixelsEx(image,&image->exception))
1327
thread_status=MagickFail;
1329
#if defined(HAVE_OPENMP)
1330
# pragma omp critical
1334
if (QuantumTick(row_count,width))
1335
if (!MagickMonitorFormatted(row_count,width,&image->exception,
1336
YShearImageText,image->filename))
1337
thread_status=MagickFail;
1339
if (thread_status == MagickFail)
1045
if (!SyncImagePixels(image))
1047
if (QuantumTick(y,width))
1048
if (!MagickMonitor(YShearImageText,y,width,&image->exception))
1051
1343
if (is_grayscale && IsGray(image->background_color))
1052
1344
image->is_grayscale=True;