Attaching patch that allows changing pixels of pixbufs. As requested the length of the supplied string is compared to the length of the buffer and exception is raised if they are not the same. This could be probably changed to a gdk assertion instead. Also attaching a sample application that uses this new method. Thanks Michal
on 2009-09-30 01:05
on 2009-10-04 15:12
Hi, In <a5d587fb0909291604w6ea1b974x836b2b9221261957@mail.gmail.com> "[ruby-gnome2-devel-en] [PATCH] pixels= for pixbuf" on Wed, 30 Sep 2009 01:04:30 +0200, Michal Suchanek <hramrach@centrum.cz> wrote: > Attaching patch that allows changing pixels of pixbufs. Could you adapt coding style in your patch to codes in the same file? > --- ruby-gnome2-0.19.1/gdkpixbuf/rbgdk-pixbuf.c 2008-12-10 13:04:52.000000000 +0100 > +++ ruby-gnome2-0.19.0.mod/gdkpixbuf/rbgdk-pixbuf.c 2009-09-29 22:11:50.000000000 +0200 > @@ -30,6 +30,7 @@ > GDK_PIXBUF_ERROR,\ > GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,\ > "Insufficient memory to load image file"); > +#include <string.h> #include line should be placed before #define lines. > -static VALUE > -get_pixels(self) > - VALUE self; > +static int pixels_size(pixbuf) > + GdkPixbuf *pixbuf; We use static int pixels_size(pixbuf) GdkPixbuf *pixbuf; or static int pixels_size(GdkPixbuf *pixbuf) style. We prefer to the later. > + Check_Type (pixels, T_STRING); We doesn't put a space between function name and a left parenthesis. > + arg_size = NUM2INT(rb_funcall(pixels, rb_intern("length"), 0)); We use RSTRING_LEN() for getting string length. > + rb_raise(rb_eRangeError, "Pixels are %i bytes, %i bytes supplied.", size, arg_size); We use %d for formatting int. > + /* The user currently cannot get a pointer to the actual pixels, the data is copied to a String. */ > + memcpy(gdk_pixbuf_get_pixels(pixbuf), RSTRING(pixels)->ptr, MIN(RSTRING(pixels)->len, size)); We use RSTRING_PTR() for getting row C string and RSTRING_LEN() for getting string length. Thanks, -- kou
on 2009-10-05 22:12
2009/10/4 Kouhei Sutou <kou@cozmixng.org>:
>
Attaching an updated patch that hopefully resolves the code style
issues.
For test application see the previous mail.
Thanks
Michal
on 2009-10-11 06:51
Hi, In <a5d587fb0910051311o6cd6058fq66eac633add1aea0@mail.gmail.com> "Re: [ruby-gnome2-devel-en] [PATCH] pixels= for pixbuf" on Mon, 5 Oct 2009 22:11:15 +0200, Michal Suchanek <hramrach@centrum.cz> wrote: >>> Attaching patch that allows changing pixels of pixbufs. >> >> Could you adapt coding style in your patch to codes in the >> same file? >> > > Attaching an updated patch that hopefully resolves the code style issues. > > For test application see the previous mail. Thanks for fixing it! I've applied your patch in trunk. -- kou
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.