Le titre annonce la couleur ...
En gros vous selectionnez la couleur que vous voulez remplacer ds une image
puis
soit vous choisissez une couleur pour la remplacer
soit vous prenez une image
DERNIERE MISE A JOUR *
POSSIBILITES DU PROG
____________________
OUVRIR UNE IMAGE(BMP,JPEG) POUR LA MODIFIER EN CHANGEANT LES COULEURS VIA LA METHODE-PIXEL OU SCANLINE
CHANGER LA COULEUR PAR UNE AUTRE COULEUR OU CHANGER LA COULEUR PAR UNE IMAGE
POSSIBILITE DE CHOISIR SON 'TAUX' DE MODIFICATION CAD D ELARGIR LES PALETTES DE COULEURS A CHANGER(UNIQUEMENT AVEC SCANLINE )
ANNULATION DE LA DERNIERE OPERATION GRAPHIQUE
UNE FOIS L'IMAGE MODIFIE POSSIBILITE DE LA SAUVEGARDER EN JPEG
Source / Exemple :
procedure TForm1.RemplacerClick(Sender: TObject);
var
x,y: integer;
SX,SY: extended;
Scan,ScanIMG : TypePRGBArray;
lR, lV, lB, mR, mV, mB : Integer;
begin
// Creation de l image a sauvegarder pour l annulation
Tempb.Height:=image1.Picture.Bitmap.Height;
Tempb.Width:=image1.Picture.Bitmap.Width;
Tempb.Assign(image1.Picture.Bitmap);
precedent.Enabled:=true;
// Facteur pour l'incrustation de l'image(mode image)
SX:=Image1.Picture.Width / BitIMG.Picture.Width;
SY:=Image1.Picture.Height / BitIMG.Picture.Height;
// convertion en entier
if round(sx)=0 then sx:=1;
if round(sy)=0 then sy:=1;
// max gauge(pr la patience !!)
gauge1.MaxValue:=image1.picture.Bitmap. Height-1;
//----------------------------------------------------------------------------------------------
// DEBUT DE LA BOUClE
//----------------------------------------------------------------------------------------------
if UtiliserS.Checked=false then
begin
for y:=0 to image1.Picture.Bitmap.Height-1 do
begin
gauge1.Progress:=y; // ...
for x:=0 to image1.Picture.Bitmap.Width-1 do
begin
// ----------------------------------------------------------------------------------------------
// METHODE N UTILISANT PAS SCANLINE
// ----------------------------------------------------------------------------------------------
if UTColIMG.Checked then
begin
// si les couleurs concorde alors on remplace par la col finale
if (image1.Picture.Bitmap.Canvas.Pixels[x,y]=colimg.color)
then
begin
image1.Picture.Bitmap.Canvas.Pixels[x,y]:=colFinal.Color;
end;
end ;
if UtBITIMG.Checked then
begin
// idem / que c pr l'image
if (image1.Picture.Bitmap.Canvas.Pixels[x,y]=colimg.color)
then
begin
Image1.Picture.Bitmap.Canvas.Pixels[x,y]:=
BitIMG.Picture.Bitmap.Canvas.Pixels[x div round(sx) ,y div round(sy) ] ;
end;
end;
end;//utiliserS
end; // fin de
end; // la boucle
// max gauge(pr la patience !!)
gauge1.MaxValue:=image1.picture.Bitmap. Height-1;
//----------------------------------------------------------------------------------------------
// DEBUT DE LA BOUClE
//----------------------------------------------------------------------------------------------
if UtiliserS.Checked=true then
begin
if UtBITIMG.Checked=true then
begin
if (image1.picture.Bitmap.Width> Bitimg.Picture.Bitmap.Width ) or //Protection pour ne pas depasser
(image1.picture.Bitmap.Height> Bitimg.Picture.Bitmap.Height ) // les limites
then
begin
Bitimg.Picture.Bitmap.Width:=image1.Picture.Bitmap.Width;
Bitimg.Picture.Bitmap.height:=image1.Picture.Bitmap.height;
end;
end;
for y:=0 to image1.Picture.Bitmap.Height-1 do
begin
gauge1.Progress:=y; // ...
Scan := image1.picture.Bitmap.ScanLine[Y];
if utBITIMG.Checked then ScanIMG :=BitImg.Picture.Bitmap.ScanLine[y];
for x:=0 to image1.Picture.Bitmap.Width-1 do
begin
// ----------------------------------------------------------------------------------------------
// METHODE UTILISANT SCANLINE
// ----------------------------------------------------------------------------------------------
if UTColIMG.Checked then
begin
mR := Scan[X].Rouge;
mV := Scan[X].Vert;
mB := Scan[X].Bleu;
If
( rgb(mr,mv,mb)<colimg.Color+rgb(taux.Position,taux.Position,taux.Position))
and
( rgb(mr,mv,mb)>colimg.Color-rgb(taux.Position,taux.Position,taux.Position) )
Then
Begin
lR := getRvalue(colfinal.Color) ;//Scan[X].Rouge;
lV := getGvalue(colfinal.Color) ; //Scan[X].Vert;
lB := getBvalue(colfinal.Color) ; //Scan[X].Bleu + 151;
End
Else Begin // Sinon, recopier le pixel d'origine
lR := mR;
lV := mV;
lB := mB;
End;
Scan[X].Rouge := lR;
Scan[X].Vert := lV;
Scan[X].Bleu := lB;
end;
if UtBITIMG.Checked then
begin
mR := Scan[X].Rouge;
mV := Scan[X].Vert;
mB := Scan[X].Bleu;
If
( rgb(mr,mv,mb)<colimg.Color+rgb(taux.Position,taux.Position,taux.Position))
and
( rgb(mr,mv,mb)>colimg.Color-rgb(taux.Position,taux.Position,taux.Position) )
Then
Begin
lR := ScanIMG[X].Rouge;
lV := ScanIMG[X].Vert;
lB := ScanIMG[X].Bleu;
End
Else Begin // Sinon, recopier le pixel d'origine
lR := mR;
lV := mV;
lB := mB;
End;
Scan[X].Rouge := lR;
Scan[X].Vert := lV;
Scan[X].Bleu := lB;
end;
end;//utiliserS
end; // fin de
end; // la boucle
image1.Refresh ;
if UtiliserS.Checked=true then image1.Refresh;
gauge1.Progress:=0; // on remet a zero la petite gauge
end;
Conclusion :
SCANLINE , QUAND MEME VACHEMENT PLUS RAPIDE !!!
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.