1- این رویه DC مربوط به مرحله قبل را دریافت کرده و ابعاد کلیه توکن های موجود که همان تصاویر در فریم اصلی هستند را شناسایی می کند.
در اینجا تابع fill رو قرار ندادم همان طور که گفتیم براینکه اینکار با سرعت بالا صورت بگیره به روش آدرس دهی و صف و pixelFormat کمتر از 8 استفاده نماید .
procedure GetTokens(DC:HDC; BW,BH : Integer);
var i , j : integer;
row : PTriple;
CountRect : integer;
ROut : TRect;
begin
FillColor := RGBTriple(clRed);
TextColor := RGBTriple(clBlack);
Bitmap := TBitmap.Create;
Bitmap.Width := BW;
Bitmap.Height := BH;
BitBlt(Bitmap.Canvas.Handle,0,0,BW,BH,DC,0,0,SRCCO PY);
Bitmap.PixelFormat := pf8bit;
CountRect:=0;
SetLength(Rects,0);
for i := 0 to Bitmap.Height-1 do
begin
row := Bitmap.ScanLine[i];
for j := Bitmap.Width-1 downto 0 do
if CompareRGBTriple(row[j],TextColor) then
begin
ROut:= Fill2(j,i);
if ROut.Right-ROut.Left>0 then
begin
inc(CountRect);
SetLength(rects,CountRect);
rects[CountRect-1].x1:=ROut.Left;
rects[CountRect-1].y1:=ROut.Top;
rects[CountRect-1].x2:=ROut.Right;
rects[CountRect-1].y2:=ROut.Bottom;
Rects[CountRect-1].pnt:=Point(j,i);
end;
end;
end;
end;