begin process at 2010 03 20 12:56:03
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Delphi et asm

 > 3 FONCTIONS GRAPHIQUES PLUS RAPIDES QUE LES FONCTIONS DE BASES DE DELPHI

3 FONCTIONS GRAPHIQUES PLUS RAPIDES QUE LES FONCTIONS DE BASES DE DELPHI


 Information sur la source

Note :
Aucune note
Catégorie :Delphi et asm Niveau :Débutant Date de création :25/06/2003 Date de mise à jour :25/06/2003 15:51:25 Vu :4 535

Auteur : balgrim

Ecrire un message privé
Site perso
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Voici 3 fonctions graphique, la premiere permet de creer un point sur 1 bitmap, la seconde a crée une droite horizontal, et la derniere à colorer tout le bitmap...

Les 2 premiers sont environs 5 fois plus rapides que les fonctions de bases de delphi, la derniere tres peu parcontre (5%+) enfin c deja ça de gagné :)

Aussi pour ASMClear, en mode 24 bits elle fonctionne mais pas comme il faut :-\ si quelqu'un sait pourquoi je suis preneur

Si l'image n'est pas en 32 ou 24 bits on a la procedure tout bete de delphi,

Source

  • procedure ASMPoint(Bitmap:TBitmap;X,Y:dword;color:dword);
  • var
  • p1:pointer;
  • begin
  • if (X>Bitmap.Height-1) or (Y>Bitmap.Width-1) then exit;
  • p1:=Bitmap.ScanLine[X-1];
  • case Bitmap.PixelFormat of
  • pf32bit:
  • asm
  • push edi
  • mov edi,p1
  • mov eax,y
  • shl eax,2
  • add edi,eax
  • mov eax,color
  • mov [edi],eax
  • pop edi
  • end;
  • pf24bit:
  • asm
  • push edi
  • mov edi,p1
  • mov eax,y
  • imul eax,3
  • add edi,eax
  • mov eax,color
  • mov ecx,eax
  • shr ecx,16
  • mov [edi],ax
  • mov [edi+2],cl
  • pop edi
  • end;
  • else
  • bitmap.Canvas.Pixels[X,Y]:=Color;
  • end;
  • procedure ASMHorizontal(Bitmap:TBitmap;Y:dword;color:dword);
  • var
  • p1:pointer;m:dword;
  • begin
  • p1:=Bitmap.ScanLine[Y];
  • m:=Bitmap.Width;
  • case Bitmap.PixelFormat of
  • pf32bit:
  • asm
  • push edi
  • mov ecx,m
  • mov eax,color
  • mov edi,p1
  • rep stosd
  • pop edi
  • end;
  • pf24bit:
  • asm
  • push edi
  • xor ecx,ecx
  • mov eax,color
  • mov edi,p1
  • @Loop1:
  • mov [edi],eax
  • add edi,3
  • inc ecx
  • cmp ecx,m
  • jne @Loop1
  • pop edi
  • end;
  • else
  • Bitmap.Canvas.Pen.Color:=Color;
  • Bitmap.Canvas.MoveTo(0,Y);
  • Bitmap.Canvas.LineTo(m,Y);
  • end;
  • end;
  • procedure ASMClear(Bitmap:TBitmap;color:dword);
  • var
  • p1:pointer;m:dword;
  • begin
  • with bitmap do begin
  • p1:=ScanLine[height-1];
  • m:=Width*Height;
  • end;
  • case Bitmap.PixelFormat of
  • pf32bit:
  • asm
  • push edi
  • mov ecx,m
  • mov eax,color
  • mov edi,p1
  • rep stosd
  • pop edi
  • end;
  • pf24bit:
  • asm
  • push edi
  • xor ecx,ecx
  • mov eax,color
  • mov edx,color
  • shr edx,16
  • mov edi,p1
  • @Loop1:
  • mov [edi],ax
  • mov [edi+2],dl
  • add edi,3
  • inc ecx
  • cmp ecx,m
  • jne @Loop1
  • pop edi
  • end;
  • else
  • Bitmap.Canvas.Brush.Color:=Color;
  • Bitmap.Canvas.Rectangle(0,0,Bitmap.Width,Bitmap.Height);
  • end;
  • end;
procedure ASMPoint(Bitmap:TBitmap;X,Y:dword;color:dword);
var
p1:pointer;
begin
if (X>Bitmap.Height-1) or (Y>Bitmap.Width-1) then exit;
p1:=Bitmap.ScanLine[X-1];
case Bitmap.PixelFormat of
pf32bit:
  asm
  push edi
  mov edi,p1
  mov eax,y
  shl eax,2
  add edi,eax
  mov eax,color
  mov [edi],eax
  pop edi
  end;
pf24bit:
  asm
  push edi
  mov edi,p1
  mov eax,y
  imul eax,3
  add edi,eax
  mov eax,color
  mov ecx,eax
  shr ecx,16
  mov [edi],ax
  mov [edi+2],cl
  pop edi
  end;
else
bitmap.Canvas.Pixels[X,Y]:=Color;
end;

procedure ASMHorizontal(Bitmap:TBitmap;Y:dword;color:dword);
var
p1:pointer;m:dword;
begin
p1:=Bitmap.ScanLine[Y];
m:=Bitmap.Width;
case Bitmap.PixelFormat of
pf32bit:
  asm
  push  edi
  mov ecx,m
  mov eax,color
  mov edi,p1
  rep stosd
  pop  edi
  end;
pf24bit:
  asm
  push  edi
  xor ecx,ecx
  mov eax,color
  mov edi,p1
  @Loop1:
  mov [edi],eax
  add edi,3
  inc ecx
  cmp ecx,m
  jne @Loop1
  pop  edi
  end;
else
Bitmap.Canvas.Pen.Color:=Color;
Bitmap.Canvas.MoveTo(0,Y);
Bitmap.Canvas.LineTo(m,Y);
end;
end;

procedure ASMClear(Bitmap:TBitmap;color:dword);
var
p1:pointer;m:dword;
begin
with bitmap do begin
p1:=ScanLine[height-1];
m:=Width*Height;
end;
case Bitmap.PixelFormat of
pf32bit:
asm
push  edi
mov ecx,m
mov eax,color
mov edi,p1
rep stosd
pop  edi
end;
pf24bit:
asm
push  edi
xor ecx,ecx
mov eax,color
mov edx,color
shr edx,16
mov edi,p1
@Loop1:
mov [edi],ax
mov [edi+2],dl
add edi,3
inc ecx
cmp ecx,m
jne @Loop1
pop  edi
end;
else
Bitmap.Canvas.Brush.Color:=Color;
Bitmap.Canvas.Rectangle(0,0,Bitmap.Width,Bitmap.Height);
end;
end;

 Conclusion

ça peu etre interressant pour faires de petit jeux sans lag, et sans utilisé scanline tout le temps :)


 Sources du même auteur

ECRIRE UN TEXTE RAPIDEMENT (NASM) AVEC L'INT 10H

 Sources de la même categorie

Source avec Zip APPELER UNE API EN ASM AVEC DELPHI par DeadlyPredator
RENVOIT UNE CHAINE DE X FOIS LE CARACTÈRE DEMANDÉ par cutmaster
PETIT ÉQUIVALENT DU ?: DU C EN DELPHI POUR LES CHAINES, LONG... par cutmaster
AVOIR LE NOM DU JOUR DE LA SEMAINE DÉSIGNÉ par cutmaster
REMPLISSAGE FORMATÉ D'UN SHORTSTRING par cutmaster

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,343 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales