how to capture the scrolled panel without dark image at bottom page

here is my few lines of code to capture the scrolled panel and also i have tried to reduced the size in the clientdc, yet same problem.

context = wx.ClientDC( self.panel )

self.panel.DoPrepareDC(context)

bitmap = wx.Bitmap( 720,800)

memory = wx.MemoryDC( )

memory.SelectObject( bitmap

memory.Blit( 0, 0, 720, 800, context, 0, 0)

memory.SelectObject( wx.NullBitmap)

data = wx.PrintDialogData(self.pdata)

bitmap.SaveFile( ‘test5.jpg’, wx.BITMAP_TYPE_JPEG )

here is the image captured

test5.jpg

Try using the size of the panel instead of hard-coding the size.

···

On Monday, April 16, 2018 at 2:05:06 AM UTC-7, gbiggs wrote:

here is my few lines of code to capture the scrolled panel and also i have tried to reduced the size in the clientdc, yet same problem.

context = wx.ClientDC( self.panel )

self.panel.DoPrepareDC(context)

bitmap = wx.Bitmap( 720,800)

Robin

gbiggs wrote:

here is my few lines of code to capture the scrolled panel and also i
have tried to reduced the size in the clientdc, yet same problem.

I must have missed the beginning of this conversation. Are you trying
to capture the entire contents of a scrolled panel, when part of the
panel is invisible? If so, this path will never work. A wx.ClientDC
can only access pixels that are visible on the screen. There is no
magic "backing store" that holds the other pixels.

You should be able to create a MemoryDC the same size as the entire
scrolling window (NOT the visible region), and then pass this DC to the
OnDraw method of the ScrolledWindow. The ScrolledWindow will recreate
the contents into your DC.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.