Hallo,
ich hoffe es gibt in diesem Forum ein paar Leute die sich mit Assembler auskenne. Ich wollte als Übung mal ein Bild (in Form von TBitmap) aufhellen, also mit jeder Farbe jeden Pixels einen Wert addieren. Hier der Code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65:
| procedure EffectsAufhellenAsm(wert: cardinal); var i, j: Integer; p, q: PPixel; temp1: Cardinal; begin temp1 := wert shl 1; wert := wert or temp1; temp1 := wert shl 2; wert := wert or temp1; temp1 := wert shl 3; wert := wert or temp1; asm movd MM1, wert movq MM0, MM1 psllq MM1, 32 paddd MM1, MM0 end;
for i := 0 to Bitmap.Height-1 do begin p := Bitmap.ScanLine[i]; for j := 0 to (Bitmap.Width div 2)-1 do begin
q := p; temp1 := (q^[1] shl 0) or (q^[2] shl 1) or (q^[3] shl 2); asm movd MM0, temp1 end; inc(q); temp1 := (q^[1] shl 4) or (q^[2] shl 5) or (q^[3] shl 6); asm movd MM2, temp1 psllq MM2, 32 paddd MM0, MM2 end;
asm paddusb MM0, MM1 end;
asm movd temp1, MM0 end; p^[1] := temp1 and $000000ff; p^[2] := temp1 and $0000ff00; p^[3] := temp1 and $00ff0000; inc(p); asm psrld MM0, 32 movd temp1, MM0 end; p^[1] := temp1 and $000000ff; p^[2] := temp1 and $0000ff00; p^[3] := temp1 and $00ff0000; inc(p); end; end; end; |
Was da rauskommt, sieht nicht besonders schön aus. Wenn man als 'wert' null verwendet kommt ein blaues Bild mit den Schattierungen raus, bei einer anderen Zahl ist das Bild komplett blau.
(das war mit 0.)
Der komplette Code:
hier.
Ich hoffe ihr könnt mir helfen!
Pearl Harbor
Moderiert von
Motzi: Code- durch Delphi-Tags ersetzt.