Topics

get picture content of diagram


Tage Johansson <frans.tage@...>
 

Hello,


I have an object with the role ROLE_DIAGRAM. How can I retreeve the actual picture of the diagram. Or so to say, the pixels on the window corresponding to the object.


It is in firefox if that helps.


Thanks in advance,

Tage


Shubham Jain
 

Hi Tage,

I'm not sure if it's the best way to do this but this is how I am doing something similar for my add-ons:

import screenBitmap
left, top, width, height = nav.location    #where nav is your navigator object with role ROLE_DIAGRAM
sb = screenBitmap.ScreenBitmap(width, height)
pixels = sb.captureImage(left, top, width, height)    #will give you a 2D array of RBGAQuad values

# If you want to save the image as a file you can do the following
import wx
bmp = wx.EmptyBitmap(width, height, 32)
bmp.CopyFromBuffer(pixels, wx.BitmapBufferFormat_RGB32)
bmp.SaveFile("path_to_save_location.jpg", wx.BITMAP_TYPE_JPEG)    # you can also use different image formats instead of JPEG (see here)

regards,
Shubham Jain