> importwx
>
> displays =(wx.Display(i)fori inrange(wx.Display.GetCount()))
> sizes =[display.GetGeometry().GetSize()fordisplay indisplays]
>
> for(i,s)inenumerate(sizes):
> print("Monitor{} size is {}".format(i,s))
>
> screen =wx.ScreenDC()
>
> size =screen.GetSize()
> size1=screen.GetSizeMMTuple()
>
> print("Width = {}".format(size[0]))
> print("Heigh = {}".format(size[1]))
>
> width=size[0]
> height=size[1]
>
> bmp =wx.EmptyBitmap(width,height)
> mem =wx.MemoryDC(bmp)
> mem.Blit(0,0,width,height,screen,0,0)
>
> delmem
> bmp.SaveFile("testimg.png",wx.BITMAP_TYPE_PNG)
>
> |
>
>
> When I run I see the followinginfo printed out on the console
>
>
> Monitor0 size is (1366, 768) Monitor1 size is (1920, 1080) Width =
> 3286 Height = 1080
>
>
> When the screenshot is taken, I get is a snapshot of the entire
> viewing area (both monitors).
>
> I don't understand how to limit to one monitor or the other.
>
> I'm certain the issue is when I say
>
>
> screen = wx.ScreenDC()
>
>
> but I don't know how to narrow down the size of that Object to the
> size of either of my monitors
>
>
> Any thoughts are appreciated
>
>
> Thanks
>
> Sean
>
>
Sean,
You are correct in thinking that it is a thinking issue - you keep
thinking of 2 screens - the physical world rather than 2 displays each
showing parts of a single big canvas.
______________________
| | ___________ |<- Canvas
| 1 || 2 ||
|______|| ||
|_______|___________||
So as well as a size being unique for each screen it has a position on
the canvas and a) your MemoryDC size needs to match the size of the
screen that you blit from and the position _within the canvas_ so the
size of the blit needs to match the size of the monitor and the start
point, (the last two parameters), needs to match the position of the top
left of the screen on the canvas. So in the example above screen 1 will
start at 0, 0 on the canvas and might have a size of 640x480 and screen
2 will start at maybe 640, 100 and have a size of 1024x768.
So you need to query each screen for size and position and use the size
for the MemoryDC and both for the blit.