ext/pdf417/pdf417.c
/*
 * call-seq:
 *  to_blob
 *
 * Returns a binary string representing the image bits, requires scaling before display
 */


Returns a binary string representing the image bits, requires scaling before display
Returns a binary string representing the image bits requires scaling before display
static VALUE rb_pdf417_lib_to_blob(VALUE self) {
  VALUE generation_options, text, aspect_ratio, raw_codewords, y_height, error_level, code_rows, code_cols;
  pdf417param *ptr;
  int options = 0;
  Data_Get_Struct(self, pdf417param, ptr);
  generation_options = rb_iv_get(self, "@generation_options");
  text = rb_iv_get(self, "@text"); 
  aspect_ratio = rb_iv_get(self, "@aspect_ratio");
  raw_codewords = rb_iv_get(self, "@raw_codewords");
  y_height = rb_iv_get(self, "@y_height");
  error_level = rb_iv_get(self, "@error_level");
  code_rows = rb_iv_get(self, "@code_rows");
  code_cols = rb_iv_get(self, "@code_cols");
  Check_Type(text, T_STRING);
  pdf417init(ptr);
  ptr->text = StringValuePtr(text);
  ptr->lenText = (int)RSTRING_LEN(text);
  if ( TYPE(generation_options) == T_FIXNUM ){
    ptr->options = FIX2INT(generation_options);
  }
  if ( TYPE(aspect_ratio) == T_FLOAT ){
    ptr->aspectRatio = (float)NUM2DBL(aspect_ratio);
  }
  if ( TYPE(y_height) == T_FLOAT ){
    ptr->yHeight = (float)NUM2DBL(y_height);
  }
  if ( TYPE(error_level) == T_FIXNUM ){
    ptr->errorLevel = FIX2INT(error_level);
  }
  if ( TYPE(code_rows) == T_FIXNUM ){    
    ptr->codeRows = FIX2INT(code_rows);
  }
  if ( TYPE(code_cols) == T_FIXNUM ){
    ptr->codeColumns = FIX2INT(code_cols);
  }
  if ( TYPE(raw_codewords) == T_ARRAY && ptr->options & PDF417_USE_RAW_CODEWORDS){
    ptr->lenCodewords = RARRAY_LEN(raw_codewords);
    int k;
    for (k = 0; k < ptr->lenCodewords; ++k) {
      ptr->codewords[k] = FIX2INT(rb_ary_entry(raw_codewords, k));
    }
  }
  paintCode(ptr); 
  if (ptr->error && ptr->error != PDF417_ERROR_SUCCESS) {
      return Qnil; 
  }
  return rb_str_new2(ptr->outBits);
}
static VALUE rb_pdf417_lib_to_blob ( VALUE self ) { VALUE generation_options , text , aspect_ratio , raw_codewords , y_height , error_level , code_rows , code_cols ; pdf417param * ptr ; int options = 0 ; Data_Get_Struct ( self , pdf417param , ptr ) ; generation_options = rb_iv_get ( self , " " ) ; text = rb_iv_get ( self , " " ) ; aspect_ratio = rb_iv_get ( self , " " ) ; raw_codewords = rb_iv_get ( self , " " ) ; y_height = rb_iv_get ( self , " " ) ; error_level = rb_iv_get ( self , " " ) ; code_rows = rb_iv_get ( self , " " ) ; code_cols = rb_iv_get ( self , " " ) ; Check_Type ( text , T_STRING ) ; pdf417init ( ptr ) ; ptr -> text = StringValuePtr ( text ) ; ptr -> lenText = ( int ) RSTRING_LEN ( text ) ; if ( TYPE ( generation_options ) == T_FIXNUM ) { ptr -> options = FIX2INT ( generation_options ) ; } if ( TYPE ( aspect_ratio ) == T_FLOAT ) { ptr -> aspectRatio = ( float ) NUM2DBL ( aspect_ratio ) ; } if ( TYPE ( y_height ) == T_FLOAT ) { ptr -> yHeight = ( float ) NUM2DBL ( y_height ) ; } if ( TYPE ( error_level ) == T_FIXNUM ) { ptr -> errorLevel = FIX2INT ( error_level ) ; } if ( TYPE ( code_rows ) == T_FIXNUM ) { ptr -> codeRows = FIX2INT ( code_rows ) ; } if ( TYPE ( code_cols ) == T_FIXNUM ) { ptr -> codeColumns = FIX2INT ( code_cols ) ; } if ( TYPE ( raw_codewords ) == T_ARRAY && ptr -> options & PDF417_USE_RAW_CODEWORDS ) { ptr -> lenCodewords = RARRAY_LEN ( raw_codewords ) ; int k ; for ( k = 0 ; k < ptr -> lenCodewords ; ++ k ) { ptr -> codewords [ k ] = FIX2INT ( rb_ary_entry ( raw_codewords , k ) ) ; } } paintCode ( ptr ) ; if ( ptr -> error && ptr -> error != PDF417_ERROR_SUCCESS ) { return Qnil ; } return rb_str_new2 ( ptr -> outBits ) ; }
call-seq:
  to_blob
call - seq : to_blob
// re-set our internal variables // Always set the text, can't really go wrong here // Start setting them based off of what we got //could also return list