def __init__(self, wnd, w, h, units, bgcolor): self._viewport = Viewport(self, 0, 0, w, h, bgcolor) self._rect = 0, 0, w, h self._wnd = wnd self._bgcolor = bgcolor or (0, 0, 0) import winuser desktop = winuser.GetDesktopWindow() self._ddraw = ddraw.CreateDirectDraw() self._ddraw.SetCooperativeLevel(desktop.GetSafeHwnd(), ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_PRIMARYSURFACE) self._frontBuffer = self._ddraw.CreateSurface(ddsd) self._pxlfmt = self._frontBuffer.GetPixelFormat() ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self._backBuffer = self._ddraw.CreateSurface(ddsd) self._ddbgcolor = self._backBuffer.GetColorMatch(self._bgcolor or (255,255,255)) self._backBuffer.BltFill((0, 0, w, h), self._ddbgcolor)
def __init__(self, wnd, w, h, units, bgcolor): self._viewport = Viewport(self, 0, 0, w, h, bgcolor) self._rect = 0, 0, w, h self._wnd = wnd self._bgcolor = bgcolor or (0, 0, 0) self._ddraw = ddraw.CreateDirectDraw() self._ddraw.SetCooperativeLevel(wnd.GetSafeHwnd(), ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_PRIMARYSURFACE) self._frontBuffer = self._ddraw.CreateSurface(ddsd) self._pxlfmt = self._frontBuffer.GetPixelFormat() ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self._backBuffer = self._ddraw.CreateSurface(ddsd) self._clipper = self._ddraw.CreateClipper(wnd.GetSafeHwnd()) self._frontBuffer.SetClipper(self._clipper) self._ddbgcolor = self._backBuffer.GetColorMatch(self._bgcolor or (255,255,255)) self._backBuffer.BltFill((0, 0, w, h), self._ddbgcolor) self._wnd.HookMessage(self.OnPaint, win32con.WM_PAINT)
def OnCreate(self, params): w, h = self._w, self._h self.__ddraw = ddraw.CreateDirectDraw() self.__ddraw.SetCooperativeLevel(self.GetSafeHwnd(), ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_PRIMARYSURFACE) self.__frontBuffer = self.__ddraw.CreateSurface(ddsd) self.__clipper = self.__ddraw.CreateClipper(self.GetSafeHwnd()) self.__frontBuffer.SetClipper(self.__clipper) self._pxlfmt = self.__frontBuffer.GetPixelFormat() ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self.__backBuffer = self.__ddraw.CreateSurface(ddsd) url = r'D:\ufs\mm\cmif\Build\common\testdoc\testdatampg.mpg' self._mmstream = MMStream(self.__ddraw) self._mmstream.open(url) self._mmstream.run() self.__init_it() self.HookMessage(self.OnTimer, win32con.WM_TIMER) self.__timer_id = self.SetTimer(1, 50)
def OnCreate(self, params): # back buffer size w, h = self.GetClientRect()[2:] self.__ddraw = ddraw.CreateDirectDraw() self.__ddraw.SetCooperativeLevel(self.GetSafeHwnd(), ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_PRIMARYSURFACE) self.__frontBuffer = self.__ddraw.CreateSurface(ddsd) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self.__backBuffer = self.__ddraw.CreateSurface(ddsd) self.__clipper = self.__ddraw.CreateClipper(self.GetSafeHwnd()) self.__frontBuffer.SetClipper(self.__clipper) self._pxlfmt = self.__frontBuffer.GetPixelFormat() # clear back buffer ddcolor = self.__backBuffer.GetColorMatch(self.__bgcolor or (255, 255, 255)) self.__backBuffer.BltFill((0, 0, w, h), ddcolor) self.createDirectDrawQt(self.__ddraw, self._movieRect[2:]) self.HookMessage(self.OnTimer, win32con.WM_TIMER) self.__timer_id = self.SetTimer(1, self.TIMER_TICK)
def createVideoDDS(self, ddobj, size=None): if self._rect is None: return if size is not None: w, h = size else: w, h = self._rect[2:] if ddobj is None: intefacePtr = Qt.GetDDObject() if intefacePtr: ddobj = ddraw.CreateDirectDrawWrapper(intefacePtr) if ddobj: self._ddobj = ddobj ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self._dds = ddobj.CreateSurface(ddsd) Qt.SetDDObject(self._ddobj) Qt.SetDDPrimarySurface(self._dds) self._movie.SetMovieBox((0, 0, w, h)) self._movie.SetMovieActive(1)
def __init_it(self): self.__x = 0 self.__y = 0 self.__vx = 4 # horiz velocity self.__vy = 4 # vert velocity # init animated object filename = r'D:\ufs\mm\cmif\win32\DXMedia\ddraw\test\mark.bmp' self.__img = gear32sd.load_file(filename) if self.__img: self.__cx, self.__cy, depth = gear32sd.image_dimensions_get( self.__img) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(self.__cx, self.__cy) self.__objBuffer = self.__ddraw.CreateSurface(ddsd) hdc = self.__objBuffer.GetDC() if self.__img >= 0: rc = (0, 0, self.__cx, self.__cy) gear32sd.device_rect_set(self.__img, rc) gear32sd.display_desktop_pattern_set(self.__img, 0) gear32sd.display_image(self.__img, hdc) self.__objBuffer.ReleaseDC(hdc) # set source colorkey to black self.__objBuffer.SetColorKey(ddraw.DDCKEY_SRCBLT, (0, 0))
def CreateSurface(self, w, h): ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w,h) dds = self._ddraw.CreateSurface(ddsd) dds.BltFill((0, 0, w, h), self._ddbgcolor) return dds
def createDDSurface(): # create a ddraw surface with this size import ddraw, winuser ddrawobj = ddraw.CreateDirectDraw() ddrawobj.SetCooperativeLevel(winuser.GetDesktopWindow().GetSafeHwnd(), ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_PRIMARYSURFACE) frontBuffer = ddrawobj.CreateSurface(ddsd) frontBuffer.GetPixelFormat() return ddrawobj, frontBuffer
def createDirectDrawQt(self, ddobj, size): w, h = size ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w, h) self.__movieBuffer = ddobj.CreateSurface(ddsd) Qt.InitializeQTML() Qt.EnterMovies() Qt.SetDDObject(ddobj) Qt.SetDDPrimarySurface(self.__movieBuffer) fn = 'D:\\ufs\\mm\\cmif\\win32\\Qt\\media\\fashion.mov' try: movieResRef = Qt.OpenMovieFileWin(fn, 1) except Exception, arg: print arg return
def _initddraw(self): movie_w = self.videodescr['width'] movie_h = self.videodescr['height'] movie_rect = (0, 0, movie_w, movie_h) ddrawobj = ddraw.CreateDirectDraw() ddrawobj.SetCooperativeLevel(0, ddraw.DDSCL_NORMAL) ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(movie_w, movie_h) dds = ddrawobj.CreateSurface(ddsd) pxlfmt = dds.GetPixelFormat() Qt.SetDDObject(ddrawobj) Qt.SetDDPrimarySurface(dds) self._ddrawobj = ddrawobj self._dds = dds self.pxlfmt = pxlfmt self.movie.SetMovieBox(movie_rect) self.movie.SetMovieActive(1) self.movie.MoviesTask(0) self.movie.SetMoviePlayHints(winqtcon.hintsHighQuality, winqtcon.hintsHighQuality)
h = 300 ########################################### import ddraw # create direct draw stuff ddrawobj = ddraw.CreateDirectDraw() # we need a window here, so use desktop import win32ui Sdk = win32ui.GetWin32Sdk() ddrawobj.SetCooperativeLevel(Sdk.GetDesktopWindow().GetSafeHwnd(), ddraw.DDSCL_NORMAL) # create our dd surface ddsd = ddraw.CreateDDSURFACEDESC() ddsd.SetFlags(ddraw.DDSD_WIDTH | ddraw.DDSD_HEIGHT | ddraw.DDSD_CAPS) ddsd.SetCaps(ddraw.DDSCAPS_OFFSCREENPLAIN) ddsd.SetSize(w,h) dds = ddrawobj.CreateSurface(ddsd) pxlfmt = dds.GetPixelFormat() ddcolor = dds.GetColorMatch((0,0,255)) dds.BltFill((0, 0, w, h), ddcolor) filename1 = r'D:\ufs\mmdocuments\interop2\interop2\images\frown.jpg' filename2 = r'D:\ufs\mmdocuments\interop2\interop2\images\smile.jpg' ########################################### # record manually coded presentation