ext/rfreeimage/rfi_main.c in rfreeimage-0.1.7 vs ext/rfreeimage/rfi_main.c in rfreeimage-0.1.8

- old
+ new

@@ -37,20 +37,20 @@ int stride; FREE_IMAGE_FORMAT fif; FIBITMAP *handle; }; -void Image_free(struct native_image* img) +static void Image_free(struct native_image* img) { if(!img) return; if(img->handle) FreeImage_Unload(img->handle); free(img); } -VALUE Image_alloc(VALUE self) +static VALUE Image_alloc(VALUE self) { /* allocate */ struct native_image* img = malloc(sizeof(struct native_image)); memset(img, 0, sizeof(struct native_image)); @@ -170,11 +170,11 @@ img->bpp = FreeImage_GetBPP(h); img->stride = FreeImage_GetPitch(h); img->fif = in_fif; } -VALUE Image_initialize(int argc, VALUE *argv, VALUE self) +static VALUE Image_initialize(int argc, VALUE *argv, VALUE self) { struct native_image* img; /* unwrap */ Data_Get_Struct(self, struct native_image, img); @@ -198,11 +198,11 @@ } #define RFI_CHECK_IMG(x) \ if (!img->handle) rb_raise(Class_RFIError, "Image pixels not loaded"); -VALUE Image_save(VALUE self, VALUE file) +static VALUE Image_save(VALUE self, VALUE file) { char *filename; struct native_image* img; BOOL result; FREE_IMAGE_FORMAT out_fif; @@ -232,11 +232,11 @@ if(!result) rb_raise(rb_eIOError, "Fail to save image"); return Qnil; } -VALUE Image_to_blob(VALUE self, VALUE type) +static VALUE Image_to_blob(VALUE self, VALUE type) { char *filetype; struct native_image* img; FIMEMORY *hmem; BOOL result; @@ -280,59 +280,59 @@ } -VALUE Image_cols(VALUE self) +static VALUE Image_cols(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); return INT2NUM(img->w); } -VALUE Image_rows(VALUE self) +static VALUE Image_rows(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); return INT2NUM(img->h); } -VALUE Image_bpp(VALUE self) +static VALUE Image_bpp(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); return INT2NUM(img->bpp); } -VALUE Image_stride(VALUE self) +static VALUE Image_stride(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); return INT2NUM(img->stride); } -VALUE Image_format(VALUE self) +static VALUE Image_format(VALUE self) { struct native_image* img; const char *p; Data_Get_Struct(self, struct native_image, img); p = FreeImage_GetFormatFromFIF(img->fif); return rb_str_new(p, strlen(p)); } -VALUE Image_release(VALUE self) +static VALUE Image_release(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); if (img->handle) FreeImage_Unload(img->handle); img->handle = NULL; return Qnil; } -VALUE Image_read_bytes(VALUE self) +static VALUE Image_read_bytes(VALUE self) { struct native_image* img; const char *p; char *ptr; unsigned stride_dst; @@ -353,22 +353,22 @@ p += img->stride; } return v; } -VALUE Image_buffer_addr(VALUE self) +static VALUE Image_buffer_addr(VALUE self) { struct native_image* img; const char *p; Data_Get_Struct(self, struct native_image, img); RFI_CHECK_IMG(img); p = (const char*)FreeImage_GetBits(img->handle); return ULONG2NUM((uintptr_t)p); } -VALUE Image_has_bytes(VALUE self) +static VALUE Image_has_bytes(VALUE self) { struct native_image* img; Data_Get_Struct(self, struct native_image, img); return img->handle ? Qtrue : Qfalse; } @@ -386,11 +386,11 @@ new_img->h = FreeImage_GetHeight(nh); return Data_Wrap_Struct(Class_Image, NULL, Image_free, new_img); } -VALUE Image_to_bpp(VALUE self, VALUE _bpp) +static VALUE Image_to_bpp(VALUE self, VALUE _bpp) { struct native_image *img; FIBITMAP *nh; int bpp = NUM2INT(_bpp); Data_Get_Struct(self, struct native_image, img); @@ -402,11 +402,11 @@ if (!nh) rb_raise(rb_eArgError, "Invalid bpp"); return rfi_get_image(nh); } -VALUE Image_rotate(VALUE self, VALUE _angle) +static VALUE Image_rotate(VALUE self, VALUE _angle) { struct native_image *img; FIBITMAP *nh; double angle = NUM2DBL(_angle); @@ -414,22 +414,22 @@ RFI_CHECK_IMG(img); nh = FreeImage_Rotate(img->handle, angle, NULL); return rfi_get_image(nh); } -VALUE Image_clone(VALUE self) +static VALUE Image_clone(VALUE self) { struct native_image *img; FIBITMAP *nh; Data_Get_Struct(self, struct native_image, img); RFI_CHECK_IMG(img); nh = FreeImage_Clone(img->handle); return rfi_get_image(nh); } -VALUE Image_rescale(VALUE self, VALUE dst_width, VALUE dst_height, VALUE filter_type) +static VALUE Image_rescale(VALUE self, VALUE dst_width, VALUE dst_height, VALUE filter_type) { struct native_image *img; FIBITMAP *nh; int w = NUM2INT(dst_width); int h = NUM2INT(dst_height); @@ -445,11 +445,11 @@ nh = FreeImage_Rescale(img->handle, w, h, f); return rfi_get_image(nh); } -VALUE Image_downscale(VALUE self, VALUE max_size) { +static VALUE Image_downscale(VALUE self, VALUE max_size) { // down-sample resize struct native_image *img; FIBITMAP *nh; int i; int j; @@ -499,11 +499,11 @@ } } return rfi_get_image(nh); } -VALUE Image_crop(VALUE self, VALUE _left, VALUE _top, VALUE _right, VALUE _bottom) +static VALUE Image_crop(VALUE self, VALUE _left, VALUE _top, VALUE _right, VALUE _bottom) { struct native_image *img; FIBITMAP *nh; int left = NUM2INT(_left); int top = NUM2INT(_top); @@ -524,11 +524,11 @@ #define ALLOC_NEW_IMAGE(__v, img) \ VALUE __v = Image_alloc(Class_Image); \ struct native_image* img; \ Data_Get_Struct(__v, struct native_image, img) \ -VALUE Image_ping(VALUE self, VALUE file) +static VALUE Image_ping(VALUE self, VALUE file) { ALLOC_NEW_IMAGE(v, img); rd_image(self, file, img, 0, 1, 0); if (img->handle) @@ -536,11 +536,11 @@ img->handle = NULL; return v; } -VALUE Image_from_blob(int argc, VALUE *argv, VALUE self) +static VALUE Image_from_blob(int argc, VALUE *argv, VALUE self) { ALLOC_NEW_IMAGE(v, img); switch (argc) { @@ -559,11 +559,11 @@ } return v; } -VALUE Image_ping_blob(VALUE self, VALUE blob) +static VALUE Image_ping_blob(VALUE self, VALUE blob) { ALLOC_NEW_IMAGE(v, img); rd_image_blob(self, blob, img, 0, 1, 0); if (img->handle) @@ -571,11 +571,11 @@ img->handle = NULL; return v; } -VALUE Image_from_bytes(VALUE self, VALUE bytes, VALUE width, +static VALUE Image_from_bytes(VALUE self, VALUE bytes, VALUE width, VALUE height, VALUE stride, VALUE bpp) { long f_len; int _bpp = NUM2INT(bpp); char *ptr; @@ -615,11 +615,11 @@ return v; } /* draw */ -VALUE Image_draw_point(VALUE self, VALUE _x, VALUE _y, VALUE color, VALUE _size) +static VALUE Image_draw_point(VALUE self, VALUE _x, VALUE _y, VALUE color, VALUE _size) { struct native_image* img; int x = NUM2INT(_x); int y = NUM2INT(_y); int size = NUM2INT(_size); @@ -638,10 +638,10 @@ } return self; } -VALUE Image_draw_rectangle(VALUE self, VALUE _x1, VALUE _y1, +static VALUE Image_draw_rectangle(VALUE self, VALUE _x1, VALUE _y1, VALUE _x2, VALUE _y2, VALUE color, VALUE _width) { struct native_image* img; int x1 = NUM2INT(_x1);