Accueil > > > 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
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 de la même categorie
Commentaires et avis
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|