Method: Magick::Image#units=
- Defined in:
- ext/RMagick/rmimage.cpp
#units=(restype) ⇒ Magick::ResolutionType
Set the units of image resolution.
15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 |
# File 'ext/RMagick/rmimage.cpp', line 15158
VALUE
Image_units_eq(VALUE self, VALUE restype)
{
ResolutionType units;
Image *image = rm_check_frozen(self);
VALUE_TO_ENUM(restype, units, ResolutionType);
if (image->units != units)
{
switch (image->units)
{
case PixelsPerInchResolution:
if (units == PixelsPerCentimeterResolution)
{
#if defined(IMAGEMAGICK_7)
image->resolution.x /= 2.54;
image->resolution.y /= 2.54;
#else
image->x_resolution /= 2.54;
image->y_resolution /= 2.54;
#endif
}
break;
case PixelsPerCentimeterResolution:
if (units == PixelsPerInchResolution)
{
#if defined(IMAGEMAGICK_7)
image->resolution.x *= 2.54;
image->resolution.y *= 2.54;
#else
image->x_resolution *= 2.54;
image->y_resolution *= 2.54;
#endif
}
break;
default:
// UndefinedResolution
#if defined(IMAGEMAGICK_7)
image->resolution.x = 0.0;
image->resolution.y = 0.0;
#else
image->x_resolution = 0.0;
image->y_resolution = 0.0;
#endif
break;
}
image->units = units;
}
return restype;
}
|