Class: Cairo::ImageSurface
- Defined in:
- ext/cairo/rb_cairo_surface.c
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #format ⇒ Object
- #height ⇒ Object
- #initialize ⇒ Object constructor
- #stride ⇒ Object
- #width ⇒ Object
Methods inherited from Surface
#clone, #content, #copy_page, create, #create_similar, #create_similar_image, #destroy, #device, #device_offset, #device_scale, #dup, #fallback_resolution, #finish, #flush, #font_options, #get_mime_data, gl_supported?, gl_texture_supported?, image_supported?, #map_to_image, #mark_dirty, pdf_supported?, ps_supported?, quartz_image_supported?, quartz_supported?, recording_supported?, #reference_count, script_supported?, #set_device_offset, #set_device_scale, #set_fallback_resolution, #set_mime_data, #show_page, #sub_rectangle_surface, supported?, #supported_mime_type?, svg_supported?, tee_supported?, #unmap_image, win32_printing_supported?, win32_supported?, #write_to_png, xml_supported?
Constructor Details
#initialize ⇒ Object
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
# File 'ext/cairo/rb_cairo_surface.c', line 1030
static VALUE
cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
{
cairo_surface_t *surface;
VALUE arg1, arg2, arg3, arg4, arg5;
int n;
n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5);
if (n == 2)
surface = cr_image_surface_create (self, Qnil, arg1, arg2);
else if (n == 3)
surface = cr_image_surface_create (self, arg1, arg2, arg3);
else if (n == 5)
surface =
cr_image_surface_create_for_data (self, arg1, arg2, arg3, arg4, arg5);
else
rb_raise (rb_eArgError,
"invalid argument (expect "
"(width, height) or "
"(format, width, height) or "
"(data, format, width, height, stride)): %s",
rb_cairo__inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));
rb_cairo_surface_check_status (surface);
DATA_PTR (self) = surface;
rb_cairo_surface_adjust_memory_usage (surface, CR_TRUE);
if (rb_block_given_p ())
rb_cairo__surface_yield_and_finish (self);
return Qnil;
}
|
Class Method Details
.from_png ⇒ Object
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'ext/cairo/rb_cairo_surface.c', line 985
static VALUE
cr_image_surface_create_from_png_generic (VALUE klass, VALUE target)
{
VALUE rb_surface;
cairo_surface_t *surface;
if (rb_respond_to (target, rb_cairo__io_id_read))
surface = cr_image_surface_create_from_png_stream (target);
else
surface = cr_image_surface_create_from_png (target);
rb_cairo_surface_check_status (surface);
rb_surface = cr_surface_allocate (klass);
DATA_PTR (rb_surface) = surface;
return rb_surface;
}
|
Instance Method Details
#data ⇒ Object
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
# File 'ext/cairo/rb_cairo_surface.c', line 1062
static VALUE
cr_image_surface_get_data (VALUE self)
{
unsigned char *data;
cairo_surface_t *surface;
surface = _SELF;
data = cairo_image_surface_get_data (surface);
if (data)
return rb_str_new ((const char *)data,
cairo_image_surface_get_stride (surface) *
cairo_image_surface_get_height (surface));
else
return Qnil;
}
|
#format ⇒ Object
1079 1080 1081 1082 1083 |
# File 'ext/cairo/rb_cairo_surface.c', line 1079
static VALUE
cr_image_surface_get_format (VALUE self)
{
return INT2NUM (cairo_image_surface_get_format (_SELF));
}
|
#height ⇒ Object
1091 1092 1093 1094 1095 |
# File 'ext/cairo/rb_cairo_surface.c', line 1091
static VALUE
cr_image_surface_get_height (VALUE self)
{
return INT2NUM (cairo_image_surface_get_height (_SELF));
}
|
#stride ⇒ Object
1097 1098 1099 1100 1101 |
# File 'ext/cairo/rb_cairo_surface.c', line 1097
static VALUE
cr_image_surface_get_stride (VALUE self)
{
return INT2NUM (cairo_image_surface_get_stride (_SELF));
}
|
#width ⇒ Object
1085 1086 1087 1088 1089 |
# File 'ext/cairo/rb_cairo_surface.c', line 1085
static VALUE
cr_image_surface_get_width (VALUE self)
{
return INT2NUM (cairo_image_surface_get_width (_SELF));
}
|