|
From: Paul E O. <pau...@co...> - 2007-02-13 05:50:12
|
Hi Jerry et. al. -
I have also compiled your port on Ubuntu Linux Edgy. I also ported
Agg2DDemo to X11 and FreeType using agg_platform_support.cpp/.h
agg_font_freetype.cpp/.h.
Build environment is Eclipse/g++.
I found that there was a warning regarding int/unsigned int used in
comparison in an agg-2.4 file, agg_image_accessors.h, in
image_accessor_clone::span(). This warning came up when instantiating
templatized function Agg2DRenderer::renderImage() which instantiates the
templatized function agg::render_scanlines() in several places. The odd
thing about this warning is that g++ refused to complete the compilation
- everyplace that agg::render_scanlines() was instantiated was declared
as an error - or at least that's what showed up in Eclipse. Still, the
archiver was not kicked off until the warning was resolved (I compiled
Agg2D as a separate library.)
Code was:
AGG_INLINE const int8u* span(int x, int y, unsigned len)
{
m_x = m_x0 = x;
m_y = y;
if(y >= 0 && y < (int)m_pixf->height() &&
x >= 0 && x+len <= (int)m_pixf->width())
{
return m_pix_ptr = m_pixf->pix_ptr(x, y);
}
m_pix_ptr = 0;
return pixel();
}
Code now is:
AGG_INLINE const int8u* span(int x, int y, unsigned len)
{
m_x = m_x0 = x;
m_y = y;
if(y >= 0 && y < (int)m_pixf->height() &&
>> x >= 0 && (int)(x+len) <= (int)m_pixf->width()) //cast
x+len to int
{
return m_pix_ptr = m_pixf->pix_ptr(x, y);
}
m_pix_ptr = 0;
return pixel();
}
Jerry, I hope I'm not overstating the obvious, but in your code at the
top of Agg2DRenderer::renderImage(), you mentioned that you were puzzled
at needing the const cast. It is due to the fact that renderImage()
promises that it won't modify the image, but when you pass the reference
to the image buffer into agg::pixfmt_bgra32::pixfmt_bgra32() (via
parameterized class, pixfmt_alpha_blend_rgba), that constructor makes no
such promise. I didn't delve any deeper into the code to ascertain
whether the promise is actually kept, but I suspect that it is, since
this method should only be reading the image in order to render it into
another buffer (I think! :)).
Paul
|