Reading Pixel Values In a Movie

Just starting out? Need help? Post your questions and find answers here.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Reading Pixel Values In a Movie

Post by Mijikai »

chris319 wrote:Here is what I got from somebody else's demo program. It uses CreateDIBSection()

Code: Select all

hImage = CreateDIBSection_(ndc, bmi, #DIB_RGB_COLORS, @*buffer1, 0, 0)

Now what do I do with himage? Can it be made into a conventional PB image?
Its just the handle to the created DIB-Section.

I just posted a module for screen capture - take a look ;)

http://www.purebasic.fr/english/viewtop ... 12&t=69266
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Reading Pixel Values In a Movie

Post by chris319 »

Here is a much-simplified version of my program.

Thank you for your help.

Code: Select all

   ;*************** TURN OFF THE DEBUGGER! ****************
DisableDebugger
#CAPTUREBLT = $40000000 ; Necessary for BitBlt to get layered windows if present on screen

InitMovie()
    Global width = 640
    Global height = 360

    dc = CreateDC_("DISPLAY",0,0,0)
    ndc = CreateCompatibleDC_(0)

    bmi.BITMAPINFO
    bmi\bmiHeader\biSize     = SizeOf(BITMAPINFOHEADER)
    bmi\bmiHeader\biWidth    = width
    bmi\bmiHeader\biHeight   = -height ; Otherwise colors in the buffer will be backwards, "bottom-up" which we don't want
    bmi\bmiHeader\biPlanes   = 1
    bmi\bmiHeader\biBitCount = 32
    bmi\bmiHeader\biCompression = #BI_RGB

; hImage = CreateDIBSection_(ndc, bmi, #DIB_RGB_COLORS, @*buffer1, 0, 0)
;     If hImage
;       DeleteObject_(SelectObject_(ndc, hImage))
;       BitBlt_(ndc, 0,0,width,height,dc,0,0,#SRCCOPY|#CAPTUREBLT)
;       DeleteDC_(dc)
;       DeleteDC_(ndc)
;     EndIf

LoadMovie(1,"handsfree big load.mp4")
;LoadMovie(1,"your movie title.mp4")
MovieAudio(1,0,0)
ResizeMovie(1,0,0,640,360)

hWnd = OpenWindow(1,0,0,1280,720,"",#PB_Window_SystemMenu)
AddKeyboardShortcut(1, #PB_Shortcut_Control|#PB_Shortcut_Q, 113);CTL Q TO QUIT

;FOR TESTING BLITTER
;  StartDrawing(WindowOutput(1))
;  Box(0,0,200,200,#Blue)
;  StopDrawing()

CreateImage(1,width,height,24)

PlayMovie(1,WindowID(1)) ;: Delay(duration * 1000)
Delay(500):PauseMovie(1)
Repeat: Until MovieStatus(1) <= 0

hImage = CreateDIBSection_(ndc, bmi, #DIB_RGB_COLORS, @*buffer1, 0, 0)
    If hImage
      DeleteObject_(SelectObject_(ndc, hImage))
      BitBlt_(ndc, 0,0,width,height,dc,0,0,#SRCCOPY|#CAPTUREBLT)
      DeleteDC_(dc)
      DeleteDC_(ndc)
    EndIf

;hdcDest = StartDrawing(ImageOutput(1))
;hDCsrc = GetDC_(WindowID(1))
;BitBlt_(hdcDest, 0, 0, 640, 360,hDCsrc, 0,0,#SRCCOPY|#CAPTUREBLT)
;StopDrawing()

StartDrawing(WindowOutput(1))
DrawImage(ImageID(1),0,360)
StopDrawing()

Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
FreeMovie(1)
FreeImage(1)
ReleaseDC_(hWnd,hDCsrc)
CloseWindow(1)
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Reading Pixel Values In a Movie

Post by chris319 »

I'll have a look at your new code in a while.

I've got the blitter working perfectly on drawn images. Will your new code work with a movie? Have you tested it with a movie? Movies seem to be the hangup.

In the demo program I posted above, it plays one second of video, then pauses. If it worked properly, you would see the actual movie playback above and a duplicate image below. If you turn off movie playback and draw the blue box, you can see that we can blit the blue box into the lower rectangle.
Post Reply