gemhome/rmagick — pull request #125 by u338steven (2014-09-20 08:29:39+00:00)
Title: Fixed #83: test_import_export(Import_Export_UT) in Import_Export.rb fails

If you use HDRI enabled ImageMagick, this ArgumentError occurs.
```
test_import_export(Import_Export_UT):
ArgumentError: pixel buffer too small (need 150000 channel values, got 75000)
/home/linduxed/Documents/ruby/rmagick/test/Import_Export.rb:14:in `import_pixels'
/home/linduxed/Documents/ruby/rmagick/test/Import_Export.rb:14:in `import_pixels'
/home/linduxed/Documents/ruby/rmagick/test/Import_Export.rb:21:in `import'
/home/linduxed/Documents/ruby/rmagick/test/Import_Export.rb:67:in `test_import_export'
```

/home/linduxed/Documents/ruby/rmagick/test/[Import_Export.rb:67](https://github.com/gemhome/rmagick/blob/master/test/Import_Export.rb#L67):in `test_import_export':
```ruby
import(p, Magick::QuantumPixel)
```

[rmimage.c L7207-](https://github.com/gemhome/rmagick/blob/master/ext/RMagick/rmimage.c#L7207):in `Image_import_pixels':
```c
case QuantumPixel:
type_sz = sizeof(Quantum);
...
if ((unsigned long)(buffer_l / type_sz) < npixels)
{
rb_raise(rb_eArgError, "pixel buffer too small (need %lu channel values, got %ld)"
, npixels, buffer_l/type_sz);
}
```

if MAGICKCORE_QUANTUM_DEPTH = 16,
Quantum type is:
- HDRI support: float(4 bytes)
- else: short(2 bytes)

```c
#if defined(MAGICKCORE_HDRI_SUPPORT)
typedef float Quantum;
...
#else
typedef unsigned short Quantum;
...
#endif
```
#### Magick::Magick_features
From the above, we need to know ImageMagick support HDRI or not from RMagick.
But RMagick could not judge it, so I added Magick::Magick_features.

Magick::Magick_features result:
```ruby
[2] pry(main)> p Magick::Magick_features
"DPC HDRI Modules OpenMP"
=> "DPC HDRI Modules OpenMP"
```
Magick::Magick_features(features_constant) is similar to Magick::Magick_version([version_constants](https://github.com/gemhome/rmagick/blob/master/ext/RMagick/rmmain.c#L1676-L1686)).

#### Similarly
if MAGICKCORE_QUANTUM_DEPTH = 8
```c
#if defined(MAGICKCORE_HDRI_SUPPORT)
typedef float Quantum;
...
#else
typedef unsigned char Quantum;
...
#endif
```
- HDRI support: float
- else: char

if MAGICKCORE_QUANTUM_DEPTH = 32
```c
#if defined(MAGICKCORE_HDRI_SUPPORT)
typedef double Quantum;
...
#else
typedef unsigned int Quantum;
...
#endif
```
- HDRI support: double
- else: int

#### Dissimilarly
if MAGICKCORE_QUANTUM_DEPTH = 64
```c
typedef long double Quantum;
```
- HDRI: long double
- not HDRI: long double

#### MagickSupport constant
[version.h](http://trac.imagemagick.org/browser/ImageMagick/branches/ImageMagick-6.5.6/magick/version.h#L54)
```c
#if !defined(MAGICKCORE_HDRI_SUPPORT)
#define MagickHDRISupport ""
#else
#define MagickHDRISupport "HDRI "
#endif
#if !defined(_OPENMP)
#define MagickOPENMPSupport ""
#else
#define MagickOPENMPSupport "OpenMP "
#endif
#define MagickSupport MagickHDRISupport MagickOPENMPSupport

#define MagickVersion MagickPackageName " " MagickLibVersionText \
MagickLibSubversion " " MagickReleaseDate " " MagickQuantumDepth " " \
MagickSupport MagickAuthoritativeURL
```