|
Membre émérite
 anthony Enseignant Inscription : avril 2005 Messages : 1 026 Détails du profil  Informations personnelles : Nom :  anthony Localisation : France, Charente Maritime (Poitou Charente) Informations professionnelles :
Activité : Enseignant Secteur : Enseignement Informations forums :
Inscription : avril 2005 Messages : 1 026 Points : 975 Points : 975
|
Utilisation de SetPixel
ci-joint une application :
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
program niveau_de_gris;
{$FRAME_WIDTH 520}
{$FRAME_HEIGHT 366}
{$FRAME_RATE 32}
{$BACKGROUND $FFFFFF}
{$JPEG nom 'voeux2012.jpg'}
uses
Flash8,UCursor;
const
frame_width=520;
frame_height=366 ;
type
image = class(Movieclip)
mybmp : BitmapData;
Field:TextField;
Font:TextFormat;
constructor Create;
procedure onKeyDown;
Procedure onMouseMove;
end;
var cur:TCursor;
Function GetBvalue(coul:integer):integer;
begin
result :=coul Mod 256;
end;
Function GetGvalue(coul:integer):integer;
begin
result :=floor((Coul Mod 65536)/256);
end;
Function GetRvalue(coul:integer):integer;
begin
result :=Floor(Coul/65536);
end;
Function RGB(R,V,B:integer):integer;
begin
result:=65536*R+256*V+B;
end;
function IntToStr3(i: Integer): string;
begin
Result := IntToStr(i);
if (i<100) and (i<>0) and (i>=10) then Result:='0'+Result else if (i<10) and (i<>0) then Result:='00'+Result else if i =0 then Result :='000';
end;
constructor Image.Create;
begin
inherited Create(nil,'mymovieclip',1);
mybmp := loadBitmap('nom');
attachBitmap(mybmp,1,'',false);
Font:=TextFormat.Create( 'Arial',16,$000000,True,False,False,'center');
cur:=TCursor.create(self);
Key.Addlistener(self);
field:=TextField.Create(self,'codeRGB',getNextHighestDepth(),0,0,200,40);
field.selectable:=false;
field.setNewTextFormat(Font);
end;
Procedure Image.onMouseMove;
var R,V,B:integer;
rgb:number;
begin
rgb:=mybmp.GetPixel(_xmouse,_ymouse);
R:=GetRValue(floor(rgb));
V:=GetGValue(floor(rgb));
B:=GetBValue(floor(rgb));
Field.text:='( '+inttostr3(R)+' , '+inttostr3(V)+' , '+inttostr3(B)+' )';
Field._x:=_xmouse-60;
Field._y:=_ymouse-30;
end;
procedure Image.onKeyDown;
var i,j:integer;
col:number;
R,V,B,moy:integer;
begin
For i:=0 to 520 do for j:=0 to 366 do
begin
col:=mybmp.GetPixel(i,j);
R:=GetRValue(floor(col));
V:=GetGValue(floor(col));
B:=GetBValue(floor(col));
moy:=Floor((R+V+B)/3);
mybmp.SetPixel( i,j,RGB(moy,moy,moy) );
end;
mybmp.draw(mybmp);
end;
begin
Image.create;
stage.scaleMode :='noScale';
end. |
+ UCusor
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
unit UCursor;
interface
uses
Flash8,URealmovie;//uniquement pour le record TPoint...
const clblack=$000000;
type
Mouse = external class
class procedure addListener(listener: TObject);
class function hide: Number;
class function removeListener(listener: TObject): Boolean;
class function show: Number;
end;
TCursor = class(MovieClip)
constructor Create(mc:Textfield);
Procedure Arrow(x1,y1,x2,y2:number;col,penw:integer);
procedure onMouseMove;
end;
implementation
constructor TCursor.Create(mc:TextField);
begin
inherited Create(nil,'Cursor',getNextHighestDepth());
Arrow(0,30,0,0,clblack,2);
Mouse.addListener(mc);
Mouse.Hide;
end;
procedure TCursor.onMouseMove;
begin
_x :=_root._xmouse;
_y :=_root._ymouse;
end;
Procedure TCursor.Arrow(x1,y1,x2,y2:number;col,penw:integer);
var i:integer;
Norme,cX,cY: number;
ALength,AWidth:number;
Arrow:array of TPoint;
begin
ALength:=10;
AWidth:=7;
Norme:=SQRT((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
if Norme=0 then Exit;
cX:=(x2-x1)/Norme;
cY:=(y2-y1)/Norme;
Arrow[0]:=pt(x2,y2);
Arrow[1]:=pt(x2-cX*ALength+cY*AWidth,y2-cY*ALength-cX*AWidth);
Arrow[2]:=pt(x2-cX*ALength-cY*AWidth,y2-cY*ALength+cX*AWidth);
Arrow[3]:=pt(x2,y2);
Linestyle(penw,col);
BeginFill(col);
Moveto(x1,y1);
Lineto(x2,y2);
Moveto(arrow[0].x,arrow[0].y);
for i:=1 to 3 do lineto(arrow[i].x,arrow[i].y);
Endfill();
end;
end. |
Ma question est : existe-il un moyen plus rapide pour changer la couleur de la photo... un scanline spécial flashpascal ?
Anthony
__________________
Citation:
|
tout développeur plongé dans son code subit une poussée d'urticaire de bas en haut égale au poids du volume d'unités qu'il ajoute.
|
|