Sha256: f8ac36cbe923cd6e5188ac06f25fd9babaec9b5c9d6dba8fc08170d4f8863328

Contents?: true

Size: 1003 Bytes

Versions: 2

Compression:

Stored size: 1003 Bytes

Contents

#include "oily_png_ext.h"

// Initialize the extension by creating the OilyPNG modules.
void Init_oily_png_ext() {
  VALUE OilyPNG = rb_define_module("OilyPNG");

  // Setup decoding
  VALUE OilyPNG_PNGDecoding = rb_define_module_under(OilyPNG, "PNGDecoding");
  rb_define_method(OilyPNG_PNGDecoding, "decode_png_image_pass", oily_png_decode_png_image_pass, 5);
  
  // Setup encoding
  VALUE OilyPNG_PNGEncoding = rb_define_module_under(OilyPNG, "PNGEncoding");
  rb_define_method(OilyPNG_PNGEncoding, "encode_png_image_pass_to_stream", oily_png_encode_png_image_pass_to_stream, 3);
}

// Returns the number of bytes per pixel for a given color mode.
int oily_png_pixel_size(int color_mode) {
  switch (color_mode) {
    case OILY_PNG_COLOR_GRAYSCALE:       return 1;
    case OILY_PNG_COLOR_TRUECOLOR:       return 3;
    case OILY_PNG_COLOR_INDEXED:         return 1;
    case OILY_PNG_COLOR_GRAYSCALE_ALPHA: return 2;
    case OILY_PNG_COLOR_TRUECOLOR_ALPHA: return 4;
    default: return -1;
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oily_png-0.0.5 ext/oily_png/oily_png_ext.c
oily_png-0.0.4 ext/oily_png/oily_png_ext.c