Demo of what it would do:
Code: Select all
Procedure RI(simg.i)
iw = ImageWidth(simg)
ih = ImageHeight(simg)
win = OpenWindow(#PB_Any,0,0,iw,ih,"Report image",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
imgad = ImageGadget(#PB_Any,0,0,iw,ih,ImageID(simg))
escapekey = 1
spacekey = 2
returnkey = 3
AddKeyboardShortcut(win,#PB_Shortcut_Escape,escapekey)
AddKeyboardShortcut(win,#PB_Shortcut_Space,spacekey)
AddKeyboardShortcut(win,#PB_Shortcut_Return,returnkey)
killtime = ElapsedMilliseconds()+timelimit
Repeat
we = WindowEvent()
If we
If we=#PB_Event_Menu
Break
EndIf
Else
Delay(10)
EndIf
If timelimt>0 And ElapsedMilliseconds()>killtime : Break : EndIf
ForEver
CloseWindow(win)
EndProcedure
Procedure.l AlphaAdjust(x, y, SourceColor.l, TargetColor.l)
new_alpha.d = Alpha(TargetColor) / 255 * Alpha(SourceColor)
ProcedureReturn RGBA(Red(TargetColor),Green(TargetColor),Blue(TargetColor),new_alpha)
EndProcedure
iw = 400
ih = 400
; create the alpha adjuster...
alpha_img = CreateImage(#PB_Any,iw,ih,32,#PB_Image_Transparent)
StartDrawing(ImageOutput(alpha_img))
DrawingMode(#PB_2DDrawing_AlphaBlend)
For x = 0 To iw Step 40
alp.d = 255 - (255 / iw * x)
Box(x,0,40,ih,RGBA(0,0,0,alp))
Next x
StopDrawing()
; create a solid red image
img = CreateImage(#PB_Any,iw,ih,32,RGBA(255,0,0,255))
; apply the alpha adjuster to it...
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_CustomFilter) : CustomFilterCallback(@AlphaAdjust())
DrawAlphaImage(ImageID(alpha_img),0,0)
StopDrawing()
; draw the adjusted image over a solid blue background...
demo_img = CreateImage(#PB_Any,iw,ih,32,#Blue)
StartDrawing(ImageOutput(demo_img))
DrawAlphaImage(ImageID(img),0,0)
StopDrawing()
RI(demo_img)