Klaas Holwerda wrote:
> only a small part is actually drawn.
This works fine here, with a2dCanvas, will check it in this evening:
virtual void PaintBackground( int x, int y, int width, int height )
{
if ( m_image.IsOk() )
{
//position of background image in world coordinates
double xImageOrigin= -500;
double yImageOrigin= 1000;
double wImage = 4000;
double hImage = 4000;
a2dCanvasView::PaintBackground(x,y,width,height);
//m_drawer2D->DrawImage( image, xOrigin, yOrigin, w, h );
int orgdevicew,devicew,orgdeviceh,deviceh;
int imagew = m_image.GetWidth();
int imageh = m_image.GetHeight();
orgdevicew = devicew = m_drawer2D->WorldToDeviceXRelNoRnd( wImage
);
orgdeviceh = deviceh = abs(m_drawer2D->WorldToDeviceYRelNoRnd(
hImage ));
//device x/y of projected (imaginairy) image
int devicex = m_drawer2D->WorldToDeviceX( xImageOrigin );
int devicey = m_drawer2D->WorldToDeviceY( yImageOrigin );
int clipx = x;
int clipy = y;
int clipwidth = width;
int clipheight = height;
//the above gives jitter because of rounding i think, so just take
the whole window as clip.
clipx = 0;
clipy = 0;
clipwidth = m_drawer2D->GetWidth();
clipheight = m_drawer2D->GetHeight();
int mindx=0; //miminum device x in projected (imaginairy) image
int mindy=0; //miminum device y in projected (imaginairy) image
// clip to clipping area
if (devicex < clipx)
{
mindx = clipx-devicex;
devicew -= clipx-devicex;
}
if (devicew <= 0) return;
if (devicey < clipy)
{
mindy = clipy-devicey;
deviceh -= clipy-devicey;
}
if (deviceh <= 0) return;
if (devicex+orgdevicew >= clipx+clipwidth)
{
devicew -= devicex + orgdevicew - (clipx + clipwidth);
}
if (devicew <= 0) return;
if (devicey+orgdeviceh >= clipy+clipheight)
{
deviceh -= devicey + orgdeviceh - (clipy + clipheight);
}
if (deviceh <= 0) return;
//now the projected image to be drawn at the given width and
height in world coordinates,
//is clipped to the current clip rectangle.
// and it is something to be drawn, else we would have returned by
now
//based on the device rectangle to be drawn, calculate what
subimage we need.
wxRect SubImageRect( (mindx * imagew) / orgdevicew,
(mindy * imageh) / orgdeviceh,
(devicew * imagew) / orgdevicew,
(deviceh * imageh) / orgdeviceh
);
if ( SubImageRect.GetHeight() <= 0 || SubImageRect.GetWidth() <= 0
)
return;
wxImage SubImage = m_image.GetSubImage(SubImageRect);
// Scale it properly.
SubImage.Rescale( devicew, deviceh);
// Generate a bitmap and a memory device context and select the
bitmap
// into the memory device context.
wxBitmap Bitmap( SubImage );
wxMemoryDC MemoryDc;
MemoryDc.SelectObject(Bitmap);
// Copy the pre-stretched bitmap to the display device.
m_drawer2D->GetRenderDC()->Blit( devicex + mindx, devicey + mindy,
devicew, deviceh,
&MemoryDc, 0, 0, wxCOPY, false);
}
else
a2dCanvasView::PaintBackground(x,y,width,height);
}
--
Unclassified
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Wxart2d-users_dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev