On 8/11/07, Bob Jamison <rwjj@...127...> wrote:
Sounds great. Sorry I missed you when you were asking about Win32 and the Buildtool. So I tried building it and have it mostly done now.
From a portability side, I have found a couple of thing that need to be tweaked.
In imagemagick.cpp, the first include should be #include <libintl.h> This will work on both Linux and windows and will provide the definition for libintl_printf() that Windows needs.
strndup, stpcpy and strnlen are Linux-only
strndup can be replaced with g_strndup()
For stpcpy() , which returns the tail of the destination string, I would either replace it with some pointer-walking code, like below, or preferably use a Glib::ustring as an output buffer and append the data to it. Slightly slower, but a LOT safer.
I hope Thunderbird doesn't screw up the formatting too much :)
int formatted_len = raw_len * 78 / 76 + 100; char *formatted = new char[formatted_len]; char *formatted_i = formatted; const char *src;
for (src = "data:image/" ; *src ; ) *formatted_i++ = *src++; for (src = effectedImage.magick().c_str() ; *src ; ) *formatted_i++ = *src++; for (src = ";base64, \n" ; *src ; ) *formatted_i++ = *src++;
int col = 0; while (*raw_i) { *formatted_i++ = *raw_i++; if (col++ > 76) { *formatted_i++ = '\n'; col = 0; } }
if (col) *formatted_i++ = '\n';
*formatted_i = '\0';
======================= /* Being lazy, I prefer this */ Glib::ustring buf = "data:image/"; buf.append(effectedImage.magick()); buf.append(";base64, \n"); int col = 0; while (*raw_i) { buf.push_back(*raw_i++); if (col++ > 76) { buf.push_back('n'); col = 0; } } if (col) buf.push_back('\n');
const char *formatted = (const char *)buf.c_str();
======================
k, did the above, replacing the strndup with the g_ version, and using the /* being lazy */ code for the stpcpy and it compiles ok, but I'm not getting any raster extensions showing on the effects menu here. Is it checking for IM somewhere? I'm gonna guess that the test isnt working right on windows... Let me know and I'll help you try get this working.
Cheers
Sim