From: Michal S. <hra...@ce...> - 2009-08-03 12:21:27
|
2009/8/2 Kouhei Sutou <ko...@co...>: > Hi, > > In <a5d...@ma...> > "Re: [ruby-gnome2-devel-en] cannot set pixbuf pixels - how to modify an image?" on Sun, 2 Aug 2009 08:37:15 +0200, > Michal Suchanek <hra...@ce...> wrote: > >>>> Which I resolved by patching the pixbuf bindings. >>> >>> set_pixels: >>> >>> * We should use RSTRING_PTR() instead of RSTRING()->ptr >>> and RSTRING_LEN() instead of RSTRING()->len. >>> * We should return self for setter method: >>> http://ruby-gnome2.sourceforge.jp/hiki.cgi?Naming+and+Conversion+Rules#Accessors+%28Setter%2FGetter+methods%29 >> >> OK, these are easy to change, I just used whatever worked (and >> whatever was described in README.EXT) > > Please. > >>> * Why memmove()? Should we use memcpy()? >> >> memmove is the safer variant. If the user got to the original pointer >> somehow the copied regions might overlap. While it's unlikely one >> more check should not impact performance and should avoid some >> interesting bugs. > > It seems that the user can't get the original pointer. > If the user can get the original pointer, the user doesn't > need to set pixels. The user can only change the original > pointer. > > So I think that we can use memcpy(). > >>> * Should we require "pixbuf.pixels.size == new_pixels.size"? >> >> I guess it's OK to set only part of the pixels. I am not sure >> returning error is appropriate if the sizes do not match. > > If we provide an 'offset' argument, it will be reasonable. > But set_pixels doesn't provide it. > > So I think that the sizes should be matched. Perhaps a [] interface would be better than pixels and pixels= then? Thanks Michal |