Link to home
Start Free TrialLog in
Avatar of dvplayltd
dvplayltdFlag for Bulgaria

asked on

How to save current pic of PictureBox VB6 control and compare it with new pic?

Dear experts!

I have a picture control with VB6 desktop application. I pass his hWnd to a OCX which put picture in it. Actually a OCX provide me with preview of played video.  But in 5-10 min.  it block and show empty (black screen). Of course, first plan are to check the OCX, but it is on C and rule external device which it not under my control,also it may be driver problem . A possible  solution is to do workaround and to restart the control, then it continue fine. But I should detect that there is no change in picture last 2 or 5 sec.

So the question is: how to save current picture from PictureBox control and how to compare it after 2 sec. May be I need to get bytes of current pics and to compare it with old bytes? Only count of bytes, or to make some fast check sum over it?  Give me advice please.

I prefer to do this without save picture to file and check bytes of files, as it is slow and I'm sure all can be solved in memory only.

For C experts, if you give me idea about API fuctions may be I'll be able to call it from Vb6.
Avatar of Member_2_5069294
Member_2_5069294

Are you trying to detect a black screen or no change in the picture?

You could try sending a WM_PRINTCLIENT message to the PictureBox.  You create a DC and pass it to the control as a parameter of the message.  If the control handles that message it will draw itself into the DC.

You could use GetPixel to test the image.  Alternatively, you can get the image into memory by using CreateDIBSection to allocate a memory buffer for the image, select the created DIB into a second DC then use BitBlt to copy the image into the buffer.
ASKER CERTIFIED SOLUTION
Avatar of inthedark
inthedark
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dvplayltd

ASKER

To satsumo

>>Are you trying to detect a black screen or no change in the picture?

I'm trying to detect no change in picture. It should be fast and to not consume many resourses. The images will be in same widht, height and colour scheme, but I believe they will get different size in memory. May be best will be to check how much size in memory they take and if it is different, then the images are different.   But how ?

Please, give me API call, you may use C or C++, I'll do it in VB6.

To inthedark

Seems to me too many resourses to copy all bytes of the image on different memory. How can I get access to the memory of picture and get his size in bytes? Post some code please
I don't know the context of what your working on, if the picture is from a camera and the camera is pointed at a brick wall, then the image will not change, even when the camera is working.  I guess thats no relevant in this case?

Did you understand how to do the API calls in my first comment?
The picture is not from camera, it is from video movies broadcasted from TV channels, so it is always change in a sec. .

Well, I have great practice with API call, but please send me excatly name of API and his order. Will be OK if it is real code in C . I have option to put this code in OCX in C, if I do not manage it under VB6. But I'm sure I'll ..many programmer are surpised what I can do with VB6 and API ... :-)

And again, I need this to be as fast as is possible and to not consume hardware, perfect will be to get just size in bytes in memory.
not complate answer.