Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#1

Assemler Routine ummodeln - wer kann bitte helfen

  Alt 7. Okt 2007, 13:48
Hi,

ich habe volgende Procedure:

Delphi-Quellcode:
{------------------------------------------------------------------}
{  Swap bitmap format from BGR to RGB                              }
{------------------------------------------------------------------}
procedure SwapRGB(data : Pointer; Size : Integer);
asm
  mov ebx, eax
  mov ecx, size

@@loop :
  mov al,[ebx+0]
  mov ah,[ebx+2]
  mov [ebx+2],al
  mov [ebx+0],ah
  add ebx,3
  dec ecx
  jnz @@loop
end;
und möchte sie wiefolgt verändern:

Delphi-Quellcode:
procedure SwapRGB(data : Pointer; Size : Integer; Step: Byte);
asm
  mov ebx, eax
  mov ecx, size
  mov ???, step

@@loop :
  mov al,[ebx+0]
  mov ah,[ebx+2]
  mov [ebx+2],al
  mov [ebx+0],ah
  add ebx, ??? (4)
  dec ecx
  jnz @@loop
end;
Das soll ein Array umformen in etwa so:

Code:
BGRA, BGRA, BGRA...
// nach:
RGBA, RGBA, RGBA...

und das ergibt dann eine Bitmapladeroutiene für zB. OpenGl:

Delphi-Quellcode:
function LoadBMPTexture(ResID: Integer; var Texture : GLuint) : Boolean;
var
  BitmapLength: LongWord;
  bmpBits: array of byte;
  hBmp: HBitmap;
  bi: tagBITMAP;
begin
  hBmp := Loadimage(HInstance, MAKEINTRESOURCE(ResID), IMAGE_BITMAP, 0,0,0);
  GetObject(hBmp, sizeof(bi), @bi);
  BitmapLength := bi.bmWidth * bi.bmHeight * bi.bmBitsPixel Div 8;
  SetLength(bmpBits, BitmapLength+1);
  GetBitmapBits(hBmp, BitmapLength, @bmpBits[0]);

  if @bmpBits[0] <> nil then
  begin
    SwapRGB(@bmpBits[0], bi.bmWidth * bi.bmHeight); // Swap Bitmap Bits BGR(A) to RGB(A)
    Texture := CreateTexture(bi.bmWidth, bi.bmHeight, GL_RGBA, @bmpBits[0]);
    Result := (Texture <> 0);
  end else
    Result := False;

  DeleteObject(hBmp);
end;
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat