Page 1 of 1

TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 1:02 am
by netmaestro
Hurray! :D

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 8:51 am
by Mistrel
If netmaestro is excited enough about this to make a post about it then it must be good! :D

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 12:41 pm
by dige
wow, that must be really important .. never seen Netmeastro so excited before ;-)

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 12:51 pm
by srod
Isn't that API buggy? I mean I read somewhere (on these forums I think) that the function can yield a memory leak on some systems.

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 2:33 pm
by netmaestro
The memory leak only affected Win95 and 98. For my part, I stopped trying to write code that will run on those dinosaurs about three years ago. So for me, it isn't an issue. What is an issue imho is that it is five times faster (no exaggeration) than any alternatives I've seen. And for XP/2000 and up it's solid.

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Thu Oct 01, 2009 7:43 pm
by srod
Yes I thought that it affected only those old relics (Win 95 etc.) and so it's good for me! :wink:

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Fri Oct 02, 2009 12:32 am
by citystate
any chance for a code snippet showing how it can be used?

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Fri Oct 02, 2009 1:54 am
by netmaestro
any chance for a code snippet showing how it can be used?
OK:

Code: Select all

If FileSize(GetTemporaryDirectory()+"girlonchair.bmp") = -1
  InitNetwork()
  If Not ReceiveHTTPFile("http://www.lloydsplace.com/girlonchair.bmp", GetTemporaryDirectory()+"girlonchair.bmp")
    MessageRequester("oops...","Couldn't get image - ending",#MB_ICONERROR)  
  EndIf
EndIf

; If we're still here, we have the image in our temp directory

img = LoadImage(#PB_Any, GetTemporaryDirectory()+"girlonchair.bmp")
w=ImageWidth(img) 
h=ImageHeight(img)

OpenWindow(0, 0, 0, 640, 480, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
x=WindowWidth(0)/2-w/2
y=WindowHeight(0)/2-h/2

Repeat
  EventID = WaitWindowEvent()
  Select EventID
    Case #PB_Event_Repaint
      hDC_Out = StartDrawing(WindowOutput(0))
      hDC_In = CreateCompatibleDC_(#Null)
      oldimg = SelectObject_(hDC_In, ImageID(img))
      TransparentBlt_(hDC_Out,x,y,w,h,hDC_In,0,0,w,h,#White)
      SelectObject_(hDC_In, oldimg)
      DeleteDC_(hDC_In)
      StopDrawing()
  EndSelect
  
Until EventID = #PB_Event_CloseWindow

Re: TransparentBlt_() is imported in 4.40 winx86

Posted: Fri Oct 02, 2009 9:34 am
by dige
Oh, good to know - thx netmeastro