Echtzeit-Bildmanipulation Spielerei...
$I compatible.inc
cls
long hpic=create("hnewPic",256,256,0)
startPaint hPic
useFont "Arial",26,0,0,0,0
textcolor $FFFFFF,0
drawText 10,10,"Hallo Welt"
endPaint
drawPic hPic,0,0;0
while 1
filterTest(hPic,%bmpx,%bmpy)
drawSizedPic hPic,0,0 - width(%hWnd),height(%hWnd);0
startPaint hPic
useFont "Arial",26,0,0,0,0
textcolor $FFFFFF,-1
drawText sin(getTickCount*0.001)*75+75,sin(getTickCount*0.00077777)*110+110,"Hallo Welt"
textcolor $0000FF,-1
drawText -sin(getTickCount*0.001)*75+75,sin(getTickCount*0.00088887)*110+110,"Hallo Welt"
textcolor $FF0000,-1
drawText -sin(getTickCount*0.0013)*75+75,-sin(getTickCount*0.00088887)*110+110,"Hallo Welt"
textcolor $00FF00,-1
drawText sin(getTickCount*0.0023)*75+75,-sin(getTickCount*0.00022222)*110+110,"Hallo Welt"
endpaint
waitinput 10
wend
//mcopysizedbmp 0,0 - 767,255 > 0,0 - width(hWnd),height(hWnd);0
waitinput
end
nProc filterTest
Parameters h&,_width&,_height&
var a&=GetPixels(h&,_width&,_height&)
filter.dith(a&,_width&,_height&)
filter.blur(a&,_width&,_height&)
SetPixels(h&,a&,_width&,_height&)
dispose(a&)
endproc
nProc filter.dith
parameters a&,_width&,_height&
var x&=0
var y&=0
var c&=0
var p&=0
var ww4&=_width&*4
whileLoop _height&-1,0
y&=&loop*ww4&
whileLoop 0,ww4&-4,4
p&=y&+&loop
c&=long(a&,p&)
ifnot rnd(10)
c&=rgb.mix(c&,rnd($FFFFFF))
endif
long a&,p&=c&
wend
wend
endproc
nProc filter.blur
parameters a&,_width&,_height&
var x&=0
var y&=0
var c&=0
var c2&=0
var p&=0
var p1&=0
var p2&=0
var p3&=0
var p4&=0
var p6&=0
var p7&=0
var p8&=0
var p9&=0
var r&=0
var g&=0
var b&=0
var ww4&=_width&*4
whileLoop _height&-1,0
y&=&loop*ww4&
whileLoop 0,ww4&-4,4
p&=y&+&loop
c&=long(a&,p&)
c&=rgb.mix(rgb.mix(rgb.mix(rgb.mix(long(a&,p&-4),long(a&,p&+4)),long(a&,p&)),long(a&,p&-ww4&)),long(a&,p&+ww4&))
p1&=long(a&,p&+ww4&-4)
p2&=long(a&,p&+ww4&+4)
p3&=long(a&,p&+ww4&)
p4&=long(a&,p&-4)
p6&=long(a&,p&+4)
p7&=long(a&,p&-ww4&-4)
p8&=long(a&,p&-ww4&+4)
p9&=long(a&,p&-ww4&)
r&=getRValue(p1&)+getRValue(p2&)+getRValue(p3&)+getRValue(p4&)+getRValue(c&)+getRValue(p6&)+getRValue(p7&)+getRValue(p8&)+getRValue(p9&)
g&=getGValue(p1&)+getGValue(p2&)+getGValue(p3&)+getGValue(p4&)+getGValue(c&)+getGValue(p6&)+getGValue(p7&)+getGValue(p8&)+getGValue(p9&)
b&=getBValue(p1&)+getBValue(p2&)+getBValue(p3&)+getBValue(p4&)+getBValue(c&)+getBValue(p6&)+getBValue(p7&)+getBValue(p8&)+getBValue(p9&)
div r&,9
div g&,9
div b&,9
long a&,p&=bgr(r&,g&,b&)
wend
wend
endproc
nproc rgb.mix
parameters c1&,c2&
var r&=getRValue(c1&)+getRValue(c2&)
div r&,2
var g&=getGValue(c1&)+getGValue(c2&)
div g&,2
var b&=getBValue(c1&)+getBValue(c2&)
div b&,2
return rgb(r&,g&,b&)
endproc