Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Image capture

Reply
Thread Tools

Image capture

 
 
Catalin Lungu
Guest
Posts: n/a
 
      01-05-2005
Hi,
Can anybody help me to implement the following VB code in Python. Thanks in
advance.

Private Declare Function SendMessage Lib "user32.dll" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4&
Private Const PRF_CHILDREN = &H10&
Private Const PRF_OWNED = &H20&

Private Sub Command1_Click()
SendMessage grid.hwnd, WM_PAINT, picture.hDC, 0
SendMessage grid.hwnd, WM_PRINT, picture.hDC, PRF_CHILDREN Or PRF_CLIENT
Or PRF_OWNED
picture.Picture = picture.Image
picture.Refresh
End Sub


Catalin



 
Reply With Quote
 
 
 
 
Kartic
Guest
Posts: n/a
 
      01-05-2005
Catalin,

Some explanation about what you are tring to do will be of immense
help.

Did you want to capture some other Windows object from Python or do you
want to capture a Python GUI application from Python?

I might be able to help out, but please send more details.
Thank you,
--Kartic

 
Reply With Quote
 
 
 
 
Catalin Lungu
Guest
Posts: n/a
 
      01-05-2005
Hi,

I want to capture a no visible area of a wxFrame of Python. This area
contain a wxGrid object. In VB6 this code work very good.

Thanks.

"Kartic" <> escribió en el mensaje
news: oups.com...
> Catalin,
>
> Some explanation about what you are tring to do will be of immense
> help.
>
> Did you want to capture some other Windows object from Python or do you
> want to capture a Python GUI application from Python?
>
> I might be able to help out, but please send more details.
> Thank you,
> --Kartic
>



 
Reply With Quote
 
Kartic
Guest
Posts: n/a
 
      01-05-2005
Hi Catalin,

Here are the modifications to your code. I am emailing you the complete
file back to your email address. Please note that you need PIL (Python
Imaging Library) to grab the window. I included a step to save the
image, but you can do whatever you want with it.

Thanks,
--Kartic

-------------- Unified Diff ---------------

--- Catalin.txt Wed Jan 05 11:43:38 2005
+++ frmDesign.py Wed Jan 05 11:43:17 2005
@@ -1,7 +1,7 @@
from wxPython.wx import *
from wxPython.grid import *
from win32api import SendMessage
-import win32ui
+import win32ui, win32gui, ImageGrab

WM_PAINT = 0xf
WM_PRINT = 0x317
@@ -47,6 +47,10 @@
dc = wxMemoryDC()
dc.SelectObject(bmp)
dc.Clear()
+ win_sz = win32gui.GetWindowRect(self.grd.GetHandle())
+ print win_sz
+ im = ImageGrab.grab((win_sz[0],win_sz[1],win_sz[2],win_sz[3]))
+ im.save('C:/TEMP/grid.jpg')
SendMessage(self.grd.GetHandle(), WM_PAINT, dc.GetHDC(), 0)
SendMessage(self.grd.GetHandle(), WM_PRINT, dc.GetHDC(),
PRF_CHILDREN|PRF_CLIENT|PRF_OWNED)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Capture With Mouse , Mouse Position Capture Max Java 7 08-08-2009 11:51 PM
SuperVideoCap work as a broadcast capture and screen capture and record tool. hely0123 Media 0 10-30-2007 08:59 AM
Problem: Capture screen returns black image on webserver kris_scheyer@yahoo.com ASP .Net 0 08-25-2005 12:38 PM
wx.Image: Couldn't add an image to the image list. Laszlo Zsolt Nagy Python 1 01-26-2005 09:55 PM
JMF wanted to play a mpg video and capture an Image into a Buffered Image tochaotic4u Java 2 07-03-2003 09:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57