Module: Magick
- Defined in:
- lib/RMagick.rb,
ext/RMagick/rmmain.c
Defined Under Namespace
Classes: Draw, Enum, Geometry, GeometryValue, GradientFill, HatchFill, Image, ImageList, ImageMagickError, Pixel, TextureFill
Constant Summary collapse
- PercentGeometry =
GeometryValue.new(:PercentGeometry, 1)
- AspectGeometry =
GeometryValue.new(:AspectGeometry, 2)
- LessGeometry =
GeometryValue.new(:LessGeometry, 3)
- GreaterGeometry =
GeometryValue.new(:GreaterGeometry, 4)
- AreaGeometry =
GeometryValue.new(:AreaGeometry, 5)
- MaxRGB =
Miscellaneous constants
INT2FIX(MaxRGB)
- QuantumDepth =
INT2FIX(QuantumDepth)
- AffineMatrix =
Class_AffineMatrix
- Statistics =
Class_Statistics
- Primary =
Class_Primary
- Chromaticity =
Class_Chromaticity
- Color =
Class_Color
- Point =
Class_Point
- Rectangle =
Class_Rectangle
- Segment =
Class_Segment
- Font =
Class_Font
- TypeMetric =
Class_TypeMetric
- Magick_version =
rb_str_new2(mgk_version)
- Version =
rb_str_new2(PACKAGE_STRING)
- Long_version =
rb_str_new2(long_version)
- @@formats =
nil
Class Method Summary collapse
-
.colors ⇒ Object
Method: Magick::colors [ { |colorinfo| } ] Purpose: If called with the optional block, iterates over the colors, otherwise returns an array of Magick::Color objects Notes: There are 3 implementations.
-
.fonts ⇒ Object
Method: Magick::fonts [ { |fontinfo| } ] Purpose: If called with the optional block, iterates over the fonts, otherwise returns an array of Magick::Font objects.
- .formats(&block) ⇒ Object
- .init_formats ⇒ Object
-
.set_cache_threshold(threshold) ⇒ Object
Method Magick.set_cache_threshold(megabytes) Purpose: sets the amount of free memory allocated for the pixel cache.
-
.set_log_event_mask(*args) ⇒ Object
Method: Magick.set_log_event_mask(event,…) -> Magick Notes: “event” is one of “all”, “annotate”, “blob”, “cache”, “coder”, “configure”, “deprecate”, “locale”, “none”, “render”, “transform”, “user”, “x11”.
-
.set_log_format(format) ⇒ Object
Method: Magick.set_log_format(format) -> Magick Notes: Format is a string containing one or more of: %t - current time %r - elapsed time %u - user time %p - pid %m - module (source file name) %f - function name %l - line number %d - event domain (one of the events listed above) %e - event name Plus other characters, including n, etc.
-
.set_monitor(monitor) ⇒ Object
Method: Magick.set_monitor(&monitor) Purpose: Establish MagickMonitor exit Notes: use nil argument to turn off monitoring.
Class Method Details
.colors ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'ext/RMagick/rmmain.c', line 32
VALUE
Magick_colors(VALUE class)
{
#if defined(HAVE_GETCOLORINFOARRAY) // GraphicsMagick
ColorInfo **color_ary;
ExceptionInfo exception;
volatile VALUE ary;
int x;
GetExceptionInfo(&exception);
color_ary = GetColorInfoArray(&exception);
HANDLE_ERROR
if (rb_block_given_p())
{
x = 0;
while(color_ary[x])
{
rb_yield(Color_from_ColorInfo(color_ary[x]));
x += 1;
}
magick_free(color_ary);
return class;
}
else
{
ary = rb_ary_new();
x = 0;
while (color_ary[x])
{
rb_ary_push(ary, Color_from_ColorInfo(color_ary[x]));
x += 1;
}
magick_free(color_ary);
return ary;
}
#elif defined(HAVE_GETCOLORINFOLIST) // ImageMagick 6.0.0
const ColorInfo **color_info_list;
unsigned long number_colors, x;
volatile VALUE ary;
#if defined(HAVE_OLD_GETCOLORINFOLIST)
color_info_list = GetColorInfoList("*", &number_colors);
#else
// IM 6.1.3 added an exception parm to GetColorInfoList
ExceptionInfo exception;
GetExceptionInfo(&exception);
color_info_list = GetColorInfoList("*", &number_colors, &exception);
HANDLE_ERROR
#endif
if (rb_block_given_p())
{
for(x = 0; x < number_colors; x++)
{
rb_yield(Color_from_ColorInfo(color_info_list[x]));
}
magick_free(color_info_list);
return class;
}
else
{
ary = rb_ary_new2((long) number_colors);
for(x = 0; x < number_colors; x++)
{
rb_ary_push(ary, Color_from_ColorInfo(color_info_list[x]));
}
magick_free(color_info_list);
return ary;
}
#else // ImageMagick < 6.0.0
const ColorInfo *color_list;
ColorInfo *color;
ExceptionInfo exception;
volatile VALUE ary, el;
GetExceptionInfo(&exception);
color_list = GetColorInfo("*", &exception);
DestroyExceptionInfo(&exception);
// The order of the colors list can change in mid-iteration,
// so the only way we can guarantee a single pass thru the list
// is to copy the elements into an array without returning to
// IM. So, we always create a Ruby array and either return it
// or iterate over it.
ary = rb_ary_new();
for (color = (ColorInfo *)color_list; color; color = color->next)
{
rb_ary_push(ary, Color_from_ColorInfo(color));
}
// If block, iterate over colors
if (rb_block_given_p())
{
while ((el = rb_ary_shift(ary)) != Qnil)
{
rb_yield(el);
}
return class;
}
else
{
return ary;
}
#endif
}
|
.fonts ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'ext/RMagick/rmmain.c', line 157
VALUE
Magick_fonts(VALUE class)
{
#if defined(HAVE_GETTYPEINFOLIST) // ImageMagick 6.0.0
const TypeInfo **type_info;
unsigned long number_types, x;
volatile VALUE ary;
#if defined(HAVE_OLD_GETTYPEINFOLIST)
type_info = GetTypeInfoList("*", &number_types);
#else
// IM 6.1.3 added an exception argument to GetTypeInfoList
ExceptionInfo exception;
GetExceptionInfo(&exception);
type_info = GetTypeInfoList("*", &number_types, &exception);
HANDLE_ERROR
#endif
if (rb_block_given_p())
{
for(x = 0; x < number_types; x++)
{
rb_yield(Font_from_TypeInfo((TypeInfo *)type_info[x]));
}
magick_free(type_info);
return class;
}
else
{
ary = rb_ary_new2(number_types);
for(x = 0; x < number_types; x++)
{
rb_ary_push(ary, Font_from_TypeInfo((TypeInfo *)type_info[x]));
}
magick_free(type_info);
return ary;
}
#else
const TypeInfo *type_list;
TypeInfo *type, *next;
ExceptionInfo exception;
volatile VALUE ary;
GetExceptionInfo(&exception);
type_list = GetTypeInfo("*", &exception);
HANDLE_ERROR
// If block, iterate over fonts
if (rb_block_given_p())
{
for (type = (TypeInfo *)type_list; type; type = next)
{
next = type->next; // Protect against recursive calls to GetTypeInfo
if (! type->stealth)
{
rb_yield(Font_from_TypeInfo(type));
}
}
return class;
}
else
{
ary = rb_ary_new();
for (type = (TypeInfo *)type_list; type; type = type->next)
{
rb_ary_push(ary, Font_from_TypeInfo(type));
}
return ary;
}
#endif
}
|
.formats(&block) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/RMagick.rb', line 16 def Magick.formats(&block) @@formats ||= Magick.init_formats if block_given? @@formats.each { |k,v| yield(k,v) } self else @@formats end end |
.init_formats ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'ext/RMagick/rmmain.c', line 266
VALUE
Magick_init_formats(VALUE class)
{
#if defined(HAVE_GETMAGICKINFOARRAY) // GraphicsMagick
MagickInfo *magick_info, *m;
volatile VALUE formats;
ExceptionInfo exception;
class = class; // defeat "never referenced" message from icc
formats = rb_hash_new();
GetExceptionInfo(&exception);
magick_info = (MagickInfo *)GetMagickInfoArray(&exception);
for(m = magick_info; m != NULL; m = m->next)
{
rb_hash_aset(formats, rb_str_new2(m->name), MagickInfo_to_format(m));
}
magick_free(magick_info);
return formats;
#elif defined(HAVE_GETMAGICKINFOLIST) // ImageMagick 6.0.0
const MagickInfo **magick_info;
unsigned long number_formats, x;
volatile VALUE formats;
#if !defined(HAVE_OLD_GETMAGICKINFOLIST)
ExceptionInfo exception;
#endif
class = class; // defeat "never referenced" message from icc
formats = rb_hash_new();
#if defined(HAVE_OLD_GETMAGICKINFOLIST)
magick_info = GetMagickInfoList("*", &number_formats);
#else
// IM 6.1.3 added an exception argument to GetMagickInfoList
GetExceptionInfo(&exception);
magick_info = GetMagickInfoList("*", &number_formats, &exception);
HANDLE_ERROR
#endif
for(x = 0; x < number_formats; x++)
{
rb_hash_aset(formats
, rb_str_new2(magick_info[x]->name)
, MagickInfo_to_format((MagickInfo *)magick_info[x]));
}
return formats;
#else
MagickInfo *m;
volatile VALUE formats;
ExceptionInfo exception;
class = class; // defeat "never referenced" message from icc
formats = rb_hash_new();
GetExceptionInfo(&exception);
m = (MagickInfo *)GetMagickInfo("*", &exception);
HANDLE_ERROR
for ( ; m != NULL; m = m->next)
{
rb_hash_aset(formats, rb_str_new2(m->name), MagickInfo_to_format(m));
}
return formats;
#endif
}
|
.set_cache_threshold(threshold) ⇒ Object
Method Magick.set_cache_threshold(megabytes) Purpose: sets the amount of free memory allocated for the
pixel cache. Once this threshold is exceeded, all
subsequent pixels cache operations are to/from disk.
Notes: singleton method
Pre-5.5.1 this method called the SetCacheThreshold
function, which is deprecated in 5.5.1.
420 421 422 423 424 425 426 427 |
# File 'ext/RMagick/rmmain.c', line 420
static VALUE
Magick_set_cache_threshold(VALUE class, VALUE threshold)
{
unsigned long thrshld = NUM2ULONG(threshold);
SetMagickResourceLimit(MemoryResource,thrshld);
SetMagickResourceLimit(MapResource,2*thrshld);
return class;
}
|
.set_log_event_mask(*args) ⇒ Object
Method: Magick.set_log_event_mask(event,…) -> Magick Notes: “event” is one of “all”, “annotate”, “blob”, “cache”,
"coder", "configure", "deprecate", "locale", "none",
"render", "transform", "user", "x11". Multiple events
can be specified. Event names may be capitalized.
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'ext/RMagick/rmmain.c', line 436
static VALUE
Magick_set_log_event_mask(int argc, VALUE *argv, VALUE class)
{
int x;
if (argc == 0)
{
rb_raise(rb_eArgError, "wrong number of arguments (at least 1 required)");
}
for (x = 0; x < argc; x++)
{
(void) SetLogEventMask(STRING_PTR(argv[x]));
}
return class;
}
|
.set_log_format(format) ⇒ Object
Method: Magick.set_log_format(format) -> Magick Notes: Format is a string containing one or more of:
%t - current time
%r - elapsed time
%u - user time
%p - pid
%m - module (source file name)
%f - function name
%l - line number
%d - event domain (one of the events listed above)
%e - event name
Plus other characters, including \n, etc.
466 467 468 469 470 471 472 473 474 475 476 |
# File 'ext/RMagick/rmmain.c', line 466
static VALUE
Magick_set_log_format(VALUE class, VALUE format)
{
#ifdef HAVE_SETLOGFORMAT
SetLogFormat(STRING_PTR(format));
return class;
#else
rm_not_implemented();
return (VALUE)0;
#endif
}
|
.set_monitor(monitor) ⇒ Object
Method: Magick.set_monitor(&monitor) Purpose: Establish MagickMonitor exit Notes: use nil argument to turn off monitoring
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'ext/RMagick/rmmain.c', line 379
static VALUE
Magick_set_monitor(VALUE class, VALUE monitor)
{
// 1st time: establish ID, define @@__MAGICK_MONITOR__
// class variable, stow monitor VALUE in it.
if (!Magick_Monitor)
{
Magick_Monitor = rb_intern(MAGICK_MONITOR_CVAR);
rb_define_class_variable(Module_Magick, MAGICK_MONITOR_CVAR, monitor);
ID_call = rb_intern("call");
}
// If nil, turn off monitoring.
if (monitor == Qnil)
{
(void) SetMonitorHandler(NULL);
}
else
// Otherwise, store monitor in @@__MAGICK_MONITOR__
{
// 1.8.0 deletes rb_cvar_declare and adds another
// parm to rb_cvar_set - if rb_cvar_declare is
// available, use the 3-parm version of rb_cvar_set.
RUBY18(rb_cvar_set(Module_Magick, Magick_Monitor, monitor, 0);)
RUBY16(rb_cvar_set(Module_Magick, Magick_Monitor, monitor);)
(void) SetMonitorHandler(&monitor_handler);
}
return class;
}
|