Sha256: 12b93e9a26d3b989dfb8914e27a51e329e02ea3b07af26431721f8ed1a9ba7a7

Contents?: true

Size: 750 Bytes

Versions: 11

Compression:

Stored size: 750 Bytes

Contents

#include "psd_native_ext.h"

VALUE psd_native_cmyk_to_rgb(VALUE self, VALUE c, VALUE m, VALUE y, VALUE k) {
  int r, g, b;

  r = psd_clamp_int((65535 - (FIX2INT(c) * (255 - FIX2INT(k)) + (FIX2INT(k) << 8))) >> 8, 0, 255);
  g = psd_clamp_int((65535 - (FIX2INT(m) * (255 - FIX2INT(k)) + (FIX2INT(k) << 8))) >> 8, 0, 255);
  b = psd_clamp_int((65535 - (FIX2INT(y) * (255 - FIX2INT(k)) + (FIX2INT(k) << 8))) >> 8, 0, 255);

  VALUE result = rb_hash_new();
  rb_hash_aset(result, ID2SYM(rb_intern("r")), INT2FIX(r));
  rb_hash_aset(result, ID2SYM(rb_intern("g")), INT2FIX(g));
  rb_hash_aset(result, ID2SYM(rb_intern("b")), INT2FIX(b));

  return result;
}

int psd_clamp_int(int n, int low, int high) {
  return n < low ? low : (n > high ? high : n);
}

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
bench9000-0.1 vendor/psd_native/ext/psd_native/color.c
psd_native-1.1.3 ext/psd_native/color.c
psd_native-1.1.2 ext/psd_native/color.c
psd_native-1.1.1 ext/psd_native/color.c
psd_native-1.1.0 ext/psd_native/color.c
psd_native-1.0.1 ext/psd_native/color.c
psd_native-1.0.0 ext/psd_native/color.c
psd_native-0.6.0 ext/psd_native/color.c
psd_native-0.5.0 ext/psd_native/color.c
psd_native-0.3.1 ext/psd_native/color.c
psd_native-0.3.0 ext/psd_native/color.c