Posted: Sat Dec 10, 2005 11:42 am
I've been banging my head against this one for a bit. I can get your example to work great but when I try to merge it into my code, it fails. Only a pure black image is outputted. Here's a snippet of the code that does the work.
Hopefully that kind of makes sense. It's just a part of the whole but it's the part that does the work. "t1.bmp" is saved correctly. It's the image/mask. It is mostly blue except for an image. "t2.bmp" is also correct and contains the background image. "t3.bmp" should be a combination of t1 & t2 with t2 as the background and t1 pasted on top. However, "t3.bmp" is just a pure black image when it is saved. I don't understand what's wrong. I'm using Mischa's version and his demonstration works perfectly for my t1 & t2 images.
Am I making an obvious mistake somewhere?
EDIT: I figured it out with El_Choni's wonderful help. It was the SelectObject_() line causing problems. Once that is removed, it's fine. Also, I needed to change the GetDC_() to use GetDesktopWindow_().
Thanks, El_Choni!
Code: Select all
*xVideo\AVS\pGetFrame = CallFunctionFast(_VideoAddress\AVIStreamGetFrameOpen, *xVideo\AVS\pAVIStream, #AVIGETFRAMEF_BESTDISPLAYFMT)
;
*bih = CallFunctionFast(_VideoAddress\AVIStreamGetFrame, *xVideo\AVS\pGetFrame, inFrame)
;
If *bih
;
hDC = GetDC_(ImageID(*xVideo\ImageSubtitle))
;
hCDC = CreateCompatibleDC_(hDC)
;
If hCDC
;
SelectObject_(hCDC, ImageID(*xVideo\ImageSubtitle))
;
SetDIBits_(hCDC, ImageID(*xVideo\ImageSubtitle), 0, *bih\biHeight, *bih + SizeOf(BITMAPINFOHEADER), *bih, #DIB_RGB_COLORS)
;
SaveImage(*xVideo\ImageSubtitle, "t1.bmp")
;
;DrawImage(ImageID(*xVideo\ImageSubtitle), 0, 0)
dcVideo = StartDrawing(ImageOutput(*xVideo\ImageVideo))
;
If dcVideo
;
mciSendString_("update "+*xVideo\Alias+" hdc "+Str(dcVideo)+" wait", #Null, 0, 0)
;
SaveImage(*xVideo\ImageVideo, "t2.bmp")
;
DrawTransparentImage(dcVideo, ImageID(*xVideo\ImageSubtitle), 0, 0, *xVideo\Properties\Width, *xVideo\Properties\Height, RGB(0, 0, 255))
;
StopDrawing()
;
SaveImage(*xVideo\ImageVideo, "t3.bmp")
;
EndIf
;
DeleteDC_(hCDC)
;
EndIf
;
ReleaseDC_(ImageID(*xVideo\ImageSubtitle), hDC)
;
; SetGadgetState(*xVideo\idParent, ImageID(*xVideo\ImageVideo))
;
EndIf
;
CallFunctionFast(_VideoAddress\AVIStreamGetFrameClose, *xVideo\AVS\pGetFrame) : *xVideo\AVS\pGetFrame = 0
Am I making an obvious mistake somewhere?
EDIT: I figured it out with El_Choni's wonderful help. It was the SelectObject_() line causing problems. Once that is removed, it's fine. Also, I needed to change the GetDC_() to use GetDesktopWindow_().
Thanks, El_Choni!