Hi, I''ve been having some intermittent (but repeatable) problems using Image#set_data. In some cases, I get just a black image drawn after I''ve set a (non-black) image. Other times I get a MSVC++ runtime exception. It happens on the same files at the same time. I''m confident that I''m setting the correct amount of data for the image size. (Note: Ruby 1.8.2, WxRuby 0.6.0, Windows XP) Possible problems: 1. I''m reusing the same Image object that has been created before and painted (via creation of a Bitmap). So I''m calling .set_data on something that''s been around for a while. This shouldn''t be a problem, right? 2. Memory allocation. The data object is a String, created via something like: ''x = "a"*some_length'' in a method and class far away from where it gets used to set the image''s data. Could this be a garbage collection issue? If so, why only sometimes? Is there a better way to allocate space? 3. Since it''s repeatable with the same image data and the same image processing steps, perhaps it''s a data content issue? Is there any reason image.set_data would choke on a String of the correct length because of the data contents? Interestingly it appears to only happen on images that don''t have a mask (but maybe that''s just the way my data is...). This is an image processing application, and interestingly I''ve never seen the problem happen when loading from a file. It only happens after some image processing has taken place on the data. Any ideas of things to investigate? I''m at my wit''s end on this... Thanks, Kian W _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it''s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
I previously wrote:> >I''ve been having some intermittent (but repeatable) problems using >Image#set_data. In some cases, I get just a black image drawn after I''ve >set a (non-black) image. Other times I get a MSVC++ runtime exception....>1. I''m reusing the same Image object that has been created before and >painted (via creation of a Bitmap). So I''m calling .set_data on something >that''s been around for a while. This shouldn''t be a problem, right?Answered my own question I guess... Creating a new Image object instead of reusing the old one appears to work fine so far. Will do more testing, but so far so good... KW _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it''s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
no body wrote:> I previously wrote: > >> >> I''ve been having some intermittent (but repeatable) problems using >> Image#set_data. In some cases, I get just a black image drawn after >> I''ve set a (non-black) image. Other times I get a MSVC++ runtime >> exception. > > ... > >> 1. I''m reusing the same Image object that has been created before and >> painted (via creation of a Bitmap). So I''m calling .set_data on >> something that''s been around for a while. This shouldn''t be a problem, >> right? > > > Answered my own question I guess... Creating a new Image object instead > of reusing the old one appears to work fine so far. Will do more > testing, but so far so good...There is nothing in the wxruby source code that should affect this. Looking at the wxWindows source code, it appears that set_data can only be used if the image is exactly the same size and depth, and has exactly the same mask. Within those constraints, I don''t see why it wouldn''t work. The wx header comment for set_data (or SetData, as they call it) is: // these functions provide fastest access to wxImage data but should be // used carefully as no checks are done Kevin
Hello. You wrote 06.05.2005, 17:06:38: nb> Answered my own question I guess... Creating a new Image object instead of nb> reusing the old one appears to work fine so far. Will do more testing, but nb> so far so good... Also probably you need to call Wx::Image.destroy manually after using image. This is because wxruby does not call wxImage destructor properly. -- Dmitry mailto:dmiceman@ubiz.ru