Hi Paul, Further info, have now compiled the new code on RedHat and no problem with constructor.
Seems most of my problems are Microsoft related, either XP Pro or MSVC7.1 :( Regards, Graham. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Graham Fairweather Sent: Friday, September 17, 2004 6:08 PM To: [EMAIL PROTECTED] Subject: RE: [PNGwriter-users] readfromfile Hi Paul, I tried exactly this method at first but could not get it working. // xbnbt_test_png.cpp // #include <pngwriter.h> void test () { pngwriter image( 1, 1, 0.0, "out.png" ); image.setcompressionlevel( 6 ); image.readfromfile( "burro.png" ); pngwriter image2( 1, 1, 0.0, "out2.png" ); char cName[255]; for( int i = 0; i != 10; i++ ) { sprintf( cName, "png/%d.png", i ); std::cout << "Writing: " << cName; image2 = image; image2.pngwriter_rename( cName ); image2.plot_text_utf8( "arial.ttf", 14 ,4 ,4, 0.0, cName, 0.0, 0.0, 0.0 ); image2.write_png(); std::cout << " Done.\n"; } } int main() { test(); system("PAUSE"); } When I execute this it crashes in the constructor here graph_[vhhh][tempindex+2] = rhs.graph_[vhhh][tempindex+2]; This is why I used readfromfile As a further note, I have compiled the original code on a RedHat 9 system with GCC, it does not crash at image 508 like with Windows. However, the memory usage also increases just like on Windows. Regards, Graham. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Blackburn Sent: Friday, September 17, 2004 5:31 PM To: [EMAIL PROTECTED] Subject: Re: [PNGwriter-users] readfromfile Hi Graham, On 17 Sep 2004, at 11:51, Graham Fairweather wrote: > > > I used sprintf instead of casting as I want to add the path? Ah, true, in that case you're absolutely correct. > > I was only intending to read from 1 file. If I use readfromfile > outside of > the loop then the path/filename is added to the previous image and I > end up > with a block of black where 0-9 etc., has been superimposed on each > image? Ah, of course, I hadn't thought of that. How about this idea: Create two instances. Load one with readfromfile(). The program might be something like create temp create master master.readfromfile("burro.png"); loop: { temp = master; temp.plot_text_utf8(); temp.write_png(); } And you're done! I've used the assignment operator = to easily set temp's contents to that of master. This is much faster than reading the file every time in the loop. > > I was using utf8 for extra language support, ie Russian, Chinese & > Japanese. > I didn't think the plain one supported these? No, it doesn't, you are right in using the UTF8 version if you want to support other languages. > > I though that close() wrote and destroyed the image? Perhaps this is > why my > memory allocation gets bigger and bigger? How do I destroy the image > at the > end of the routine? Ah, I fell for this misconception a while ago (despite the fact that I myself wrote the library, go figure), but if you check the PNGwriter source code, you'll notice that all it does is write the image to disk. The instance's destructor is called when (as far as I can remember) when no other piece of memory refers to it, or at the end of the scope, just like any other variable, so in theory no, you don't need to destroy the instance. If you are sure that your memory allocation increases constantly, then I can go and take a look in the PNGwriter source code, to see if something's amiss, perhaps there's a memory leak. On the other hand, it may just be the way the compiler has compiled the program. I'm not much of an expert on these matters, but if you say that the program's memory use increases drastically, then I'll take a look and see what I can find. > > If my questions sound a bit dumb it's because I am new to programming. Oh, don't worry about that, I'm only an amateur programmer myself :-) Paul ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ http://pngwriter.sourceforge.net/ PNGwriter-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/pngwriter-users ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ http://pngwriter.sourceforge.net/ PNGwriter-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/pngwriter-users ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ http://pngwriter.sourceforge.net/ PNGwriter-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/pngwriter-users
