Y
ydzi_
Unregistered / Unconfirmed
GUEST, unregistred user!
type
TSWFInfo = record
xMin: integer;
//
xMax: integer;
//
yMin: integer;
//
yMax: integer;
//
FrameCount: integer;
end;
procedure WriteTxtInfo(sFileName, txtInfo: string);
var
m_Info: string;
FileResult: THandle;
TmpTxtFile: TextFile;
begin
try
if not FileExists(sFileName) then
begin
FileResult := FileCreate(sFileName);
FileClose(FileResult);
AssignFile(TmpTxtFile, sFileName);
ReWrite(TmpTxtFile);
CloseFile(TmpTxtFile);
end;
m_Info := txtInfo + #13#10;
FileResult := FileOpen(sFileName, fmOpenReadWrite or fmShareDenyNone);
if FileResult > 0 then
begin
FileSeek(FileResult, 0, 2);
FileWrite(FileResult, m_Info[1], Length(m_Info));
FileClose(FileResult);
end;
except
on e: exceptiondo
begin
//MessageBox(Handle, pChar('txtWriteInfo 处出错!详情' + #13#10 + E.Message), '', mb_Ok + mb_IconInformation);
Exit;
end;
end;
end;
procedure GetColor;
var
tmpFrame, tmpX, tmpY: integer;
tmpString: string;
C: Cardinal;
FilePath: string;
FrameMin, FrameMax: integer;
xMin, xMax, yMin, yMax: integer;
SWFInfo: TSWFInfo;
begin
Screen.Cursor := crHourGlass;
try
FilePath := 'd:/123.txt';
// 取得SWF文件头信息
// SWFRect...
// ...
xMin := SWFInfo.xMin; // 值范围在0~1000
xMax := SWFInfo.xMax; // 值范围在0~1000
yMin := SWFInfo.yMin; // 值范围在0~1000
yMax := SWFInfo.yMax; // 值范围在0~1000
FrameMin := 1;
FrameMax := SWFInfo.FrameCount; // 值范围在1~3500左右
for tmpFrame := FrameMin to FrameMaxdo
begin
frmFlash.ShockwaveFlash1.StopPlay();
frmFlash.ShockwaveFlash1.GotoFrame(tmpFrame);
frmFlash.Update;
tmpString := '第 [' + IntToSTr(tmpInteger) + '] 帧';
WriteTxtInfo(FilePath, tmpString);
for tmpX := xMin to xMaxdo
begin
tmpString := '';
for tmpY := yMin to yMaxdo
begin
C := GetPixel(GetDc(frmFlash.ShockwaveFlash1.Handle), tmpX, tmpY);
TmpString := TmpString + '(X: ' + IntToStr(tmpX)
+ ', Y: ' + IntToStr(tmpY) + '): $'
+ IntToHex(GetRValue(C), 2)
+ IntToHex(GetGValue(C), 2)
+ IntToHex(GetBValue(C), 2);
end;
WriteTxtInfo(FilePath, tmpString);// 将该点颜色写入到文本文件中
end;
end;
except
showmessage('');
end;
Screen.Cursor := crDefault;
end;
procedure TfrmMain.BitBtn1Click(Sender: TObject);
var
// m_Thread: TThreadFindFrame;
hGetColorThread: THandle;
ThID: dWord;
begin
try
hGetColorThread := begin
Thread(nil, 0,
@GetColor, nil, 0, ThID);
if hGetColorThread = 0 then
messageBox(Handle, '线程失败,5555~~~', '', mb_Ok + mb_IconInformation)
except
on e: exceptiondo
begin
messageBox(handle, pChar(E.Message), '', mb_Ok + mb_IconInformation);
Exit;
end;
end;
end;
说明:上面代码的功能是在指定SWF动画中,取每一帧里指定坐标点的颜色!!
由于一些动画中帧相对较多,或者每帧当中取的坐标较多!所以程序效率比较低!
所以,特求一段高效代码!谢谢
TSWFInfo = record
xMin: integer;
//
xMax: integer;
//
yMin: integer;
//
yMax: integer;
//
FrameCount: integer;
end;
procedure WriteTxtInfo(sFileName, txtInfo: string);
var
m_Info: string;
FileResult: THandle;
TmpTxtFile: TextFile;
begin
try
if not FileExists(sFileName) then
begin
FileResult := FileCreate(sFileName);
FileClose(FileResult);
AssignFile(TmpTxtFile, sFileName);
ReWrite(TmpTxtFile);
CloseFile(TmpTxtFile);
end;
m_Info := txtInfo + #13#10;
FileResult := FileOpen(sFileName, fmOpenReadWrite or fmShareDenyNone);
if FileResult > 0 then
begin
FileSeek(FileResult, 0, 2);
FileWrite(FileResult, m_Info[1], Length(m_Info));
FileClose(FileResult);
end;
except
on e: exceptiondo
begin
//MessageBox(Handle, pChar('txtWriteInfo 处出错!详情' + #13#10 + E.Message), '', mb_Ok + mb_IconInformation);
Exit;
end;
end;
end;
procedure GetColor;
var
tmpFrame, tmpX, tmpY: integer;
tmpString: string;
C: Cardinal;
FilePath: string;
FrameMin, FrameMax: integer;
xMin, xMax, yMin, yMax: integer;
SWFInfo: TSWFInfo;
begin
Screen.Cursor := crHourGlass;
try
FilePath := 'd:/123.txt';
// 取得SWF文件头信息
// SWFRect...
// ...
xMin := SWFInfo.xMin; // 值范围在0~1000
xMax := SWFInfo.xMax; // 值范围在0~1000
yMin := SWFInfo.yMin; // 值范围在0~1000
yMax := SWFInfo.yMax; // 值范围在0~1000
FrameMin := 1;
FrameMax := SWFInfo.FrameCount; // 值范围在1~3500左右
for tmpFrame := FrameMin to FrameMaxdo
begin
frmFlash.ShockwaveFlash1.StopPlay();
frmFlash.ShockwaveFlash1.GotoFrame(tmpFrame);
frmFlash.Update;
tmpString := '第 [' + IntToSTr(tmpInteger) + '] 帧';
WriteTxtInfo(FilePath, tmpString);
for tmpX := xMin to xMaxdo
begin
tmpString := '';
for tmpY := yMin to yMaxdo
begin
C := GetPixel(GetDc(frmFlash.ShockwaveFlash1.Handle), tmpX, tmpY);
TmpString := TmpString + '(X: ' + IntToStr(tmpX)
+ ', Y: ' + IntToStr(tmpY) + '): $'
+ IntToHex(GetRValue(C), 2)
+ IntToHex(GetGValue(C), 2)
+ IntToHex(GetBValue(C), 2);
end;
WriteTxtInfo(FilePath, tmpString);// 将该点颜色写入到文本文件中
end;
end;
except
showmessage('');
end;
Screen.Cursor := crDefault;
end;
procedure TfrmMain.BitBtn1Click(Sender: TObject);
var
// m_Thread: TThreadFindFrame;
hGetColorThread: THandle;
ThID: dWord;
begin
try
hGetColorThread := begin
Thread(nil, 0,
@GetColor, nil, 0, ThID);
if hGetColorThread = 0 then
messageBox(Handle, '线程失败,5555~~~', '', mb_Ok + mb_IconInformation)
except
on e: exceptiondo
begin
messageBox(handle, pChar(E.Message), '', mb_Ok + mb_IconInformation);
Exit;
end;
end;
end;
说明:上面代码的功能是在指定SWF动画中,取每一帧里指定坐标点的颜色!!
由于一些动画中帧相对较多,或者每帧当中取的坐标较多!所以程序效率比较低!
所以,特求一段高效代码!谢谢