X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fruby%2Fgfx.c;h=648e902325a34573372c96d4fac6f2700e83fcbd;hb=6487933fe6b496bb04cd287b51b96af6b7d97058;hp=edca2e3278f2b0e7c87a9c839174eb70c7c577b7;hpb=c1e49c576e3589d84427f1d305cf226d720c2288;p=swftools.git diff --git a/lib/ruby/gfx.c b/lib/ruby/gfx.c index edca2e3..648e902 100644 --- a/lib/ruby/gfx.c +++ b/lib/ruby/gfx.c @@ -9,6 +9,7 @@ #include "../pdf/pdf.h" #include "../mem.h" #include "../types.h" +#include "../log.h" #define RUBY_GFX_VERSION "0.9.0" @@ -87,7 +88,7 @@ static VALUE doc_get_page(VALUE cls, VALUE _nr) page->doc = doc; if(!page->page) { rb_raise(rb_eArgError, "No page %d in document", nr); - return; + return Qnil; } return v; } @@ -220,6 +221,18 @@ static VALUE image_rescale(VALUE cls, VALUE _width, VALUE _height) } return v_image2; } +static VALUE image_has_alpha(VALUE cls) +{ + Get_Image(image,cls) + int size = image->image->width * image->image->height; + gfxcolor_t*data = image->image->data; + int t; + for(t=0;ta!=255) + return Qtrue; + } + return Qfalse; +} static VALUE image_save_jpeg(VALUE cls, VALUE _filename, VALUE quality) { Get_Image(image,cls) @@ -484,6 +497,10 @@ static VALUE convert_font(gfxfont_t*font) } return v2; } +static VALUE convert_gradient(gfxgradient_t*gradient) +{ + return Qnil; //TODO +} #define HEAD \ device_internal_t*i = (device_internal_t*)dev->internal; \ VALUE v = i->v; @@ -704,6 +721,7 @@ void Init_gfx() rb_define_method(Bitmap, "width", image_width, 0); rb_define_method(Bitmap, "height", image_height, 0); rb_define_method(Bitmap, "rescale", image_rescale, 2); + rb_define_method(Bitmap, "has_alpha", image_has_alpha, 0); Glyph = rb_define_class_under(GFX, "Glyph", rb_cObject); rb_define_method(Glyph, "polygon", glyph_polygon, 0);