rmagick 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

@@ -1,6 +1,8 @@
1
1
  #undef GRAPHICSMAGICK
2
2
  /* Introduced in IM 6.0.0, GM 1.1 */
3
3
  #undef HAVE_ACQUIREMAGICKMEMORY
4
+ /* Introduced in IM 6.2.7 */
5
+ #undef HAVE_ADAPTIVESHARPENIMAGE
4
6
  /* Introduced in IM 6.0.0 */
5
7
  #undef HAVE_ACQUIRESTRINGINFO
6
8
  /* GraphicsMagick only */
@@ -28,6 +30,8 @@
28
30
  /* Introduced in IM 6.2.6 */
29
31
  #undef HAVE_COMPAREIMAGELAYERS
30
32
  /* Introduced in IM 6.2.6 */
33
+ #undef HAVE_COMPOSITEIMAGECHANNEL
34
+ /* Introduced in IM 6.2.6 */
31
35
  #undef HAVE_CONTRASTSTRETCHIMAGECHANNEL
32
36
  /* Introduced in IM 6.0.1 */
33
37
  #undef HAVE_CONVOLVEIMAGECHANNEL
@@ -152,6 +156,8 @@
152
156
  #undef HAVE_QUANTUMPIXEL
153
157
  /* Not available in GM */
154
158
  #undef HAVE_RADIALBLURIMAGE
159
+ /* Introduced in IM 6.2.4 */
160
+ #undef HAVE_RADIALBLURIMAGECHANNEL
155
161
  #undef HAVE_RANDOMCHANNELTHRESHOLDIMAGE
156
162
  #undef HAVE_RANDOMTHRESHOLDIMAGECHANNEL
157
163
  /* Introduced in GM 1.2 & IM 6.2.2 */
@@ -170,9 +176,15 @@
170
176
  #undef HAVE_SETIMAGECOLORSPACE
171
177
  /* Introduced in IM 6.0.0, GM 1.1 */
172
178
  #undef HAVE_SETIMAGECHANNELDEPTH
179
+ /* Introduced in IM 6.2.4 */
180
+ #undef HAVE_SETIMAGEEXTENT
181
+ /* Introduced in IM 6.2.1 */
182
+ #undef HAVE_SETIMAGEINFOFILE
173
183
  #undef HAVE_SETIMAGEOPTION
174
184
  /* Introduced in IM 6.1.0 */
175
185
  #undef HAVE_SETIMAGEPROGRESSMONITOR
186
+ /* Introduced in IM 6.2.6 */
187
+ #undef HAVE_SETIMAGESTORAGECLASS
176
188
  /* Introduced in IM 6.1.7 */
177
189
  #undef HAVE_SHADOWIMAGE
178
190
  /* Introduced in IM 6.0.1 */
@@ -192,6 +204,10 @@
192
204
  #undef HAVE_TINTIMAGE
193
205
  /* Introduced in IM 6.2.4 */
194
206
  #undef HAVE_TRANSPARENTVIRTUALPIXELMETHOD
207
+ /* Introduced in IM 6.2.8 */
208
+ #undef HAVE_TRANSPOSEIMAGE
209
+ /* Introduced in IM 6.2.8 */
210
+ #undef HAVE_TRANSVERSEIMAGE
195
211
  /* Introduced in IM 6.0.0 */
196
212
  #undef HAVE_UNDEFINEDGRAVITY
197
213
  #undef HAVE_UNISTD_H
@@ -1,4 +1,4 @@
1
- /* $Id: rmfill.c,v 1.14 2006/05/07 23:46:19 rmagick Exp $ */
1
+ /* $Id: rmfill.c,v 1.15 2006/06/28 23:06:15 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2006 by Timothy P. Hunter
4
4
  | Name: rmfill.c
@@ -13,12 +13,12 @@ typedef struct
13
13
  double x1, y1, x2, y2;
14
14
  PixelPacket start_color;
15
15
  PixelPacket stop_color;
16
- } GradientFill;
16
+ } rm_GradientFill;
17
17
 
18
18
  typedef struct
19
19
  {
20
20
  Image *texture;
21
- } TextureFill;
21
+ } rm_TextureFill;
22
22
 
23
23
  /*
24
24
  Static: free_Fill
@@ -45,7 +45,7 @@ GradientFill_new(
45
45
  VALUE start_color,
46
46
  VALUE stop_color)
47
47
  {
48
- GradientFill *fill;
48
+ rm_GradientFill *fill;
49
49
  volatile VALUE new_fill;
50
50
  VALUE argv[6];
51
51
 
@@ -57,7 +57,7 @@ GradientFill_new(
57
57
  argv[5] = stop_color;
58
58
 
59
59
  new_fill = Data_Make_Struct(class
60
- , GradientFill
60
+ , rm_GradientFill
61
61
  , NULL
62
62
  , free_Fill
63
63
  , fill);
@@ -69,9 +69,9 @@ GradientFill_new(
69
69
  VALUE
70
70
  GradientFill_alloc(VALUE class)
71
71
  {
72
- GradientFill *fill;
72
+ rm_GradientFill *fill;
73
73
 
74
- return Data_Make_Struct(class, GradientFill, NULL, free_Fill, fill);
74
+ return Data_Make_Struct(class, rm_GradientFill, NULL, free_Fill, fill);
75
75
  }
76
76
  #endif
77
77
 
@@ -89,9 +89,9 @@ GradientFill_initialize(
89
89
  VALUE start_color,
90
90
  VALUE stop_color)
91
91
  {
92
- GradientFill *fill;
92
+ rm_GradientFill *fill;
93
93
 
94
- Data_Get_Struct(self, GradientFill, fill);
94
+ Data_Get_Struct(self, rm_GradientFill, fill);
95
95
 
96
96
  fill->x1 = NUM2DBL(x1);
97
97
  fill->y1 = NUM2DBL(y1);
@@ -460,12 +460,12 @@ h_diagonal_fill(
460
460
  VALUE
461
461
  GradientFill_fill(VALUE self, VALUE image_obj)
462
462
  {
463
- GradientFill *fill;
463
+ rm_GradientFill *fill;
464
464
  Image *image;
465
465
  PixelPacket start_color, stop_color;
466
466
  double x1, y1, x2, y2; // points on the line
467
467
 
468
- Data_Get_Struct(self, GradientFill, fill);
468
+ Data_Get_Struct(self, rm_GradientFill, fill);
469
469
  Data_Get_Struct(image_obj, Image, image);
470
470
 
471
471
  x1 = fill->x1;
@@ -527,7 +527,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
527
527
  static void
528
528
  free_TextureFill(void *fill_obj)
529
529
  {
530
- TextureFill *fill = (TextureFill *)fill_obj;
530
+ rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
531
531
 
532
532
  DestroyImage(fill->texture);
533
533
  xfree(fill);
@@ -542,12 +542,12 @@ free_TextureFill(void *fill_obj)
542
542
  VALUE
543
543
  TextureFill_new(VALUE class, VALUE texture)
544
544
  {
545
- TextureFill *fill;
545
+ rm_TextureFill *fill;
546
546
  VALUE argv[1];
547
547
  volatile VALUE new_fill;
548
548
 
549
549
  new_fill = Data_Make_Struct(class
550
- , TextureFill
550
+ , rm_TextureFill
551
551
  , NULL
552
552
  , free_TextureFill
553
553
  , fill);
@@ -559,9 +559,9 @@ TextureFill_new(VALUE class, VALUE texture)
559
559
  VALUE
560
560
  TextureFill_alloc(VALUE class)
561
561
  {
562
- TextureFill *fill;
562
+ rm_TextureFill *fill;
563
563
  return Data_Make_Struct(class
564
- , TextureFill
564
+ , rm_TextureFill
565
565
  , NULL
566
566
  , free_TextureFill
567
567
  , fill);
@@ -575,11 +575,11 @@ TextureFill_alloc(VALUE class)
575
575
  VALUE
576
576
  TextureFill_initialize(VALUE self, VALUE texture_arg)
577
577
  {
578
- TextureFill *fill;
578
+ rm_TextureFill *fill;
579
579
  Image *texture;
580
580
  volatile VALUE texture_image;
581
581
 
582
- Data_Get_Struct(self, TextureFill, fill);
582
+ Data_Get_Struct(self, rm_TextureFill, fill);
583
583
 
584
584
  texture_image = ImageList_cur_image(texture_arg);
585
585
 
@@ -598,11 +598,11 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
598
598
  VALUE
599
599
  TextureFill_fill(VALUE self, VALUE image_obj)
600
600
  {
601
- TextureFill *fill;
601
+ rm_TextureFill *fill;
602
602
  Image *image;
603
603
 
604
604
  Data_Get_Struct(image_obj, Image, image);
605
- Data_Get_Struct(self, TextureFill, fill);
605
+ Data_Get_Struct(self, rm_TextureFill, fill);
606
606
 
607
607
  TextureImage(image, fill->texture);
608
608
  rm_check_image_exception(image, RetainOnError);
@@ -1,4 +1,4 @@
1
- /* $Id: rmilist.c,v 1.40 2006/05/27 21:05:59 rmagick Exp $ */
1
+ /* $Id: rmilist.c,v 1.41 2006/06/20 23:33:07 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2006 by Timothy P. Hunter
4
4
  | Name: rmilist.c
@@ -716,7 +716,7 @@ ImageList_write(VALUE self, VALUE file)
716
716
 
717
717
  // Ensure file is open - raise error if not
718
718
  GetOpenFile(file, fptr);
719
- info->file = GetReadFile(fptr);
719
+ SetImageInfoFile(info, GetReadFile(fptr));
720
720
  }
721
721
  else
722
722
  {
@@ -728,7 +728,7 @@ ImageList_write(VALUE self, VALUE file)
728
728
  filenameL = min(filenameL, MaxTextExtent-1);
729
729
  memcpy(info->filename, filename, (size_t)filenameL);
730
730
  info->filename[filenameL] = '\0';
731
- info->file = NULL;
731
+ SetImageInfoFile(info, NULL);
732
732
  }
733
733
 
734
734
  // Copy the filename into each images. Set a scene number to be used if
@@ -1,4 +1,4 @@
1
- /* $Id: rmimage.c,v 1.147 2006/06/02 23:26:53 rmagick Exp $ */
1
+ /* $Id: rmimage.c,v 1.153 2006/06/28 23:07:16 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2006 by Timothy P. Hunter
4
4
  | Name: rmimage.c
@@ -24,18 +24,121 @@ typedef Image *(scaler_t)(const Image *, const unsigned long, const unsigned lon
24
24
  typedef unsigned int (thresholder_t)(Image *, const char *);
25
25
  typedef Image *(xformer_t)(const Image *, const RectangleInfo *, ExceptionInfo *);
26
26
 
27
+ static VALUE cropper(int, int, VALUE *, VALUE);
27
28
  static VALUE effect_image(VALUE, int, VALUE *, effector_t *);
29
+ static VALUE flipflop(int, VALUE, flipper_t);
28
30
  static VALUE rd_image(VALUE, VALUE, reader_t);
31
+ static VALUE rotate(int, VALUE, VALUE);
29
32
  static VALUE scale(int, int, VALUE *, VALUE, scaler_t *);
30
- static VALUE cropper(int, int, VALUE *, VALUE);
31
- static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, xformer_t);
32
33
  static VALUE threshold_image(int, VALUE *, VALUE, thresholder_t);
34
+ static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, xformer_t);
33
35
  static VALUE array_from_images(Image *);
34
36
  static ChannelType extract_channels(int *, VALUE *);
35
37
  static void raise_ChannelType_error(VALUE);
36
38
 
37
39
  static ImageAttribute *Next_Attribute;
38
40
 
41
+
42
+
43
+
44
+ /*
45
+ Method: Image#adaptive_sharpen(radius=0.0, sigma=1.0)
46
+ Purpose: call AdaptiveSharpenImage
47
+ */
48
+ VALUE
49
+ Image_adaptive_sharpen(int argc, VALUE *argv, VALUE self)
50
+ {
51
+ #if defined(HAVE_ADAPTIVESHARPENIMAGE)
52
+ Image *image, *new_image;
53
+ double radius = 0.0;
54
+ double sigma = 1.0;
55
+ ExceptionInfo exception;
56
+
57
+ switch (argc)
58
+ {
59
+ case 2:
60
+ sigma = NUM2DBL(argv[1]);
61
+ case 1:
62
+ radius = NUM2DBL(argv[0]);
63
+ case 0:
64
+ break;
65
+ default:
66
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
67
+ break;
68
+ }
69
+
70
+ Data_Get_Struct(self, Image, image);
71
+
72
+ GetExceptionInfo(&exception);
73
+
74
+ new_image = AdaptiveSharpenImage(image, radius, sigma, &exception);
75
+ rm_check_exception(&exception, new_image, DestroyOnError);
76
+
77
+ DestroyExceptionInfo(&exception);
78
+
79
+ rm_ensure_result(new_image);
80
+
81
+ return rm_image_new(new_image);
82
+
83
+ #else
84
+
85
+ rm_not_implemented();
86
+ return (VALUE)0;
87
+ #endif
88
+ }
89
+
90
+
91
+ /*
92
+ Method: Image#adaptive_sharpen_channel(radius=0.0, sigma=1.0[, channel...])
93
+ Purpose: Call AdaptiveSharpenImageChannel
94
+ */
95
+ VALUE
96
+ Image_adaptive_sharpen_channel(int argc, VALUE *argv, VALUE self)
97
+ {
98
+ #if defined(HAVE_ADAPTIVESHARPENIMAGE)
99
+
100
+ Image *image, *new_image;
101
+ double radius = 0.0;
102
+ double sigma = 1.0;
103
+ ExceptionInfo exception;
104
+ ChannelType channels;
105
+
106
+ channels = extract_channels(&argc, argv);
107
+
108
+ switch (argc)
109
+ {
110
+ case 2:
111
+ sigma = NUM2DBL(argv[1]);
112
+ case 1:
113
+ radius = NUM2DBL(argv[0]);
114
+ case 0:
115
+ break;
116
+ default:
117
+ raise_ChannelType_error(argv[argc-1]);
118
+ break;
119
+ }
120
+
121
+ Data_Get_Struct(self, Image, image);
122
+
123
+ GetExceptionInfo(&exception);
124
+
125
+ new_image = AdaptiveSharpenImageChannel(image, channels, radius, sigma, &exception);
126
+ rm_check_exception(&exception, new_image, DestroyOnError);
127
+
128
+ DestroyExceptionInfo(&exception);
129
+
130
+ rm_ensure_result(new_image);
131
+
132
+ return rm_image_new(new_image);
133
+ #else
134
+
135
+ rm_not_implemented();
136
+ return (VALUE)0;
137
+ #endif
138
+ }
139
+
140
+
141
+
39
142
  /*
40
143
  Method: Image#adaptive_threshold(width=3, height=3, offset=0)
41
144
  Purpose: selects an individual threshold for each pixel based on
@@ -297,6 +400,124 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
297
400
  }
298
401
 
299
402
 
403
+ /*
404
+ Static: crisscross
405
+ Purpose: Handle #transverse, #transform methods
406
+ */
407
+ #if defined(HAVE_TRANSPOSEIMAGE) || defined(HAVE_TRANSVERSEIMAGE)
408
+ static VALUE
409
+ crisscross(
410
+ int bang,
411
+ VALUE self,
412
+ Image *(fp)(const Image *, ExceptionInfo *))
413
+ {
414
+ Image *image, *new_image;
415
+ ExceptionInfo exception;
416
+
417
+
418
+ Data_Get_Struct(self, Image, image);
419
+ GetExceptionInfo(&exception);
420
+
421
+ new_image = (fp)(image, &exception);
422
+ rm_check_exception(&exception, new_image, DestroyOnError);
423
+
424
+ DestroyExceptionInfo(&exception);
425
+
426
+ rm_ensure_result(new_image);
427
+
428
+ if (bang)
429
+ {
430
+ DATA_PTR(self) = new_image;
431
+ DestroyImage(image);
432
+ return self;
433
+ }
434
+
435
+ return rm_image_new(new_image);
436
+
437
+ }
438
+ #endif
439
+
440
+
441
+ /*
442
+ Method: Image#auto_orient
443
+ Purpose: Implement mogrify's -auto_orient option
444
+ automatically orient image based on EXIF orientation value
445
+ Notes: See mogrify.c in ImageMagick 6.2.8.
446
+ */
447
+ static VALUE auto_orient(int bang, VALUE self)
448
+ {
449
+ #if defined(HAVE_TRANSPOSEIMAGE) || defined(HAVE_TRANSVERSEIMAGE)
450
+ Image *image;
451
+ volatile VALUE new_image;
452
+
453
+ Data_Get_Struct(self, Image, image);
454
+
455
+ switch (image->orientation)
456
+ {
457
+ case TopRightOrientation:
458
+ new_image = flipflop(bang, self, FlopImage);
459
+ break;
460
+
461
+ case BottomRightOrientation:
462
+ new_image = rotate(bang, self, rb_float_new(180.0));
463
+ break;
464
+
465
+ case BottomLeftOrientation:
466
+ new_image = flipflop(bang, self, FlipImage);
467
+ break;
468
+
469
+ case LeftTopOrientation:
470
+ new_image = crisscross(bang, self, TransposeImage);
471
+ break;
472
+
473
+ case RightTopOrientation:
474
+ new_image = rotate(bang, self, rb_float_new(90.0));
475
+ break;
476
+
477
+ case RightBottomOrientation:
478
+ new_image = crisscross(bang, self, TransverseImage);
479
+ break;
480
+
481
+ case LeftBottomOrientation:
482
+ new_image = rotate(bang, self, rb_float_new(270.0));
483
+ break;
484
+
485
+ default: // Return IMMEDIATELY
486
+ return bang ? Qnil : Image_copy(self);
487
+ break;
488
+ }
489
+
490
+
491
+ Data_Get_Struct(new_image, Image, image);
492
+ image->orientation = TopLeftOrientation;
493
+
494
+ return new_image;
495
+
496
+ #else
497
+ rm_not_implemented();
498
+ return (VALUE)0;
499
+ #endif
500
+ }
501
+
502
+
503
+ VALUE
504
+ Image_auto_orient(VALUE self)
505
+ {
506
+ return auto_orient(False, self);
507
+ }
508
+
509
+ /*
510
+ Returns nil if the image is already properly oriented
511
+ */
512
+ VALUE
513
+ Image_auto_orient_bang(VALUE self)
514
+ {
515
+ rm_check_frozen(self);
516
+ return auto_orient(True, self);
517
+ }
518
+
519
+
520
+
300
521
  /*
301
522
  Method: Image#background_color
302
523
  Purpose: Return the name of the background color as a String.
@@ -1831,7 +2052,8 @@ static VALUE composite(
1831
2052
  int bang,
1832
2053
  int argc,
1833
2054
  VALUE *argv,
1834
- VALUE self)
2055
+ VALUE self,
2056
+ ChannelType channels)
1835
2057
  {
1836
2058
  Image *image, *new_image;
1837
2059
  Image *comp_image;
@@ -1939,7 +2161,11 @@ static VALUE composite(
1939
2161
  if (bang)
1940
2162
  {
1941
2163
  rm_check_frozen(self);
2164
+ #if defined(HAVE_COMPOSITEIMAGECHANNEL)
2165
+ (void) CompositeImageChannel(image, channels, operator, comp_image, x_offset, y_offset);
2166
+ #else
1942
2167
  (void) CompositeImage(image, operator, comp_image, x_offset, y_offset);
2168
+ #endif
1943
2169
  rm_check_image_exception(image, RetainOnError);
1944
2170
  return self;
1945
2171
  }
@@ -1947,7 +2173,11 @@ static VALUE composite(
1947
2173
  {
1948
2174
  new_image = rm_clone_image(image);
1949
2175
 
2176
+ #if defined(HAVE_COMPOSITEIMAGECHANNEL)
2177
+ (void) CompositeImageChannel(new_image, channels, operator, comp_image, x_offset, y_offset);
2178
+ #else
1950
2179
  (void) CompositeImage(new_image, operator, comp_image, x_offset, y_offset);
2180
+ #endif
1951
2181
  rm_check_image_exception(new_image, DestroyOnError);
1952
2182
 
1953
2183
  return rm_image_new(new_image);
@@ -1960,7 +2190,12 @@ VALUE Image_composite_bang(
1960
2190
  VALUE *argv,
1961
2191
  VALUE self)
1962
2192
  {
1963
- return composite(True, argc, argv, self);
2193
+ #if defined(HAVE_ALLCHANNELS)
2194
+ ChannelType channels = (AllChannels &~ OpacityChannel);
2195
+ #else
2196
+ ChannelType channels = (0xff &~ OpacityChannel);
2197
+ #endif
2198
+ return composite(True, argc, argv, self, channels);
1964
2199
  }
1965
2200
 
1966
2201
  VALUE Image_composite(
@@ -1968,7 +2203,12 @@ VALUE Image_composite(
1968
2203
  VALUE *argv,
1969
2204
  VALUE self)
1970
2205
  {
1971
- return composite(False, argc, argv, self);
2206
+ #if defined(HAVE_ALLCHANNELS)
2207
+ ChannelType channels = (AllChannels &~ OpacityChannel);
2208
+ #else
2209
+ ChannelType channels = (0xff &~ OpacityChannel);
2210
+ #endif
2211
+ return composite(False, argc, argv, self, channels);
1972
2212
  }
1973
2213
 
1974
2214
 
@@ -1998,6 +2238,50 @@ Image_composite_affine(
1998
2238
  return rm_image_new(new_image);
1999
2239
  }
2000
2240
 
2241
+
2242
+ /*
2243
+ Method: Image#composite_channel(src_image, geometry, composite_operator[, channel...])
2244
+ Image#composite_channel!(src_image, geometry, composite_operator[, channel...])
2245
+ Purpose: Call CompositeImageChannel
2246
+ */
2247
+ static VALUE
2248
+ composite_channel(int bang, int argc, VALUE *argv, VALUE self)
2249
+ {
2250
+ #if defined(HAVE_COMPOSITEIMAGECHANNEL)
2251
+ ChannelType channels;
2252
+
2253
+ channels = extract_channels(&argc, argv);
2254
+
2255
+ // There must be 3, 4, or 5 remaining arguments.
2256
+ if (argc < 3)
2257
+ {
2258
+ rb_raise(rb_eArgError, "composite operator not specified");
2259
+ }
2260
+ else if (argc > 5)
2261
+ {
2262
+ raise_ChannelType_error(argv[argc-1]);
2263
+ }
2264
+
2265
+ return composite(bang, argc, argv, self, channels);
2266
+
2267
+ #else
2268
+ rm_not_implemented();
2269
+ return (VALUE)0;
2270
+ #endif
2271
+ }
2272
+
2273
+ VALUE Image_composite_channel(int argc, VALUE *argv, VALUE self)
2274
+ {
2275
+ return composite_channel(False, argc, argv, self);
2276
+ }
2277
+
2278
+
2279
+ VALUE Image_composite_channel_bang(int argc, VALUE *argv, VALUE self)
2280
+ {
2281
+ return composite_channel(True, argc, argv, self);
2282
+ }
2283
+
2284
+
2001
2285
  /*
2002
2286
  Method: Image#compression
2003
2287
  Image#compression=
@@ -2156,13 +2440,9 @@ Image_constitute(VALUE class, VALUE width_arg, VALUE height_arg
2156
2440
  {
2157
2441
  rb_raise(rb_eNoMemError, "not enough memory to continue.");
2158
2442
  }
2159
- image->columns = width;
2160
- image->rows = height;
2161
- #if defined(HAVE_SETIMAGEBACKGROUNDCOLOR)
2443
+ SetImageExtent(image, width, height);
2162
2444
  SetImageBackgroundColor(image);
2163
- #else
2164
- SetImage(image, OpaqueOpacity);
2165
- #endif
2445
+
2166
2446
  (void) ImportImagePixels(image, 0, 0, width, height, map, stg_type, (void *)pixels.v);
2167
2447
  rm_check_image_exception(image, DestroyOnError);
2168
2448
  #else
@@ -2421,6 +2701,7 @@ Image_init_copy(VALUE copy, VALUE orig)
2421
2701
  return copy;
2422
2702
  }
2423
2703
 
2704
+
2424
2705
  /*
2425
2706
  Method: Image#crop(x, y, width, height)
2426
2707
  Image#crop(gravity, width, height)
@@ -2656,7 +2937,7 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
2656
2937
  StorageType stg_type = FIX_STG_TYPE;
2657
2938
  char *map;
2658
2939
  long mapL;
2659
- boolean okay;
2940
+ MagickBooleanType okay;
2660
2941
  ExceptionInfo exception;
2661
2942
  union
2662
2943
  {
@@ -3128,11 +3409,7 @@ Image_erase_bang(VALUE self)
3128
3409
  rm_check_frozen(self);
3129
3410
  Data_Get_Struct(self, Image, image);
3130
3411
 
3131
- #if defined(HAVE_SETIMAGEBACKGROUNDCOLOR)
3132
3412
  SetImageBackgroundColor(image);
3133
- #else
3134
- SetImage(image, OpaqueOpacity);
3135
- #endif
3136
3413
 
3137
3414
  rm_check_image_exception(image, RetainOnError);
3138
3415
 
@@ -5287,10 +5564,10 @@ Image_initialize(VALUE self, VALUE info_obj, VALUE width, VALUE height, VALUE fi
5287
5564
  {
5288
5565
  Image *image;
5289
5566
  Info *info;
5290
- int cols, rows;
5567
+ unsigned long cols, rows;
5291
5568
 
5292
- cols = NUM2INT(width);
5293
- rows = NUM2INT(height);
5569
+ cols = NUM2ULONG(width);
5570
+ rows = NUM2ULONG(height);
5294
5571
 
5295
5572
  if (cols <= 0 || rows <= 0)
5296
5573
  {
@@ -5299,19 +5576,15 @@ Image_initialize(VALUE self, VALUE info_obj, VALUE width, VALUE height, VALUE fi
5299
5576
 
5300
5577
  Data_Get_Struct(info_obj, Info, info);
5301
5578
  Data_Get_Struct(self, Image, image);
5302
- image->columns = cols;
5303
- image->rows = rows;
5579
+
5580
+ SetImageExtent(image, cols, rows);
5304
5581
 
5305
5582
  // If the caller did not supply a fill argument, call SetImage to fill the
5306
5583
  // image using the background color. The background color can be set by
5307
5584
  // specifying it when creating the Info parm block.
5308
5585
  if (!fill)
5309
5586
  {
5310
- #if defined(HAVE_SETIMAGEBACKGROUNDCOLOR)
5311
5587
  SetImageBackgroundColor(image);
5312
- #else
5313
- SetImage(image, OpaqueOpacity);
5314
- #endif
5315
5588
  }
5316
5589
  // fillobj.fill(self)
5317
5590
  else
@@ -5352,15 +5625,15 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
5352
5625
  Info *info;
5353
5626
  volatile VALUE info_obj;
5354
5627
  Image *image;
5355
- int cols, rows;
5628
+ unsigned long cols, rows;
5356
5629
 
5357
5630
  switch (argc)
5358
5631
  {
5359
5632
  case 3:
5360
5633
  fill = argv[2];
5361
5634
  case 2:
5362
- rows = NUM2INT(argv[1]);
5363
- cols = NUM2INT(argv[0]);
5635
+ rows = NUM2ULONG(argv[1]);
5636
+ cols = NUM2ULONG(argv[0]);
5364
5637
  break;
5365
5638
  default:
5366
5639
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
@@ -5380,15 +5653,14 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
5380
5653
  // NOW store a real image in the image object.
5381
5654
  DATA_PTR(self) = image;
5382
5655
 
5383
- image->columns = cols;
5384
- image->rows = rows;
5656
+ SetImageExtent(image, cols, rows);
5385
5657
 
5386
5658
  // If the caller did not supply a fill argument, call SetImage to fill the
5387
5659
  // image using the background color. The background color can be set by
5388
5660
  // specifying it when creating the Info parm block.
5389
5661
  if (!fill)
5390
5662
  {
5391
- SetImage(image, OpaqueOpacity);
5663
+ SetImageBackgroundColor(image);
5392
5664
  }
5393
5665
  // fillobj.fill(self)
5394
5666
  else
@@ -5639,6 +5911,7 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
5639
5911
  return rm_image_new(new_image);
5640
5912
  }
5641
5913
 
5914
+
5642
5915
  /*
5643
5916
  Method: Image#orientation
5644
5917
  Purpose: Return the orientation attribute as an OrientationType enum value.
@@ -5657,6 +5930,29 @@ Image_orientation(VALUE self)
5657
5930
  #endif
5658
5931
  }
5659
5932
 
5933
+
5934
+ /*
5935
+ Method: Image#orientation=
5936
+ Purpose: Set the orientation attribute
5937
+ */
5938
+ VALUE
5939
+ Image_orientation_eq(VALUE self, VALUE orientation)
5940
+ {
5941
+ #if defined(HAVE_IMAGE_ORIENTATION)
5942
+ Image *image;
5943
+
5944
+ rm_check_frozen(self);
5945
+ Data_Get_Struct(self, Image, image);
5946
+ VALUE_TO_ENUM(orientation, image->orientation, OrientationType);
5947
+ return self;
5948
+
5949
+ #else
5950
+ rm_not_implemented();
5951
+ return (VALUE)0;
5952
+ #endif
5953
+ }
5954
+
5955
+
5660
5956
  /*
5661
5957
  Method: Image#page
5662
5958
  Purpose: the page attribute getter
@@ -6248,6 +6544,51 @@ Image_radial_blur(VALUE self, VALUE angle)
6248
6544
  #endif
6249
6545
  }
6250
6546
 
6547
+ /*
6548
+ Method: Image#radial_blur_channel(angle[, channel..])
6549
+ Purpose: Call RadialBlurImageChannel
6550
+ Notes: Angle is in degrees
6551
+ */
6552
+ VALUE
6553
+ Image_radial_blur_channel(
6554
+ int argc,
6555
+ VALUE *argv,
6556
+ VALUE self)
6557
+ {
6558
+ #if defined(HAVE_RADIALBLURIMAGECHANNEL)
6559
+ Image *image, *new_image;
6560
+ ExceptionInfo exception;
6561
+ ChannelType channels;
6562
+
6563
+ channels = extract_channels(&argc, argv);
6564
+
6565
+ // There must be 1 remaining argument.
6566
+ if (argc == 0)
6567
+ {
6568
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)");
6569
+ }
6570
+ else if (argc > 1)
6571
+ {
6572
+ raise_ChannelType_error(argv[argc-1]);
6573
+ }
6574
+
6575
+ Data_Get_Struct(self, Image, image);
6576
+ GetExceptionInfo(&exception);
6577
+
6578
+ new_image = RadialBlurImageChannel(image, channels, NUM2DBL(argv[0]), &exception);
6579
+
6580
+ rm_check_exception(&exception, new_image, DestroyOnError);
6581
+ DestroyExceptionInfo(&exception);
6582
+ rm_ensure_result(new_image);
6583
+
6584
+ return rm_image_new(new_image);
6585
+
6586
+ #else
6587
+ rm_not_implemented();
6588
+ return (VALUE)0;
6589
+ #endif
6590
+ }
6591
+
6251
6592
 
6252
6593
  /*
6253
6594
  Method: Image#random_channel_threshold
@@ -6451,7 +6792,7 @@ rd_image(VALUE class, VALUE file, reader_t reader)
6451
6792
  // Ensure file is open - raise error if not
6452
6793
  GetOpenFile(file, fptr);
6453
6794
  rb_io_check_readable(fptr);
6454
- info->file = GetReadFile(fptr);
6795
+ SetImageInfoFile(info, GetReadFile(fptr));
6455
6796
  }
6456
6797
  else
6457
6798
  {
@@ -6462,7 +6803,7 @@ rd_image(VALUE class, VALUE file, reader_t reader)
6462
6803
  filename_l = min(filename_l, MaxTextExtent-1);
6463
6804
  memcpy(info->filename, filename, (size_t)filename_l);
6464
6805
  info->filename[filename_l] = '\0';
6465
- info->file = NULL; // Reset FILE *, if any
6806
+ SetImageInfoFile(info, NULL);
6466
6807
  }
6467
6808
 
6468
6809
  GetExceptionInfo(&exception);
@@ -7704,7 +8045,11 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
7704
8045
  QuantizeImage(&qinfo, image);
7705
8046
  }
7706
8047
 
8048
+ #if defined(HAVE_SETIMAGESTORAGECLASS)
8049
+ SetImageStorageClass(image, class_type);
8050
+ #else
7707
8051
  image->storage_class = class_type;
8052
+ #endif
7708
8053
  return self;
7709
8054
  }
7710
8055
 
@@ -8366,11 +8711,70 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
8366
8711
  }
8367
8712
 
8368
8713
 
8714
+ /*
8715
+ * Method: Image#transpose
8716
+ * Image#transpose!
8717
+ * Purpose: Call TransposeImage
8718
+ */
8719
+ VALUE
8720
+ Image_transpose(VALUE self)
8721
+ {
8722
+ #if defined(HAVE_TRANSPOSEIMAGE)
8723
+ return crisscross(False, self, TransposeImage);
8724
+ #else
8725
+ rm_not_implemented();
8726
+ return (VALUE)0;
8727
+ #endif
8728
+ }
8729
+
8730
+
8731
+ VALUE
8732
+ Image_transpose_bang(VALUE self)
8733
+ {
8734
+ #if defined(HAVE_TRANSPOSEIMAGE)
8735
+ rm_check_frozen(self);
8736
+ return crisscross(True, self, TransposeImage);
8737
+ #else
8738
+ rm_not_implemented();
8739
+ return (VALUE)0;
8740
+ #endif
8741
+ }
8742
+
8743
+
8744
+ /*
8745
+ * Method: Image#transverse
8746
+ * Image#transverse!
8747
+ * Purpose: Call TransverseImage
8748
+ */
8749
+ VALUE
8750
+ Image_transverse(VALUE self)
8751
+ {
8752
+ #if defined(HAVE_TRANSVERSEIMAGE)
8753
+ return crisscross(False, self, TransverseImage);
8754
+ #else
8755
+ rm_not_implemented();
8756
+ return (VALUE)0;
8757
+ #endif
8758
+ }
8759
+
8760
+ VALUE
8761
+ Image_transverse_bang(VALUE self)
8762
+ {
8763
+ #if defined(HAVE_TRANSVERSEIMAGE)
8764
+ rm_check_frozen(self);
8765
+ return crisscross(True, self, TransverseImage);
8766
+ #else
8767
+ rm_not_implemented();
8768
+ return (VALUE)0;
8769
+ #endif
8770
+ }
8771
+
8772
+
8369
8773
  /*
8370
8774
  * Method: Image#trim, Image#trim!
8371
8775
  * Purpose: convenience front-end to CropImage
8372
8776
  * Notes: respects fuzz attribute
8373
- */
8777
+ */
8374
8778
 
8375
8779
  static VALUE
8376
8780
  trimmer(int bang, VALUE self)
@@ -8778,7 +9182,7 @@ Image_write(VALUE self, VALUE file)
8778
9182
  // Ensure file is open - raise error if not
8779
9183
  GetOpenFile(file, fptr);
8780
9184
  rb_io_check_writable(fptr);
8781
- info->file = GetWriteFile(fptr);
9185
+ SetImageInfoFile(info, GetWriteFile(fptr));
8782
9186
  }
8783
9187
  else
8784
9188
  {
@@ -8804,7 +9208,7 @@ Image_write(VALUE self, VALUE file)
8804
9208
  {
8805
9209
  return Qnil;
8806
9210
  }
8807
- info->file = NULL;
9211
+ SetImageInfoFile(info, NULL);
8808
9212
  }
8809
9213
 
8810
9214
  info->adjoin = False;