473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Image capture

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
lc******@siadv.com
Jul 18 '05 #1
3 3146
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

Jul 18 '05 #2
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" <ka******************@gmail.com> escribió en el mensaje
news:11**********************@f14g2000cwb.googlegr 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

Jul 18 '05 #3
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)

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeremy | last post by:
I've magnified an image on the form as following codes: private void ViewForm_Paint(object sender,System.Windows.Forms.PaintEventArgs e) { Point ulCorner = new Point( 0, 0);...
2
by: Paul Aspinall | last post by:
Hi I am trying to find some code, or reference docs, to assist in helping capture images from an image capture device (ie. webcam etc etc). I want to be able to compare successive images coming...
6
by: anonymous | last post by:
hi all, I'm trying to use the capCreateCaptureWindow (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_capcreatecapturewindow.asp) in a Windows...
4
by: Tomasz Bak | last post by:
Hello, I have a simple problem: mark a list of defects on an image. I think the best way to do it is to select a single deffect, then take two coordinates of coursor form an image on a web...
2
by: | last post by:
Hi, we are planning to rewrite an extisting C++ image processing application/library in C#. Now several question arouse where I hope you can help me: So far we allocated a block of memory as...
2
by: ghostrider | last post by:
Hi, I am working on an access app and need to capture still images from a monitor connected to medical equipment. The video out port on the monitor is connected to a video card in the computer...
0
by: indhu | last post by:
Hi all, am new to the VB forum. Anyway, i need a help from u all. i am developing project.where i am using some kind of webcam. capture image thru webcam by cliking capture button in the form. ...
0
by: =?Utf-8?B?Q2hha3JhdmFydGh5?= | last post by:
Hi, Have been trying to capture the webpage as image from quite a long time. Can some one suggest me a solution to convert or capture the HTML Output of any webresponse to anykind of image...
0
by: ikramalikhan | last post by:
i am developing a software in vb 6.0 as front end and msaccess as back end..i want to capture an ultrasound image via my vb form image control.my doctor client will capture live ultrasound image and...
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.