Bild-Uglynator

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Kabelbinder

Sieger des WM-Contest 2006

Betreff: Bild-Uglynator

BeitragDo, Sep 09, 2004 15:43
Antworten mit Zitat
Benutzer-Profile anzeigen
Das Ding hier erzeugt ganz nette Effekte. Sieht ein bisschen aus, wie mit Nachtsicht-gerät gesehen. Einen ähnlichen Effekt benutzen glaub ich auch Nightwish in ihrem Musikvideo zu Nemo.

Ihr braucht nur noch ein Bild (ich hab das Cover von WarcraftIII genommen Surprised ) und ihr müsst dessen Höhe, Breite und Pfad in den Quelltext mit einbringen.

BlitzBasic: [AUSKLAPPEN]
AppTitle "Bild-Uglynator"
Graphics 640,480,16,1
bild = LoadImage("Images/WarcraftIII.bmp")
Const breit = 356
Const hoch = 356

result = CreateImage(breit,hoch)
SetBuffer ImageBuffer(result)
DrawBlock bild,0,0

For i = 0 To hoch
For j = 0 To breit
wert = ReadPixel(j,i)
r = (wert And $FF0000)/$10000
g = (wert And $FF00)/$100
b = (wert And $FF)
stufe = (r+g+b)/3
Color 255-stufe,255-stufe,255-stufe
;Color stufe,stufe,stufe
Plot j,i
Next
Next

SetBuffer FrontBuffer()

Cls
DrawBlock bild,0,0
WaitKey

Cls
DrawBlock result,0,0
WaitKey

End
<Wing Avenger Download> ◊◊◊ <Macrophage Download>

Bms

BeitragDo, Sep 09, 2004 17:14
Antworten mit Zitat
Benutzer-Profile anzeigen
nicht schlecht!
man könnte ja versuchen, das bild immer "farbloser" werden zu lassen(vielleicht for-next-schleife und die 255 verändern)

statt "hoch" und "breit" kannst du auch imagewidth() und imageheight() benutzen. aber dann const weglassen(sonst kommt "expression must be constant")

Bms

BeitragDo, Sep 09, 2004 17:30
Antworten mit Zitat
Benutzer-Profile anzeigen
habs mal versucht:

BlitzBasic: [AUSKLAPPEN]

AppTitle "Bild-Uglynator"
Graphics 640,480,16,1
bild = LoadImage("c:/eigene dateien/halt ne bitmap.bmp")
breit = ImageWidth(bild)
hoch = ImageHeight(bild)
result=CreateImage(breit,hoch)
For a=0 To 255 Step 15
SetBuffer ImageBuffer(result)
DrawBlock bild,0,0
For i = 0 To hoch
For j = 0 To breit
wert = ReadPixelFast(j,i)
r = (wert And $FF0000)/$10000
g = (wert And $FF00)/$100
b = (wert And $FF)
stufe = (r+g+b)/3
Color a-stufe,a-stufe,a-stufe
Plot j,i
Next
Next
SetBuffer FrontBuffer()
Cls
DrawBlock result,0,0
Color 255,0,0
Text 300,300,a,1,1
If KeyDown(1)Then End
Next
End
 

walski

Ehemaliger Admin

BeitragDo, Sep 09, 2004 18:27
Antworten mit Zitat
Benutzer-Profile anzeigen
Mit WritePixelFast wärs sicher etwas flotter! Wink

walski
buh!

Lord_Vader

BeitragDo, Sep 09, 2004 22:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Shocked mhh also erm bisher kommt bei mir noch kein bild.
Naja wie auch immer aber das is schon extrem lang wenn es irgentwann kommen sollte lol!

Edit: Ok jez fertig...naja toller effekt, hab ich mir schon gedacht bei der codelänge lol!
 

walski

Ehemaliger Admin

BeitragFr, Sep 10, 2004 0:01
Antworten mit Zitat
Benutzer-Profile anzeigen
Nochmal eine tolle Spielerei damit:

BlitzBasic: [AUSKLAPPEN]

; just a little crap-routine
; (c) 2004 by T. Schroeder a.k.a. walski

Const screenmode_default = 0
Const screenmode_fullscreen = 1
Const screenmode_windowed = 2

Const screen_width = 800
Const screen_height = 600
Const screen_depth = 32
Const screen_mode = screenmode_fullscreen

Graphics screen_width,screen_height,screen_depth,screen_mode
SetBuffer BackBuffer()

Const key_up = 200
Const key_down = 208
Const key_space = 57
Const key_return = 28
Const key_enter = 156
Const key_ctrlLeft = 29
Const key_ctrlRight = 157
Const key_one = 2
Const key_two = 3
Const key_three = 4
Const key_four = 5
Const key_shiftLeft = 42
Const key_shiftRight = 54

Local cmdLine$

cmdLine = CommandLine()

Local oIMG%,oIMG_width%,oIMG_height%

If cmdLine <> "" Then

oIMG = LoadImage( cmdLine )

EndIf
If cmdLine = "" Or oIMG = 0 Then

oIMG = LoadImage( "default.bmp" )

EndIf

If oIMG = 0 Then

RuntimeError( "Both the commandline-parameter and the default.bmp seems not to exist or can not be loaded." + Chr(10) + Chr(13) + "The program is aborting now." )

EndIf

oIMG_width = ImageWidth( oIMG )
oIMG_height = ImageHeight( oIMG )


Local curFactor%

curFactor = 100

Local autoCrapMode%

autoCrapMode = 0

Local crapMode%,crapModeDesc$[3]

crapMode = 0
crapModeDesc[0] = "AND"
crapModeDesc[1] = "OR"
crapModeDesc[2] = "XOR"
crapModeDesc[3] = "INV"


Local crapImage%

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

Local redInfoMode%

redInfoMode = 0

Local oldR%,oldG%,oldB%

While Not KeyHit(1)

Cls

; slow more ( press the "up"-key )
If KeyHit( key_up ) Then

curFactor = curFactor + 100

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

; slow less ( press the "down"-key )
If KeyHit( key_down ) Then

curFactor = curFactor - 100

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

; fast more ( hold down control and the "up-key" )
If KeyDown( key_ctrlLeft ) Or KeyDown( key_ctrlRight ) Then

If KeyDown( key_up ) Then

curFactor = curFactor + 100

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

EndIf

; fast less ( hold down control and the "down"-key )
If KeyDown( key_ctrl ) Or KeyDown( key_ctrlRight ) Then

If KeyDown( key_down ) Then

curFactor = curFactor - 100

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf


EndIf

EndIf

; crap image ( press space )
If KeyHit( key_space ) Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

; switch the "AutoCrap"-mode on and off ( press enter )
; if the "AutoCrap"-mode is enabled the images gets crapped anytime the factor or mode is changed
If KeyHit( key_enter ) Or KeyHit( key_return ) Then

If autoCrapMode = 0 Then

autoCrapMode = 1

Else

autoCrapMode = 0

EndIf

EndIf

; switch the crap-mode
; ( press: | 1 => AND | 2 => OR | 3 => XOR | 4 => INV | )

If KeyHit( key_one ) Then

crapMode = 0

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

If KeyHit( key_two ) Then

crapMode = 1

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

If KeyHit( key_three ) Then

crapMode = 2

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

If KeyHit( key_four ) Then

crapMode = 3

; if "AutoCrap"-mode is enabled, crap the image
If autoCrapMode Then

crapImage = doCrap( oIMG,oIMG_width,oIMG_height,curFactor,crapMode )

EndIf

EndIf

; toggle the displayed informations to red colour ( hold shift )
If KeyDown( key_shiftLeft ) Or KeyDown( key_shiftRight ) Then

redInfoMode = 1

Else

redInfoMode = 0

EndIf

; draw the image
DrawBlock( crapImage,0,0 )

;put out some information about the factor, the crap-mode and "AutoCrap"-mode on the screen

oldR = ColorRed()
oldG = ColorGreen()
oldB = ColorBlue()
If redInfoMode Then

Color 255,0,0

Else

Color 255,255,255

EndIf

Text( 0,0,"Factor: " + Str( curFactor ) )

Text( 0,20,"Mode: " + crapModeDesc[crapMode] )

If autoCrapMode Then

Text( 0,40,"AutoCrap on" )

Else

Text( 0,40,"AutoCrap off" )

EndIf

Color oldR,oldG,oldB

Flip

Wend
End

Function doCrap( IMG,width,height,factor,mode )

Local i%,j%,tIMG%,tIMG_buffer%,rgb%

tIMG = CopyImage( IMG )
tIMG_buffer = ImageBuffer( tIMG )

LockBuffer tIMG_buffer

For i = 0 To width -1

For j = 0 To height - 1

rgb = ReadPixelFast( i,j,tIMG_buffer )

; do the crapment - the modes are described above
Select mode

Case 0:

WritePixelFast( i,j,rgb And factor,tIMG_buffer )

Case 1:

WritePixelFast( i,j,rgb Or factor,tIMG_buffer )

Case 2:

WritePixelFast( i,j,rgb Xor factor,tIMG_buffer )

Case 3:

WritePixelFast( i,j,~rgb,tIMG_buffer )

End Select


Next

Next

UnlockBuffer tIMG_buffer

Return tIMG

End Function


kA, wie ich darauf komme, aber naja...

Steuerung:

1-4: Änderung des "Änderungs-Modus". Zur Wahl stehen: AND,OR,XOR oder eine Invertierung.

Hoch, Runter: Änderung eines Faktors, der bei den Modi eins bis drei eine Rolle spielt. (Steuerung gedrückt halten um den Faktor schnell zu ändern.)

Space: Ausführung der Änderung

Enter: Einschalten des automatischen Änderungsmodus, der bei jeder Änderung des Modis oder des Faktors eine Änderung des Bildes herbeiführt.

Shift (gedrückt halten): Lässt die Farbe der Informations-Anzeige rot werden.

walski
buh!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group