BitBlt_() and the new 2D Lib (PB4.4x)
Posted: Wed Feb 03, 2010 5:25 pm
I use a nice API code, to copy images faster than
PB's CopyImage().
But I've got some IMA Errors since PB4.40 and
unfortunately I was'nt able to find a reproducable
way..
So I ask myself, is this way of copy still valid?
What do you think?
PB's CopyImage().
But I've got some IMA Errors since PB4.40 and
unfortunately I was'nt able to find a reproducable
way..
So I ask myself, is this way of copy still valid?
What do you think?
Code: Select all
Procedure.l CopyImageEx( SourceID.l, DestID.l ) ; Result: DestID, -1 = Failed
Protected success.b, ImgID.i
If IsImage( SourceID )
bmp.l = ImageID(SourceID)
w.l = ImageWidth(SourceID)
h.l = ImageHeight(SourceID)
d.l = ImageDepth(SourceID)
DC.l = CreateCompatibleDC_(#Null)
If Not DC : ProcedureReturn -1 : EndIf
NewImgID = CreateImage( DestID, w, h, d)
If DestID = #PB_Any : DestID = NewImgID : EndIf
If IsImage(DestID)
If SelectObject_(DC, bmp)
tdc = StartDrawing( ImageOutput(DestID) )
If tdc
BitBlt_(tdc,0,0,w,h,DC,0,0,#SRCCOPY)
StopDrawing()
success = #True
EndIf
EndIf
EndIf
DeleteDC_(DC)
EndIf
If Not success
DestID = -1
EndIf
ProcedureReturn DestID
EndProcedure
CreateImage(0, 100, 100, 1)
CreateImage(1, 100, 100, 2)
CreateImage(2, 100, 100, 4)
CreateImage(3, 100, 100, 8)
CreateImage(4, 100, 100, 16)
CreateImage(5, 100, 100, 24)
CreateImage(6, 100, 100, 32)
CreateImage(7, 100, 100)
CreateImage(8, 100, 100, #PB_Image_DisplayFormat)
For n = 0 To 8
Debug Str(ImageDepth(n)) + "Bit, Result: " + Str(CopyImageEx(n, #PB_Any))
Next