rmagick 7.1.7 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -307,16 +307,17 @@ rm_check_ary_type(VALUE ary)
307
307
 
308
308
 
309
309
  /**
310
- * Raise an error if the image has been destroyed.
310
+ * Raise an error if the image has been destroyed or an offloaded call is changing it.
311
311
  *
312
312
  * No Ruby usage (internal function)
313
313
  *
314
314
  * @param obj the image
315
315
  * @return the C image structure for the image
316
316
  * @throw DestroyedImageError
317
+ * @throw RuntimeError if an offloaded call is changing the image
317
318
  */
318
319
  Image *
319
- rm_check_destroyed(VALUE obj)
320
+ rm_check_readable(VALUE obj)
320
321
  {
321
322
  Image *image;
322
323
 
@@ -325,13 +326,33 @@ rm_check_destroyed(VALUE obj)
325
326
  {
326
327
  rb_raise(Class_DestroyedImageError, "destroyed image");
327
328
  }
329
+ rm_gvl_check_readable(image);
328
330
 
329
331
  return image;
330
332
  }
331
333
 
332
334
 
333
335
  /**
334
- * Raise an error if the image has been destroyed or is frozen.
336
+ * Raise an error if the image has been destroyed or an offloaded call is using it.
337
+ *
338
+ * No Ruby usage (internal function)
339
+ *
340
+ * @param obj the image
341
+ * @return the C image structure for the image
342
+ * @throw DestroyedImageError
343
+ * @throw RuntimeError if an offloaded call is using the image
344
+ */
345
+ Image *
346
+ rm_check_writable(VALUE obj)
347
+ {
348
+ Image *image = rm_check_readable(obj);
349
+ rm_gvl_check_writable(image);
350
+ return image;
351
+ }
352
+
353
+
354
+ /**
355
+ * Raise an error if the image has been destroyed, is frozen or an offloaded call is using it.
335
356
  *
336
357
  * No Ruby usage (internal function)
337
358
  *
@@ -341,8 +362,15 @@ rm_check_destroyed(VALUE obj)
341
362
  Image *
342
363
  rm_check_frozen(VALUE obj)
343
364
  {
344
- Image *image = rm_check_destroyed(obj);
365
+ Image *image;
366
+
367
+ TypedData_Get_Struct(obj, Image, &rm_image_data_type, image);
368
+ if (!image)
369
+ {
370
+ rb_raise(Class_DestroyedImageError, "destroyed image");
371
+ }
345
372
  rb_check_frozen(obj);
373
+ rm_gvl_check_writable(image);
346
374
  return image;
347
375
  }
348
376
 
@@ -598,7 +626,8 @@ rm_fuzz_to_dbl(VALUE fuzz_arg)
598
626
 
599
627
  /**
600
628
  * Convert an application-supplied number to a Quantum. If the object is a Float,
601
- * truncate it before converting.
629
+ * truncate it before converting. A value outside 0 to QuantumRange is clamped
630
+ * as ClampToQuantum does, so it is kept as is with HDRI.
602
631
  *
603
632
  * No Ruby usage (internal function)
604
633
  *
@@ -615,13 +644,32 @@ Quantum
615
644
  rm_app2quantum(VALUE obj)
616
645
  {
617
646
  VALUE v = obj;
647
+ MagickRealType value;
618
648
 
619
649
  if (TYPE(obj) == T_FLOAT)
620
650
  {
621
651
  v = rb_Integer(obj);
622
652
  }
653
+ v = rb_to_int(v);
654
+
655
+ if (RTEST(rb_funcall(v, rb_intern("negative?"), 0)))
656
+ {
657
+ #if MAGICKCORE_QUANTUM_DEPTH == 64
658
+ value = (MagickRealType) NUM2LL(v);
659
+ #else
660
+ value = (MagickRealType) NUM2INT(v);
661
+ #endif
662
+ }
663
+ else
664
+ {
665
+ #if MAGICKCORE_QUANTUM_DEPTH == 64
666
+ value = (MagickRealType) NUM2ULL(v);
667
+ #else
668
+ value = (MagickRealType) NUM2UINT(v);
669
+ #endif
670
+ }
623
671
 
624
- return NUM2QUANTUM(v);
672
+ return ClampToQuantum(value);
625
673
  }
626
674
 
627
675
 
@@ -1136,13 +1184,13 @@ void rm_sync_image_options(Image *image, Info *info)
1136
1184
  {
1137
1185
  #if defined(IMAGEMAGICK_7)
1138
1186
  exception = AcquireExceptionInfo();
1139
- GVL_STRUCT_TYPE(TransformImageColorspace) args = { image, info->colorspace, exception };
1140
- CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransformImageColorspace), &args);
1187
+ DECLARE_GVL_CALL(call, TransformImageColorspace, image, info->colorspace, exception);
1188
+ call.keep_thread().run<void>();
1141
1189
  CHECK_EXCEPTION();
1142
1190
  DestroyExceptionInfo(exception);
1143
1191
  #else
1144
- GVL_STRUCT_TYPE(TransformImageColorspace) args = { image, info->colorspace };
1145
- CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransformImageColorspace), &args);
1192
+ DECLARE_GVL_CALL(call, TransformImageColorspace, image, info->colorspace);
1193
+ call.keep_thread().run<void>();
1146
1194
  rm_check_image_exception(image, RetainOnError);
1147
1195
  #endif
1148
1196
  }
@@ -1561,8 +1609,8 @@ rm_clone_image(Image *image)
1561
1609
  ExceptionInfo *exception;
1562
1610
 
1563
1611
  exception = AcquireExceptionInfo();
1564
- GVL_STRUCT_TYPE(CloneImage) args = { image, 0, 0, MagickTrue, exception };
1565
- clone = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CloneImage), &args);
1612
+ DECLARE_GVL_CALL(call, CloneImage, image, 0, 0, MagickTrue, exception);
1613
+ clone = call.keep_thread().run<Image *>();
1566
1614
  if (!clone)
1567
1615
  {
1568
1616
  rb_raise(rb_eNoMemError, "not enough memory to continue");
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Magick
4
- VERSION = '7.1.7'
4
+ VERSION = '7.2.0'
5
5
  MIN_RUBY_VERSION = '3.2.0'
6
6
  MIN_IM6_VERSION = '6.9.0'
7
7
  MIN_IM7_VERSION = '7.1.0'
@@ -1845,14 +1845,25 @@ module Magick
1845
1845
 
1846
1846
  # accepts Pixel object or color name
1847
1847
  def highlight_color=(color)
1848
- color = @img.to_color(color) if color.respond_to?(:to_color)
1849
- @img.define('highlight-color', color)
1848
+ define_compare_color('highlight-color', color)
1850
1849
  end
1851
1850
 
1852
1851
  # accepts Pixel object or color name
1853
1852
  def lowlight_color=(color)
1854
- color = @img.to_color(color) if color.respond_to?(:to_color)
1855
- @img.define('lowlight-color', color)
1853
+ define_compare_color('lowlight-color', color)
1854
+ end
1855
+
1856
+ private
1857
+
1858
+ def define_compare_color(name, color)
1859
+ color = if color.is_a?(Magick::Pixel)
1860
+ color.to_color(Magick::AllCompliance, true)
1861
+ else
1862
+ String.try_convert(color) || raise(TypeError, "argument must be color name or pixel (#{color.class} given)")
1863
+ end
1864
+ @img.define("compare:#{name}", color)
1865
+ # ImageMagick 6.9.6-0 and older read the name without the "compare:" prefix.
1866
+ @img.define(name, color)
1856
1867
  end
1857
1868
  end
1858
1869
 
data/lib/rvg/rvg.rb CHANGED
@@ -36,7 +36,7 @@ module Magick
36
36
  # else, combine it with the background_fill_opacity.
37
37
  def bgfill
38
38
  if @background_fill.nil?
39
- color = Magick::Pixel.new(0, 0, 0, Magick::OpaqueAlpha)
39
+ color = Magick::Pixel.from_color('none')
40
40
  else
41
41
  color = @background_fill
42
42
  color.alpha = @background_fill_opacity * Magick::OpaqueAlpha
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.7
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Hunter
@@ -58,7 +58,9 @@ files:
58
58
  - ext/RMagick/extconf.rb
59
59
  - ext/RMagick/rmagick.cpp
60
60
  - ext/RMagick/rmagick.h
61
+ - ext/RMagick/rmagick_gvl.cpp
61
62
  - ext/RMagick/rmagick_gvl.h
63
+ - ext/RMagick/rmagick_gvl.hpp
62
64
  - ext/RMagick/rmdraw.cpp
63
65
  - ext/RMagick/rmenum.cpp
64
66
  - ext/RMagick/rmfill.cpp