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
|
program getpixel;
uses Flash8;
{$FRAME_WIDTH 510}
{$FRAME_HEIGHT 350}
{$JPEG nom 'voeux2012.jpg'}
const frame_width=510;
frame_height=350;
type
image = class(Movieclip)
mybmp : BitmapData;
Field:TextField;
Font:TextFormat;
constructor Create;
Procedure domousemove;
end;
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;
constructor Image.Create;
begin
inherited Create(nil,'mymovieclip',1);
mybmp := BitmapData.Create(frame_width,frame_height);
mybmp := loadBitmap('nom');
attachBitmap(mybmp,1,'',false);
Font:=TextFormat.Create( 'Arial',16,$000000,True,False,False,'center');
onmousemove:=domousemove;
end;
Procedure Image.domousemove;
var R,V,B:integer;
rgb:number;
begin
clear;
Field.text:='';
mybmp.draw(self);
rgb:=mybmp.GetPixel(_xmouse,_ymouse);
R:=GetRValue(floor(rgb));
V:=GetGValue(floor(rgb));
B:=GetBValue(floor(rgb));
field:=TextField.Create(self,'codeRGB',2,_xmouse-60,_ymouse-40,200,40);
with field do
begin
setNewTextFormat(Font);
text:='( '+inttostr(R)+' , '+inttostr(V)+' , '+inttostr(B)+' )';
end;
end;
begin
Image.Create;
end. |
Partager