From: "klaas.holwerda" on
Hi,

I need to render HTML to image.
And since wxHtmlWindow::m_backBuffer is private :-(, i need to use
wxHtmlDCRenderer it seems.
But i get this error on a HTML string which has a background image for
HTML page.
The reason is that the handler TAG_HANDLER_BEGIN(BODY, "BODY") is not
checking for the m_WParser->GetWindow() to be valid.

But even then, i think that in case of wxHtmlDCRenderer, it should be
handled even if there is not a window, since a wxDC has a size.
Now the difficult part for me is how to change the handler for that tag
to be my own?

wxHtmlWinParser::GetWindow() does exist, but there is no
wxHtmlWinParser::GetDC().

Did someone of you solve this problem or knows what i should do best?

Thanks,

Klaas

Here my stack wxHTML_Handler_BODY::HandleTag() line 350 is the problem line.

wxBitmap::operator=(const wxBitmap & {...}) line 90 + 6 bytes
wxHtmlWindow::SetBackgroundImage(const wxBitmap & {...}) line 145 + 25 bytes
wxHTML_Handler_BODY::HandleTag(const wxHtmlTag & {...}) line 350 + 40 bytes
wxHtmlParser::AddTag(const wxHtmlTag & {...}) line 334 + 15 bytes
wxHtmlParser::DoParsing(int 13335, int 13337) line 319
wxHtmlParser::AddTag(const wxHtmlTag & {...}) line 343
wxHtmlParser::DoParsing(int 13344, int 13346) line 319
wxHtmlParser::DoParsing() line 281
wxHtmlParser::Parse(const wxString & {...}) line 114
wxHtmlDCRenderer::SetHtmlText(const wxString & {...}, const wxString &
{...}, unsigned char 1) line 91 + 15 bytes

--
Unclassified


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "klaas.holwerda" on
klaas.holwerda wrote:
> Now the difficult part for me is how to change the handler for that
> tag to be my own?
Sorry, not so difficult after all ( from the html/widget sample i
learned that it is simple to add my own tag ).
But it also is a way to redifine it in your own code.
The next handler for BODY does the job, just put it in yoor code and
wxHtmlDCRenderer will be happy even with a background image.

#include "wx/html/m_templ.h"

TAG_HANDLER_BEGIN(BODY, "BODY")

TAG_HANDLER_PROC(tag)
{
wxColour clr;

if (tag.GetParamAsColour(wxT("TEXT"), &clr))
{
m_WParser->SetActualColor(clr);
m_WParser->GetContainer()->InsertCell(new
wxHtmlColourCell(clr));
}

if (tag.GetParamAsColour(wxT("LINK"), &clr))
m_WParser->SetLinkColor(clr);

if (tag.HasParam(wxT("BACKGROUND")))
{
wxFSFile *fileBgImage = m_WParser->OpenURL
(
wxHTML_URL_IMAGE,

tag.GetParam(wxT("BACKGROUND"))
);
if ( fileBgImage )
{
wxInputStream *is = fileBgImage->GetStream();
if ( is )
{
#if !defined(__WXMSW__) || wxUSE_WXDIB
wxImage image(*is);
if (m_WParser->GetDC() != NULL && image.Ok() )
{
const wxSize sizeWin(m_WParser->GetDC()->GetSize());
const wxSize sizeBmp(image.GetWidth(),
image.GetHeight());
for ( wxCoord x = 0; x < sizeWin.x; x += sizeBmp.x )
{
for ( wxCoord y = 0; y < sizeWin.y; y +=
sizeBmp.y )
{
m_WParser->GetDC()->DrawBitmap(image, x,
y, true /* use mask */);
}
}
}
#endif
}
}
}

if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
{
m_WParser->GetContainer()->InsertCell(
new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
if (m_WParser->GetWindow() != NULL)
m_WParser->GetWindow()->SetBackgroundColour(clr);
}

return false;
}

TAG_HANDLER_END(BODY)

TAGS_MODULE_BEGIN(MyBind)

TAGS_MODULE_ADD(BODY)

TAGS_MODULE_END(MyBind)





--
Unclassified


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Vadim Zeitlin on
On Mon, 31 Jul 2006 11:07:58 +0200 "klaas.holwerda" <klaas.holwerda(a)nl.thalesgroup.com> wrote:

k> I need to render HTML to image.
k> And since wxHtmlWindow::m_backBuffer is private :-(, i need to use
k> wxHtmlDCRenderer it seems.
k> But i get this error on a HTML string which has a background image for
k> HTML page.
k> The reason is that the handler TAG_HANDLER_BEGIN(BODY, "BODY") is not
k> checking for the m_WParser->GetWindow() to be valid.

This shouldn't be the case any more in HEAD, although I'm not sure if it
handles background correctly when there is no window, it could just ignore
it. But at least it shouldn't crash.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org