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
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : PIC 16F84RE : PIC 16F84 par belounis
Cliquez pour lire la suite par belounis RE : PIC 16F84RE : PIC 16F84 par pont
Cliquez pour lire la suite par pont
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|