I need to be able to save an image (the format doesn't matter) the status of the device context canvas. I tried dc.GetAsBitmap , but it returns invalid raster images. How can i do this?
dc.GetAsBitmap
I believe this should do the trick:
def saveSnapshot(dcSource): # based largely on code posted to wxpython-users by Andrea Gavana 2006-11-08 size = dcSource.Size # Create a Bitmap that will later on hold the screenshot image # Note that the Bitmap must have a size big enough to hold the screenshot # -1 means using the current default colour depth bmp = wx.EmptyBitmap(size.width, size.height) # Create a memory DC that will be used for actually taking the screenshot memDC = wx.MemoryDC() # Tell the memory DC to use our Bitmap # all drawing action on the memory DC will go to the Bitmap now memDC.SelectObject(bmp) # Blit (in this case copy) the actual screen on the memory DC # and thus the Bitmap memDC.Blit( 0, # Copy to this X coordinate 0, # Copy to this Y coordinate size.width, # Copy this width size.height, # Copy this height dcSource, # From where do we copy? 0, # What the X offset in the original DC? 0 # What the Y offset in the original DC? ) # Select the Bitmap out of the memory DC by selecting a new # uninitialized Bitmap memDC.SelectObject(wx.NullBitmap) img = bmp.ConvertToImage() img.SaveFile('saved.png', wx.BITMAP_TYPE_PNG)
(I would include a link to the original, but could not find it quickly.)
Perhaps, perhaps, something from this (working with images and wxPython)
Source: https://habr.com/ru/post/1300234/More articles:Determining the unsurpassed portion of a string using regex in Python - pythonSending text cross-domain by bookmark - javascriptJavascript string replacement - what's the best way to do this? - javascriptJavascript onclick in script - javascriptActivate VPN on iPhone programmatically - iphonehttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1300235/how-to-use-jquery-attr-to-select-only-first-attribute&usg=ALkJrhjmml4cWoRi71fs6jBN0rc8GW-H6wwxpython, dc.GetAsBitmap returns an invalid bitmap - bitmapWhen your method fails, but succeeds ... Would you return failure or success? - language-agnostichow to kill setTimeout () function - actionscriptConvert DateTime to yyyyMMdd int - c #All Articles