Am 29.12.2013 13:42, schrieb Carsten A. Arnholm: > Hi Tommi, > > Thank you for replying! I sense Tntnet is extremely powerful once one > understands how it works. > > I sent the reply to Olaf before I say your response. I can see now that > your suggestions make sense (I still have no clue about where the image > is displayed in the page, but never mind that for now, it is probably in > the HTML design). > > On 29. des. 2013 12:49, Tommi Mäkitalo wrote: >> As a alternative you have a class, which generates the image data in the >> output operator for std::ostream. But I'm sure that you know how to do that. > Thanks for the tip. Yes, this is not so hard. The image is fundamentally > a string of bytes (i.e. char) so writing those to a std::ostream makes > sense. > >> One side note: you have to be careful with empty lines. You have to make >> sure, your ecpp do not contain any empty lines outside the <%cpp> >> section since it is written to the output stream and may corrupt your >> image. But as a special feature of ecpp one line feed after the end tag >> </%cpp> is not sent to the output stream. > Should the generateImageData(); send a std::endl at the end of the > image data? Do you mean empty lines *inside* the <%cpp> </%cpp> tags? > > I am going to try these things out in stages. Thanks for bearing with me! > > Best Regards > Carsten Arnholm Hi Carsten,
thank you for your feedback. We know, that documentation is not the strength of tntnet to say it friendly. We try to improve it step by step. I have the impression, that you did not yet fully understand, how html works. So let me explain it a little. If you want to display a image in a html page, you add a img-tag like that: <img src="/theimage.jpg">. The browser will do another request to the web server to load the image and display the image exactly, where the img tag is found. So from the webserver point of view there is just the request to the url "/theimage.jpg". This request do not care, where the image is displayed but just send the image back. The reply must contain a http header with the content type. In tntnet this is by default "text/html", which is really false for a jpg image. So you have to set the content type to a suitable value using reply.setContentType depending on the type of the image. When we think about dynamic images in tntnet, the url must map to a tntnet component, which sends the image back. Of course you can generate images to the file system and use static@tntnet to send the image back. But then they are more or less static images. The way I suggested, you can generate the images on the fly and send them back without touching the file system at all. After calling generateImageData you must not send a std::endl. std::endl would send a line feed, while the reply body must contain only the image data. And I mean really outside <%cpp>-tags. Inside <%cpp> tags you can use as much empty lines as you wish since it is just c++ code, which do not affect the output. Everything outside the <%cpp> tags is sent to the output stream, which will corrupt your image. Hence you must take care not to output anything other than the data returned by the generateImageData function. I've once used gd to generate dynamic images. I have a example application here. I try to pack that to a archive and upload it to www.tntnet.org and send you the link. It may be helpful to you. Tommi ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Tntnet-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tntnet-general
