blting from stdpicture to primary surface

ochensati
05-23-2002, 11:57 AM
Ok I got bliting from the primary surface to a picturebox down and that works great. But when I try to go the other direction to put in a background, I completely fail. All I get is a black screen


Dim jj As Long, sky as stdpicture
Set sky = LoadPicture(App.Path + "\sky.bmp")
frmD(CURfloor).Canvas.AutoRedraw = True
jj = BitBlt(frmD(CURfloor).Canvas.hdc, 0, 0, _
frmD(CURfloor).Canvas.ScaleWidth, frmDCURfloor).Canvas.ScaleHeight ,
sky.Handle, 0, 0, SRCCOPY)
frmD(CURfloor).Canvas.Picture = frmD(CURfloor).Canvas.Image



I am just trying to get the stdpicture to a picture box and all I get is a black screen. The return value is always zero, but the results are definitly bad!

For the directx try I have

Dim jj As Long,sky as stdpicture
dim hdc as long
Device.BeginScene
hdc = Back.GetDC
jj = BitBlt(hdc, 0, 0, Width, Height , sky.Handle, 0, 0, SRCCOPY)
Back.ReleaseDC hdc
'render 3d stuff
Device.EndScene

Dim r1 As RECT 'The screen size
'Gets the bounding rect for the entire window handle, stores in r1
Call dx.GetWindowRect(BackO.hwnd, r1)
Call Primary.Blt(r1, Back, ScreenRect, DDBLT_WAIT)





This method works great if I use a DIB, but I would like the speed of a normal bitmap and the ease of manipulation.

ochensati
05-23-2002, 02:12 PM
Ok I did a search and found some code from billsoo and thehand that gets the stdpicture onto a picturebox as such



'calling code
dim sky as stdpicture
Set sky = LoadPicture(filename)
Call PostPicture(frmD(CURfloor).Canvas.hdc, frmD(CURfloor).Canvas.width / Screen.TwipsPerPixelX, frmD(CURfloor).Canvas.height / Screen.TwipsPerPixelY, sky)


'procedure

Public Sub PostPicture(hdc As Long, width As Long, height As Long, ByRef aPic As StdPicture)
Dim aDC As Long
Dim origBmp As Long
Dim hgt As Long
Dim wid As Long
wid = F3D.ScaleX(aPic.width, vbHimetric, vbPixels)
hgt = F3D.ScaleY(aPic.height, vbHimetric, vbPixels)

aDC = CreateCompatibleDC(hdc)
origBmp = SelectObject(aDC, aPic.Handle)
'Me.Picture1.Cls


Call GetObject(aPic, Len(udtBitMap), udtBitMap)

With udtMemPicSize
.x = udtBitMap.bmWidth
.y = udtBitMap.bmHeight

MemPicWidth = .x
MemPicHeight = .y

End With



StretchBlt hdc, 0, 0, width, height, aDC, 0, 0, wid, hgt, vbSrcCopy
SelectObject aDC, origBmp
DeleteDC aDC
DeleteObject origBmp


End Sub



And this works, but when I try this with a directx surface as


Device.BeginScene
hdc = Back.GetDC
Call PostPicture(hdc, 200, 200, sky)
Back.ReleaseDC hdc

'3d rendering stuff


'Call EndScene when finished rendering

Device.EndScene


I just get a black screen. Any hints as to where I am going wrong with this new code?

edit/ Use [/code] instead of [\code] :)

Squirm
05-23-2002, 02:31 PM
Just a guess, but I have always used API with surfaces outside the BeginScene...EndScene block.

:-\

ochensati
05-28-2002, 10:03 AM
Thank you Squirm. That worked great.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum