Hi, I don''t understand how to combine ImageMagick and FXImage... The problem is that I don''t get how I should tell the FXImage about my pixels... The docs says I should either provide a FXMemoryBuffer or a String. I''ve tried with all types of strings I think. Both binary (from pack) and seperated with spaces, commas, etc, but all I get is either a grey mass, or black with various colored pixels... FXMemoryBuffer can''t be created it seems. FXMemoryBuffer.new just blows up?!?? I guess I could save the image generated from ImageMagick and then use the ''standard'' FXJpgImage class, but I rather not...
On Wednesday 03 November 2004 09:37 am, Fredrik Jagenheim wrote:> Hi, > > I don''t understand how to combine ImageMagick and FXImage... > > The problem is that I don''t get how I should tell the FXImage about my pixels... > > The docs says I should either provide a FXMemoryBuffer or a String. > > I''ve tried with all types of strings I think. Both binary (from pack) > and seperated with spaces, commas, etc, but all I get is either a grey > mass, or black with various colored pixels... > > FXMemoryBuffer can''t be created it seems. FXMemoryBuffer.new just blows up?!?? > > I guess I could save the image generated from ImageMagick and then use > the ''standard'' FXJpgImage class, but I rather not...You could create an FXImage with the right dimensions, and then set its pixel data: image=new FXImage(app,pixels,IMAGE_OWNED|IMAGE_KEEP,width,height); After which FXImage assumes ownership of the pixel array [which must have been allocated with FXMALLOC()]. If the pixel array is not to be owned by FXImage, then, of course, you can just omit the IMAGE_OWNED flag. The pixel array, incidentally, is just a rectangular array of colors. Each color is RGBA, in that order, from low to high memory. The FXRGB macros are adjusted based on the machine''s byte order so if you use these macros then the memory layout of your colors will be automatically correct. Hope this helps, - Jeroen
On Wed, 3 Nov 2004 09:36:52 -0500, Jeroen van der Zijp <jeroen@fox-toolkit.org> wrote:> On Wednesday 03 November 2004 09:37 am, Fredrik Jagenheim wrote: > > > > I don''t understand how to combine ImageMagick and FXImage... > > > > You could create an FXImage with the right dimensions, and then > set its pixel data: > > image=new FXImage(app,pixels,IMAGE_OWNED|IMAGE_KEEP,width,height);I''m using fxruby, so it looks like this for me: # This should create a either very dark magenta or very bright magenta, depending on internal bitcolors: buf = [] 100.times { 100.times { buf << 255 buf << 0 buf << 255 } } transformed_buf = buf.join(" ") # Doesn''t work # transformed_buf = buf.pack("i") # Doesn''t work either image = FXImage.new(getApp(), transformed_buf, 0, 100, 100) imageView = FXImageView.new(self, nil, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y) imageView.image = image All I get is a small, scrollable window in very dark grey.> The pixel array, incidentally, is just a rectangular array of colors.Documentation for FXRuby says it should be FXMemoryBuffer or String. :( FXMemoryBuffer doesn''t work though: fx_image_test.rb:20:in `new'': allocator undefined for Fox::FXMemoryBuffer (NoMethodError) And I can''t figure out how to transform my Array to a proper String...> Hope this helps,Sadly not, I''m using the Ruby interface... But that''s not your fault. :) I don''t know how/why my message ended up on the foxgui-users mailing list, though... //F
On Wed, 3 Nov 2004 18:03:33 +0100, Fredrik Jagenheim <jagenheim@gmail.com> wrote:> # transformed_buf = buf.pack("i") # Doesn''t work eitherIt always helps to post code to realize that you''ve done a mistake. :/ buf.pack("c*") works EXACTLY like I wanted it to. Sorry for the noise... :( //F