Code: Alles auswählen
; BitBlt simple - Werner Albus
UseJPEGImageDecoder()
UsePNGImageDecoder()
ExamineDesktops()
Global timer_event_1,timer_event_2
Procedure timer_events()
Select EventTimer()
Case 1
timer_event_1=1
Case 2
timer_event_2=1
EndSelect
EndProcedure
Procedure bitblt(bitmap1_hnd,source_x,source_y, bitmap2_hnd ,target_x,target_y, wide,height, mode, main_dc)
source_dc = CreateCompatibleDC_(main_dc)
target_dc = CreateCompatibleDC_(main_dc)
SelectObject_(source_dc,bitmap1_hnd)
SelectObject_(target_dc,bitmap2_hnd)
BitBlt_(target_dc,target_x,target_y,wide,height,source_dc,source_x,source_y,mode)
DeleteDC_(source_dc)
DeleteDC_(target_dc)
EndProcedure
Procedure stretchblt(bitmap1_hnd,source_x,source_y, bitmap2_hnd ,target_x,target_y, stretch_x,stretch_y, wide,height, mode, main_dc)
source_dc = CreateCompatibleDC_(main_dc)
target_dc = CreateCompatibleDC_(main_dc)
SelectObject_(source_dc,bitmap1_hnd)
SelectObject_(target_dc,bitmap2_hnd)
StretchBlt_(target_dc,target_x,target_y,wide,height,source_dc,source_x,source_y, stretch_x, stretch_y,mode)
DeleteDC_(source_dc)
DeleteDC_(target_dc)
EndProcedure
Procedure mirror_x(image)
width = ImageWidth(image)
height = ImageHeight(image)
bitmap_hnd = StartDrawing(ImageOutput(image))
StretchBlt_(bitmap_hnd,width,0,-width,height,bitmap_hnd,0,0,width,height, #SRCCOPY)
StopDrawing()
EndProcedure
Procedure mirror_y(image)
width = ImageWidth(image)
height = ImageHeight(image)
bitmap_hnd = StartDrawing(ImageOutput(image))
StretchBlt_(bitmap_hnd,0,height,width,-height,bitmap_hnd,0,0,width,height, #SRCCOPY)
StopDrawing()
EndProcedure
main_whnd = OpenWindow(0,DesktopWidth(0)/2-400,DesktopHeight(0)/2-400,800,800,"Demo")
main_dc = GetDC_(WindowID(0)) ; Device Context
AddWindowTimer(0,1,5)
AddWindowTimer(0,2,2000)
BindEvent(#PB_Event_Timer, @timer_events())
LoadImage(0,#PB_Compiler_Home+"\Examples\3D\Data\Textures\soil_wall.jpg")
LoadImage(2,#PB_Compiler_Home+"\Examples\3D\Data\Textures\geebee2.bmp")
;---------------------------------
CreateImage(1,800,800)
CopyImage(2,3)
stretchblt(ImageID(0),0,0, ImageID(1) ,0,0, 512,512, 800,800, #SRCCOPY ,main_dc)
StartDrawing(ImageOutput(2))
transparent=Point(0,0) ; Transparente Farbe aus linker oberer Ecke holen
For i=0 To ImageWidth(2)-1
For ii=0 To ImageHeight(2)-1
If Point(i,ii)<>transparent
Plot(i,ii,0)
Else
Plot(i,ii,$FFFFFF)
EndIf
Next ii
Next i
StopDrawing()
StartDrawing(ImageOutput(3))
transparent=Point(0,0) ; Transparente Farbe aus linker oberer Ecke holen
For i=0 To ImageWidth(3)-1
For ii=0 To ImageHeight(3)-1
If Point(i,ii)=transparent
Plot(i,ii,0)
EndIf
Next ii
Next i
StopDrawing()
x_go=2 : y_go=1 : xx_go=1 : yy_go=2
Repeat
If timer_event_1
timer_event_1=0
x+x_go : y+y_go
If x>700 : x_go=-x_go : EndIf
If x<0 : x_go=-x_go : EndIf
If y>700 : y_go=-y_go : EndIf
If y<0 : y_go=-y_go : EndIf
xx+xx_go : yy+yy_go
If xx>650 : xx_go=-xx_go : EndIf
If xx<0 : xx_go=-xx_go : EndIf
If yy>650 : yy_go=-yy_go : EndIf
If yy<0 : yy_go=-yy_go : EndIf
stretchblt(ImageID(0),0,0, ImageID(1) ,0,0, 512,512, 800,800, #SRCCOPY ,main_dc)
bitblt(ImageID(2),0,0, ImageID(1) ,x,y, 480,160 ,#SRCAND ,main_dc)
bitblt(ImageID(3),0,0, ImageID(1) ,x,y, 480,160 ,#SRCINVERT ,main_dc)
If timer_event_2
timer_event_2=0
mirror_y(2)
mirror_y(3)
EndIf
stretchblt(ImageID(2),0,0, ImageID(1) ,xx,yy, 128,128, 200,200, #SRCAND ,main_dc)
stretchblt(ImageID(3),0,0, ImageID(1) ,xx,yy, 128,128, 200,200, #SRCINVERT ,main_dc)
StartDrawing(WindowOutput(0))
DrawImage(ImageID(1),0,0)
StopDrawing()
EndIf
Repeat
event=WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit=1
EndSelect
Until event=0
Until quit
ReleaseDC_(main_whnd,main_dc) ; ----------DC freigeben----------