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
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : ASSEMBLEURRE : ASSEMBLEUR par solleil
Cliquez pour lire la suite par solleil RE : ASSEMBLEURRE : ASSEMBLEUR par ghuysmans99
Cliquez pour lire la suite par ghuysmans99
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|