|
From: Pete B. <pet...@ge...> - 2008-02-26 12:00:56
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=iso-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Verdana">I posted a wxWidgets example a
while back:<br>
<br>
</font></font><small><font face="Courier New, Courier, monospace"><br>
inline void BlitBitmap(wxDC& dc, wxBitmap& bitmap)<br>
{<br>
wxMemoryDC mdc(bitmap);<br>
int w = bitmap.GetWidth();<br>
int h = bitmap.GetHeight();<br>
<br>
if (bitmap.IsOk()) {<br>
dc.Blit(0, 0, w, h, &mdc, 0, 0);<br>
}<br>
}<br>
<br>
inline void BlitBitmapToBitmap(wxBitmap const& src, wxBitmap&
dst)<br>
{<br>
wxMemoryDC mdc(dst);<br>
mdc.DrawBitmap(src, 0, 0);<br>
}<br>
<br>
inline bool SizeBitmap(wxBitmap& bitmap, int w, int h)<br>
{<br>
if (!bitmap.IsOk() ||<br>
(bitmap.GetWidth() != w) ||<br>
(bitmap.GetHeight() != h)<br>
) { <br>
bitmap.Create(w, h, 24); // 24 bits per pixel, eases use of DIB.<br>
return true;<br>
}<br>
return false;<br>
}<br>
<br>
inline bool SizeToWindow(wxBitmap& bitmap, wxWindow const* win)<br>
{<br>
int w, h;<br>
win->GetClientSize(&w, &h);<br>
return SizeBitmap(bitmap, w, h);<br>
}<br>
<br>
typedef unsigned char byte_t;<br>
<br>
inline byte_t* AttachRBuf(agg::rendering_buffer& rbuf,
wxNativePixelData& dib)<br>
{<br>
byte_t* pix =
reinterpret_cast<byte_t*>(&dib.GetPixels().Data());<br>
if (!pix) return NULL;<br>
<br>
int const w = dib.GetWidth();<br>
int const h = dib.GetHeight();<br>
int stride = dib.GetRowStride();<br>
<br>
if (stride < 0) {<br>
// Adjust pointer to the actual start of the memory block.<br>
pix = pix + (stride * (h - 1));<br>
}<br>
<br>
rbuf.attach(pix, w, h, stride);<br>
return pix;<br>
}<br>
<br>
// The view class with AGG drawing<br>
class View : public wxPanel<br>
{<br>
// Event table omitted for brevity<br>
// (Connects the paint event, the size event and the erase event up)<br>
<br>
public:<br>
View(wxWindow *parent) <br>
: wxPanel(parent, wxID_ANY)<br>
{<br>
SetBackgroundStyle(wxBG_STYLE_CUSTOM);<br>
}<br>
<br>
void onEraseBackground(wxEraseEvent&) {<br>
// Do nothing, to prevent flicker.<br>
}<br>
void onResize(wxSizeEvent& e) {<br>
dirty_ = true;<br>
Refresh();<br>
e.Skip();<br>
}<br>
<br>
void onPaint(wxPaintEvent& e) <br>
{<br>
wxPaintDC dc(this);<br>
<br>
if (dirty_) {<br>
SizeToWindow(winbuffer_, this);<br>
draw();<br>
}<br>
<br>
BlitBitmap(dc, winbuffer_);<br>
}<br>
<br>
void draw() {<br>
// Get the DIB section of the bitmap, which allows direct<br>
// manipulation.<br>
// In wx widgets the DIB is actually held in the wxBitmap<br>
// object.<br>
wxNativePixelData dib(winbuffer_);<br>
agg::rendering_buffer rbuf;<br>
AttachRBuf(rbuf, dib);<br>
<br>
// Windows 24 bit DIB format<br>
typedef agg::pixfmt_bgr24 pixfmt_type;<br>
pixfmt_type pixfmt;<br>
pixfmt.attach(rbuf);<br>
<br>
// ... agg drawing code ... //<br>
}<br>
<br>
private:<br>
bool dirty_;<br>
wxBitmap winbuffer_;<br>
};<br>
</font></small><br>
<br>
Jerry wrote:
<blockquote cite="mid:13a501c8786d$b5e03fc0$0565a8c0@p424" type="cite">
<pre wrap="">Hi Noel
Would an MFC + Agg2D example be the most useful, if not suggest something
and I'll post one.
Jerry.
----- Original Message -----
From: "noel frankinet" <a class="moz-txt-link-rfc2396E" href="mailto:noe...@sk..."><noe...@sk...></a>
To: "Anti-Grain Geometry" <a class="moz-txt-link-rfc2396E" href="mailto:vec...@li..."><vec...@li...></a>
Sent: Tuesday, February 26, 2008 11:39 AM
Subject: Re: [AGG] Using agg & win32 painting simultaneously [solved]
Matthias Höpfer a écrit :
</pre>
<blockquote type="cite">
<pre wrap="">Noel:
</pre>
</blockquote>
<pre wrap=""><!---->
Hello Matthias
Could you just post the WM_PAINT part, just to understand how to mix GDI
calls and agg ones (I want to draw lines and polygones using agg, but
keeps GDI for text).
Thank you
Noël
</pre>
<blockquote type="cite">
<pre wrap="">What exactly? The previous mails are containing the important snippets out
of my needs.
- Matthias
-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:vec...@li...">vec...@li...</a>
[<a class="moz-txt-link-freetext" href="mailto:vec...@li...">mailto:vec...@li...</a>] On Behalf Of
noel frankinet
Sent: Tuesday, February 26, 2008 11:55 AM
To: Anti-Grain Geometry
Subject: Re: [AGG] Using agg & win32 painting simultaneously [solved]
Stephan Assmus a écrit :
Hello,
I would be interested to see the code to avoid reinventing the wheel !
Thank you
Noël Frankinet
</pre>
<blockquote type="cite">
<pre wrap="">On 2008-02-26 at 08:22:12 [+0100], Matthias Höpfer
<a class="moz-txt-link-rfc2396E" href="mailto:Mat...@eu..."><Mat...@eu...></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Lorne:
Thanks for your hint. The whole thing is going to get clearer day by
day.
Due to the current code cunstruction/architecture i see that the guy
implementing it did have the same knwoledge like me. None at all. But
i'm definitely going to mention it.
To all the others that did take part in this discussion so far:
Thanks a lot!
The build-up described so far is working (attaching agg2d to the
DWORD buffer m_bits containing the map). I found some lines of code,
again, some ancient ones, which were clearing the buffer after i
attached it to agg2d. I simply didn't see...
Again, thank you! You're doing a great job.
</pre>
</blockquote>
<pre wrap="">Sounds like you got it working now? :-)
Best regards,
-Stephan
----------------------------------------------------------------------
--- This SF.net email is sponsored by: Microsoft Defy all challenges.
Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Vector-agg-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Vec...@li...">Vec...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/vector-agg-general">https://lists.sourceforge.net/lists/listinfo/vector-agg-general</a>
</pre>
</blockquote>
<pre wrap="">
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges.
Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Vector-agg-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Vec...@li...">Vec...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/vector-agg-general">https://lists.sourceforge.net/lists/listinfo/vector-agg-general</a>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Vector-agg-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Vec...@li...">Vec...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/vector-agg-general">https://lists.sourceforge.net/lists/listinfo/vector-agg-general</a>
</pre>
</blockquote>
<pre wrap=""><!---->
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Vector-agg-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Vec...@li...">Vec...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/vector-agg-general">https://lists.sourceforge.net/lists/listinfo/vector-agg-general</a>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Vector-agg-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Vec...@li...">Vec...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/vector-agg-general">https://lists.sourceforge.net/lists/listinfo/vector-agg-general</a>
</pre>
</blockquote>
</body>
</html>
|