![]() |
Assembler-Bildaufhellung
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
ich wollte mal als Übung eine Bildaufhellung in Assembler schreiben. Das habe ich dann auch getan. Nur was dabei heraus kommt, finde ich nicht gerade prickelnd (siehe Anhang). Die Berechnung für jeden Pixel sieht so aus: NeuerPixel := Alterpixel+Wert. Hier der Sourcecode:
Delphi-Quellcode:
procedure EffectsAufhellenAsm(wert: cardinal);
var i, j: Integer; p, q: PPixel; temp1: Cardinal; begin ////// Wert zur aufhellung berechnen ///// temp1 := wert shl 8; wert := wert or temp1; temp1 := wert shl 16; wert := wert or temp1; temp1 := wert shl 24; wert := wert or temp1; ///// wert := 0www; (in Byte) ///// asm movd MM1, wert movq MM0, MM1 psllq MM1, 32 paddd MM1, MM0 end; ///// MM1 := 0www 0www; (wieder in Byte) ///// ////// Die Hauptschleife ///// for i := 0 to Bitmap.Height-1 do begin p := Bitmap.ScanLine[i]; for j := 0 to (Bitmap.Width div 2)-1 do begin ///// Die Pixel in die Register schieben ///// q := p; temp1 := (q^[1] shl 0) or (q^[2] shl 8) or (q^[3] shl 16); ///// temp1 := 0bgr; (vom ersten Pixel) ///// asm movd MM0, temp1 end; ///// MM0 := 0000 0bgr; inc(q); temp1 := (q^[1] shl 0) or (q^[2] shl 8) or (q^[3] shl 16); ///// temp1 := 0bgr; (vom zweiten Pixel) ///// asm movd MM2, temp1 psllq MM2, 32 ///// MM2 := 0bgr 0000; (vom zweiten Pixel) ///// paddd MM0, MM2 end; ///// 2. 1. Pixel ///// ///// MM0 := 0bgr 0bgr; ///// ///// Die Rechenoperation ausführen ///// asm paddusb MM0, MM1 end; ///// Pixel wieder in das Bild schieben ///// asm movd temp1, MM0 end; ///// temp1 := 0bgr; (erster Pixel) ///// p^[1] := (temp1 and $000000ff) shr 0; p^[2] := (temp1 and $0000ff00) shr 8; p^[3] := (temp1 and $00ff0000) shr 16; inc(p); asm psrld MM0, 32 movd temp1, MM0 end; ///// temp1 := 0bgr; (zweiter Pixel) ///// p^[1] := (temp1 and $000000ff) shr 0; p^[2] := (temp1 and $0000ff00) shr 8; p^[3] := (temp1 and $00ff0000) shr 16; inc(p); end; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:40 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz