|
-
May 3rd, 2002, 09:13 AM
#1
Thread Starter
New Member
video and picture boxes...
I need help in VB6 !
I have a MCI Multimedia Control and I want to play and process some video in a pictureBox (from different source: Avi files or video hardware).
I have a dll for image processing which need to copy the picture into the memory (for processing). It requires a Device Context and the hWnd property of the pictureBox:
Code:
ImageToMemory Picture1.hDC, Picture1.hWnd, Width, Height
The hWnd property doesn't seem to be important. So I don't know how to have the device context for a video stream that I could use with this function.
Moreover, user can move and resize a region of interest on the pictureBox with the mouse.
So, in a first time, I used two pictureBoxes, one was invisible and contained the original picture and the second picture used for display. When this picture was repaint I used paintpicture method and this worked fine.
Now, I want to process some video with the MMcontrol, so I had to change the paintpicture method into BitBlt.
For simple image I create a DC with CreatCompatibleDC and I use SelectObject to affect the bitmap I want.
But for video I can't find a DC of the MMcontrol except if I set MMcontrol.hWndDisplay to Picture1.hWnd and Picture1 is visible.
If Picture1 if partially hidden or not visible the bitblt function copy that is over the picture... and that very evil...
Do you understand my problem ?
-
May 4th, 2002, 03:19 AM
#2
Frenzied Member
well with the problem that it only copies the stuff partially or what's on top of it, you just need to set the autoredraw property of the source to TRUE
I don't really get your other questions... about that HWND for example. can you explain?
Sanity is a full time job
Puh das war harter Stoff!
-
May 6th, 2002, 08:47 AM
#3
Thread Starter
New Member
I've already put the autoredraw property to true but there is nothing in the device context of the hidden picture pox...
I'd like to do this:
In a image recognition application the user can load a bitmap or an avi video or a video capture hardware to learn or recognize patterns.
This image or video is displayed in a picture box and over it I draw two rectangles representing the region of scanning and the region of interrest for learning.
An other device is needed because those rectangles obstruct the image and I need a device context for calling image processing function.
What I've done for images works:
Loading...
Code:
Img = False 'false:video, true:image
CommonDialog1.DialogTitle = "Chargement d'un média"
CommonDialog1.FileName = ""
CommonDialog1.Filter = "Image (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif|MetaFile (*.emf;*.wmf)|*.emf;*.wmf|Video (*.avi)|*.avi"
CommonDialog1.ShowOpen
imgStr = CommonDialog1.FileName
tmpStr = Space(256)
imgStr = left(tmpStr, GetShortPathName(imgStr, tmpStr, 256))
If imgStr <> "" Then
If mmDC <> 0 Then
DeleteDC mmDC 'deleting the old dc
mmDC = 0
End If
Picture1.Cls 'the user view
If CommonDialog1.FilterIndex < 3 Then
'picture
Dim DBitmap As Bitmap
mmDC = CreateCompatibleDC(0)
If mmDC <> 0 Then
Picture2.Picture = LoadPicture(imgStr)
Img = True
SelectObject mmDC, Picture2.Picture
GetObject Picture2.Picture, Len(DBitmap), DBitmap
H = DBitmap.bmHeight
W = DBitmap.bmWidth
'loading image for processing
ImageToMemory mmDC, PictureImg.picture, W, H
Else
MsgBox "Error creating multimedia device context", _
vbOKOnly Or vbExclamation, "Loading"
End If
Else
'video
MMControl1.Command = "close"
MMControl1.DeviceType = "avivideo"
MMControl1.hWndDisplay = PictureImg.hWnd
MMControl1.FileName = imgStr
MMControl1.Command = "open"
MMControl1.Command = "back"
mmDC = PictureImg.hdc
End If
End If
I add the code in a timer when this is a video:
Code:
ImageToMemory mmDC, PictureImg.picture, W, H
This function is used for image processing
displaying
Code:
BitBlt Picture1.hdc, 0, 0, W, H, _
mmDC, ScaleX(HScroll1.Value, 1, 3), _
ScaleY(VScroll1.Value, 1, 3), &HCC0020 'srccpy
If CheckROS.Value Then
Picture1.Line (RosCoord(0) - ScaleX(HScroll1.Value, 1, 3), _
RosCoord(1) - ScaleY(VScroll1.Value, 1, 3))- _
(RosCoord(2) - ScaleX(HScroll1.Value, 1, 3), _
RosCoord(3) - ScaleY(FVScroll(6).Value, 1, 3)), _
RosColor, B
End If
If CheckROI.Value Then
Picture1.Line (RoiCoord(0) - ScaleX(HScroll1.Value, 1, 3), _
RoiCoord(1) - ScaleY(VScroll1.Value, 1, 3))- _
(RoiCoord(2) - ScaleX(HScroll1.Value, 1, 3), _
RoiCoord(3) - ScaleY(VScroll1.Value, 1, 3)), _
RoiColor, B
End If
This isn't working fine when I try to load a video...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|