Page 1 of 2 12 LastLast
Results 1 to 25 of 29

Thread: Dtm scanner!!

  1. #1
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Dtm scanner(generator)!!

    Hey guys,

    long long time ago i said i would make a DTM scanner, well three days ago i started, and guess what, it works.
    open the screensot,
    make a minimun of two selections
    and the program wil generate a dtm for the object... isn't that great?
    but... it needs some perfection.
    the program is made in delphi, so if there are any volunteers who like to test it for me or help me make it better, please react:P(i preffer SRL members)

    can be used for everything, not just runescape.
    sorry for my bad english, i am dutch and it is 0:44 AM:P

    //edit
    http://www.youtube.com/watch?v=plzYJ94sYwQ

    things to improve:
    now it only finds 100% matches make a color scanner with a bit tolerance
    now the dtm is limited to 2 pixels, increase to 10
    now it only looks which pixel combination comes most in selection(with the best colors)
    make it also look for the dtm outside of the selection.


    proces explenetion:
    first it scans the first selection
    save all colors and there coörds
    get the coörds of these colors in the other selection and in the non selection
    take the color that comes most in the selection en least in the non selection
    colorcounted(selection)/(colorcounted(selection)+colorcounted(nonselection ))*100=%
    remember the colors with the highest %
    for every pixel of the 3 best colors combine with another pixel
    find dtm in selection
    remember the dtm with the highest lowest found.
    is in selection1 the dtm is found 10 times, and in selection2 it is found 2 times than it says this dtm is found 2 times

    hope you guys understand:P
    Last edited by nielskool; 05-17-2010 at 11:09 PM.
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I'd love to help ..
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  3. #3
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Post the code?
    ~Hermen

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    eej hermen,

    i have to say it is a hell of a mess..:P
    and i started with other ways of searching for a dtm so there are 4 algorthmes in the app.. first 3 don't work, atleast not as i want it to.

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls, ExtCtrls, Menus, Buttons, ExtDlgs, Grids,
      ValEdit, ToolWin, Gauges, Mask;
    
    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Panel3: TPanel;
        PageControl1: TPageControl;
        Addb: TButton;
        delb: TButton;
        adds: TButton;
        dels: TButton;
        MainMenu1: TMainMenu;
        File1: TMenuItem;
        Exit1: TMenuItem;
        Help1: TMenuItem;
        Howtouse1: TMenuItem;
        About1: TMenuItem;
        New1: TMenuItem;
        Reset1: TMenuItem;
        Dtms1: TMenuItem;
        Makedtm1: TMenuItem;
        MakeDDTM1: TMenuItem;
        BitBtn1: TBitBtn;
        Edit1: TEdit;
        Label1: TLabel;
        OpenPictureDialog1: TOpenPictureDialog;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit5: TEdit;
        Edit6: TEdit;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Button1: TButton;
        Button2: TButton;
        CheckDTM1: TMenuItem;
        Checkcolor1: TMenuItem;
        GenerarteDTM1: TMenuItem;
        Credits1: TMenuItem;
        ValueListEditor1: TValueListEditor;
        Button4: TButton;
        Edit7: TEdit;
        Edit8: TEdit;
        Edit9: TEdit;
        Edit10: TEdit;
        Edit11: TEdit;
        Edit12: TEdit;
        Edit13: TEdit;
        ValueListEditor2: TValueListEditor;
        ValueListEditor3: TValueListEditor;
        Button6: TButton;
        StaticText1: TStaticText;
        BitBtn2: TBitBtn;
        Edit14: TEdit;
        Gauge1: TGauge;
        MaskEdit1: TMaskEdit;
        MaskEdit2: TMaskEdit;
        Button7: TButton;
        Button8: TButton;
        Button3: TButton;
        Button5: TButton;
        Label7: TLabel;
        procedure AddbClick(Sender: TObject);
        procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure delbClick(Sender: TObject);
        procedure OpenPictureDialog1SelectionChange(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure BitBtn1Click(Sender: TObject);
        procedure About1Click(Sender: TObject);
        procedure Credits1Click(Sender: TObject);
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure Image1Mouseup(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
    
        procedure FormCreate(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure BitBtn2Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure Button7Click(Sender: TObject);
        procedure Button8Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
    
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      x : integer;
      im:boolean;
    tabSheetw : array[0..10] of TTabSheet;
    selec1x,selec1y,selec2x,selec2y : array[0..12] of integer;
    selec: array[0..12] of Tshape;
    img: array[0..10] of TImage;
    pixelsy, pixelsx: integer;
    scro: array[0..10] of TScrollBox;
    temparr , temparr2:array of integer;
      kleur1,kleur2,kleur3:integer;
      kleur1p,kleur2p,kleur3p:integer;
      kleur1g,kleur2g,kleur3g:integer;
    
    implementation
    
    uses Unit2, Unit3, Unit4, Math, Unit5, Unit6;
    var
     forma: array of TShape;    //Array to create
      formaUtil: Integer;        // Kind of shape
      Numforma: Integer;         //Number of shapes
      Izq, Arr, Ancho, alto, x1, x2, y1, y2: Integer; //Position and size of shape
      activar: Boolean;          //Tells when you are creating and sizing the shape
    
    
    {$R *.dfm}
    procedure TForm1.Image1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
      var
      xt:integer;
    begin
    formaUtil := 1;
    if formaUtil < 1 then Exit;
      activar  := True;
      xt:=Form1.PageControl1.TabIndex+1;
                   //starting draw the shape
      x1 := x+ img[xt].left;
      Edit10.text:= inttostr(x1);
      //ShowMessage(inttostr(x1));
      y1 := y+ img[xt].Top;
      Edit11.text:= inttostr(y1);
      //ShowMessage(inttostr(y1));
      numforma := numforma + 1;
      setlength(forma, numforma);
      forma[numforma - 1] := TShape.Create(TabSheetw[xt]);
        forma[numforma - 1].Pen.Mode:=pmNot;
        forma[numforma - 1].Pen.Width:=1;
        forma[numforma - 1].Pen.Color:=clBlack;
      if formaUtil = 1 then
        forma[numforma - 1].Shape :=stRectangle
      else
        forma[numforma - 1].Shape := stCircle;
      forma[numforma - 1].Left   := x1;
      forma[numforma - 1].Top    := y1;
      forma[numforma - 1].Parent := scro[xt];
      forma[numforma - 1].Width := 0;
      forma[numforma - 1].Height := 0;
      forma[numforma - 1].BringToFront;
    end;
    
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
      var                             
      xt:integer;
    begin
    xt:=Form1.PageControl1.TabIndex+1;
    Edit8.Text:= inttostr(x);
    Edit9.Text:= inttostr(y);
    Edit7.Color := img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top];
    Edit6.Text := inttostr(img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top]);
      if (formaUtil = 0) then Exit;
      if (numforma = 0) then Exit;
      if not activar then Exit;
      x2 := x+img[xt].left;
      Edit12.text:= inttostr(x2);
      y2 := y+img[xt].Top;
      Edit13.text:= inttostr(y2);
      forma[numforma - 1].Width := x2 - x1;
      forma[numforma - 1].Height := y2 - y1;
      StaticText1.Caption := IntToStr(numforma);
    end;
    
    procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
      var
      xt:integer;
    begin
    xt:=Form1.PageControl1.TabIndex+1;
      x2 := x+img[xt].left;
      //ShowMessage(inttostr(x2));
      y2 := y+img[xt].Top;
      //ShowMessage(inttostr(y2));
      forma[numforma - 1].Width := x2 - x1;
      forma[numforma - 1].Height := y2 - y1;
      formaUtil := 1;
      activar   := False;
      //form5.show;
      Form5.MaskEdit1.text := inttostr(forma[0].left);
      Form5.MaskEdit2.text := inttostr(forma[0].top);
      Form5.MaskEdit3.text := inttostr(forma[0].height);
      Form5.MaskEdit4.text := inttostr(forma[0].width);
    
    end;
    
    procedure TForm1.AddbClick(Sender: TObject);
    begin
    x:= pageControl1.PageCount+1;
    tabSheetw[x] := TTabSheet.Create(PageControl1) ;
    tabSheetw[x].PageControl := PageControl1;
    tabSheetw[x].Caption:= inttostr(pageControl1.PageCount);
    scro[x] := TScrollBox.Create(tabSheetw[x]);
    scro[x].Align := alClient;
    scro[x].Parent:= tabSheetw[x];
    scro[x].BorderStyle:=bsSingle;
    img[x] := TImage.Create(scro[x]);
    img[x].Parent := scro[x];
    img[x].OnMouseUp := Image1MouseUp;
    img[x].OnMouseDown := Image1MouseDown;
    img[x].OnMouseMove := Image1MouseMove;
    
    
    end;
    
    procedure setrechts();
    var
    x : integer;
    tabSheetw : array[0..10] of TTabSheet;
    begin
    end;
    
    procedure sorter();
    var i,j,temp, temp2,minIndex:integer;
    sortedstring:string;
    begin
    setlength(temparr2,high(temparr));
    for i:= low(temparr) to high(temparr) do
    begin
    temparr2[i] := strtoint(Form1.ValueListEditor2.Values[inttostr(temparr[i])]);
    end;
    
    for i:= 0 to length(temparr)-1 do
    begin
    	// zoek kleinste in de rest van de array
    	minIndex := i;
    	for j:=i to length(temparr2)do
      begin
    		if (temparr2[j] < temparr2[minIndex]) then
        begin
    			minIndex := j;
    		end;
    	end;
    
    	// verwissel waarden
    	temp := temparr[i];
    	temparr[i] := temparr[minIndex];
    	temparr[minIndex] := temp;
    
      temp := temparr2[i];
    	temparr2[i] := temparr2[minIndex];
    	temparr2[minIndex] := temp;
      //ShowMessage(inttostr(temparr[i]));
    
    
    end;
    end;
    
    
    procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    //setrechts();
    end;
    
    procedure TForm1.delbClick(Sender: TObject);
    begin
    x:= pageControl1.PageCount;
    tabSheetw[x].Destroy;
    end;
    
    procedure TForm1.OpenPictureDialog1SelectionChange(Sender: TObject);
    begin
    //Self.get
    //Self.Parent.image1.picture := Self.
    end;
    
    procedure TForm1.Button4Click(Sender: TObject);
    var
    Bitmap: TBitmap;
    x:integer;
    begin
    Bitmap := TBitmap.Create;
    if OpenPictureDialog1.Execute then
      begin
      x:= PageControl1.TabIndex+1;
      Bitmap.LoadFromFile(OpenPictureDialog1.FileName);
        img[x].Picture.LoadFromFile(OpenPictureDialog1.FileName);
        img[x].Width:= Bitmap.Width ;
        img[x].Height:= Bitmap.Height;
      end;
      Bitmap.Free;
    end;
    
    
    
    
    procedure TForm1.About1Click(Sender: TObject);
    begin
    About.show;
    end;
    
    procedure TForm1.Credits1Click(Sender: TObject);
    begin
    Credits.show;
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    formaUtil := 1;
      Numforma := 0;
      activar := False;
    end;
    
    
    
    
    
    
    
    procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
    Form4.ShowModal;
    end;
    
    
    
    procedure TForm1.Button8Click(Sender: TObject);
    var
      myFile : TextFile;
      text   : string;
      gkleur, fkleur: array[0..2550] of integer;
      rowcount: integer;
      xt:integer;
      startpixelcolor,pixel2color:integer;
      startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
      goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
      zoeky,zoekx,zoekx2,zoeky2:integer;
      tempprocent,tempprocent2,procent: variant;
      tempje,color: integer;
      color2: array[0..10000] of integer;
      startpixx,startpixy,startpixcol : integer;
      directory : string;
      selecs,tempje2,i, error:integer;
      bestaat: Boolean;
    
    begin
    xt:=Form1.PageControl1.TabIndex+1;
    tempje2:= 0;
    for zoeky2    := forma[0].top to forma[0].top+forma[0].Height-1 do
    begin
    for zoekx2    := forma[0].left to forma[0].left+forma[0].Width-1 do
    begin
    color2[tempje2] := img[xt].Canvas.Pixels[zoekx2, zoeky2];
    for i:=0 to tempje2-1 do
    begin
    if(color2[i] = color2[tempje2])then tempje2:= tempje2-1;
    end;
    tempje2:= tempje2+1;
    end;
    end;
    //tempje2:= 0;
    ShowMessage(inttostr(tempje2));
    
    
    for zoeky    := img[xt].top to img[xt].top+img[xt].Height-1 do
    begin
    for zoekx    := img[xt].left to img[xt].left+img[xt].width-1 do
    begin
    Gauge1.Progress:= floor((zoeky*img[xt].width+zoekx)/(img[xt].Height*img[xt].Width)*100);
    color:= img[xt].Canvas.Pixels[zoekx, zoeky];
    bestaat := false;
    for i:=0 to tempje2-1 do
    begin
    if(color2[i] = color)then bestaat:= true;
    end;
    if(bestaat)then begin
    CreateDir('C:\tmp\fout');
    ChDir('C:\tmp\fout');
    for selecs:=0 to numforma-1 do
    begin
    if(zoekx >= forma[selecs].left) AND (zoekx <= forma[selecs].left+forma[selecs].width) AND (zoeky >= forma[selecs].top) AND (zoeky <= forma[selecs].top+forma[selecs].height)then
     begin
      CreateDir('C:\tmp\goed'+inttostr(selecs));
      ChDir('C:\tmp\goed'+inttostr(selecs));
     end;
    end;
    
     AssignFile(myFile, inttostr(color)+'.txt');
     if FileExists(inttostr(color)+'.txt') then
       Append(myFile)
       else
       begin
          Rewrite(myFile);
          WriteLn(myFile, color);
          WriteLn(myFile, '1');
       end;
       WriteLn(myFile, '['+inttostr(zoekx)+', '+inttostr(zoeky)+']');
    
       // Close the file
       CloseFile(myFile);
    
    
    
    
    
    end;
    end;
    end;
    
    
    end;
    
    
    procedure TForm1.Button3Click(Sender: TObject);
    var
      myFile : TextFile;
      text   : string;
      rowcount: integer;
      temp,temp2,temp3: integer;
      xt:integer;
      startpixelcolor,pixel2color:integer;
      startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
      goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
      zoeky,zoekx:integer;
      tempprocent,tempprocent2,procent: variant;
      tempje,color: integer;
      startpixx,startpixy,startpixcol,regel,fout : integer;
      directory : string;
      selecs, selecs2:integer;
      verwijder:Boolean;
    
    begin
    kleur1:= 0;
    kleur2:= 0;
    kleur3:= 0;
    xt:=Form1.PageControl1.TabIndex+1;
    CreateDir('C:\tmp\berekend');
    ChDir('C:\tmp\berekend');
    for zoeky    := forma[0].top to forma[0].top+forma[0].Height-1 do
    begin
    for zoekx    := forma[0].left to forma[0].left+forma[0].Width-1 do
    begin
    Gauge1.Progress:= floor((zoeky*forma[0].width+zoekx)/(forma[0].Height*forma[0].Width)*100);
    color:= img[xt].Canvas.Pixels[zoekx, zoeky];
      verwijder:= false;
      for selecs:=0 to numforma-1 do
      begin
      ChDir('C:\tmp\goed'+inttostr(selecs));
      if not FileExists(inttostr(color)+'.txt') then
    begin
       for selecs2:=0 to numforma-1 do
      begin
       ChDir('C:\tmp\goed'+inttostr(selecs2));
       If(FileExists(inttostr(color)+'.txt'))then
       DeleteFile(inttostr(color)+'.txt');
      end;
      ChDir('C:\tmp\berekend');
      If(FileExists(inttostr(color)+'.txt'))then
      DeleteFile(inttostr(color)+'.txt');
      verwijder:= true;
    
    end;
    
      end;
    if(verwijder = false)then
    begin
    ChDir('C:\tmp\berekend');
    if not FileExists(inttostr(color)+'.txt') then
    begin
    CreateDir('C:\tmp\fout');
    ChDir('C:\tmp\fout');
    if FileExists(inttostr(color)+'.txt') then
    begin
    AssignFile(myFile, inttostr(color)+'.txt');
    Reset(myFile);
    regel:= 0;
    fout:= 0;
    
      while not Eof(myFile) do
       begin
       fout:= fout+1;
       ReadLn(myFile, text);
    
      end;
      CloseFile(myFile);
      end;
      //000000
      temp:= 99999999;
      //bestaat := 1;
    
      for selecs:=0 to numforma-1 do
      begin
    ChDir('C:\tmp\goed'+inttostr(selecs));
    if FileExists(inttostr(color)+'.txt') then
    begin
    AssignFile(myFile, inttostr(color)+'.txt');
    Reset(myFile);
    regel:= 0;
    
      while not Eof(myFile) do
       begin
       regel:= regel+1;
       ReadLn(myFile, text);
    
      end;
      CloseFile(myFile);
      if(temp > regel)then temp:= regel;
      end;
      regel:= temp;
      //000000
      end;
      if(regel =  99999999)then regel:= 0;
      CreateDir('C:\tmp\berekend');
      ChDir('C:\tmp\berekend');
      AssignFile(myFile, inttostr(color)+'.txt');
      Rewrite(myFile);
      if(regel >2)then
      begin
      regel:= regel-2;
      if(fout >=0)AND(fout < 3)then
      fout:=0 else
      fout:= fout -2;
      end;
      if(regel > 5)AND(regel+fout <> 0)then  //5 staat voor minimaal aantal
      procent:= floor(regel/(regel+fout)*100) else procent:= 0;
      WriteLn(myFile, inttostr(regel));
      WriteLn(myFile, inttostr(fout));
      WriteLn(myFile, inttostr(procent));
     if(procent > kleur3p)then
     begin
      if(kleur3 = 0)then
      begin
        if(kleur2 = 0)then
        begin
          if(kleur1 = 0)then
          begin
          kleur1 := color;
          kleur1p := procent;
          kleur1g := regel;
          end else
          begin
          kleur2 := color;
          kleur2p := procent;
          kleur2g := regel;
          end;
        end else
        begin
        kleur1 := color;
        kleur1p := procent;
        kleur1g := regel;
        end;
      end;
    
     end;
    
      if(procent > kleur3p)then
      begin
       kleur3 := color;
       kleur3p:= procent;
       kleur3g:= regel;
      end;
      if(procent = kleur3p)then
      begin
      if(regel > kleur3g)then
      begin
       kleur3 := color;
       kleur3p:= procent;
       kleur3g:= regel;
      end;
      end;
    
       if(kleur3p > kleur2p)then
      begin
       temp:= kleur3;
       temp2:= kleur3p;
       temp3:= kleur3g;
       kleur3 := kleur2;
       kleur3p:= kleur2p;
       kleur3g:= kleur2g;
       kleur2 := temp;
       kleur2p:= temp2;
       kleur2g:= temp3;
      end;
      if(kleur3p = kleur2p)then
      begin
      if(kleur3g > kleur2g)then
      begin
       temp:= kleur3;
       temp2:= kleur3p;
       temp3:= kleur3g;
       kleur3 := kleur2;
       kleur3p:= kleur2p;
       kleur3g:= kleur2g;
       kleur2 := temp;
       kleur2p:= temp2;
       kleur2g:= temp3;
      end;
      end;
    
      if(kleur2p > kleur1p)then
      begin
       temp:= kleur2;
       temp2:= kleur2p;
       temp3:= kleur2g;
       kleur2 := kleur1;
       kleur2p:= kleur1p;
       kleur2g:= kleur1g;
       kleur1 := temp;
       kleur1p:= temp2;
       kleur1g:= temp3;
      end;
      if(kleur2p = kleur1p)then
      begin
      if(kleur2g > kleur1g)then
      begin
       temp:= kleur2;
       temp2:= kleur2p;
       temp3:= kleur2g;
       kleur2 := kleur1;
       kleur2p:= kleur1p;
       kleur2g:= kleur1g;
       kleur1 := temp;
       kleur1p:= temp2;
       kleur1g:= temp3;
      end;
      end;
    
      CloseFile(myFile);
    
    
    end;
    end;
    end;
    end;
    ShowMessage(inttostr(kleur1p)+'/'+inttostr(kleur1));
    ShowMessage(inttostr(kleur2p)+'/'+inttostr(kleur2));
    ShowMessage(inttostr(kleur3p)+'/'+inttostr(kleur3));
    end;
    
    
    procedure TForm1.Button5Click(Sender: TObject);
    var
    myFile,myFile2 : TextFile;
    text   : string;
    master1, master2, delimiter, found1, found2 : string;
    i, j, K : integer;  //operating variables
    pixelkleur, pixelx, pixely: array[0..1000] of integer;
    aantal,regel, aantal2, aantal3: integer;
    selecs:integer;
    firstcolor, secondcolor:integer;
    firstx, secondx:integer;
    firsty, secondy:integer;
    gfirstcolor, gsecondcolor:integer;
    gfirstx, gsecondx:integer;
    gfirsty, gsecondy:integer;
    verschilx, verschily:integer;
    xt:integer;
    goed:integer;
    goedvorig,goedvorig2:integer;
    
    
    begin
    for selecs:=0 to numforma-1 do
    begin
    aantal:= 0;
    aantal2:= 0;
    aantal3:= 0;
    
    ChDir('C:\tmp\goed'+inttostr(selecs));
    AssignFile(myFile, inttostr(kleur1)+'.txt');
    Reset(myFile);
    
       regel:= 0;
      while not Eof(myFile) do
       begin
       ReadLn(myFile, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur1;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    CloseFile(myFile);
    AssignFile(myFile2, inttostr(kleur2)+'.txt');
    Reset(myFile2);
    
       regel:= 0;
      while not Eof(myFile2) do
       begin
       ReadLn(myFile2, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur2;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    
      CloseFile(myFile2);
      AssignFile(myFile, inttostr(kleur3)+'.txt');
    Reset(myFile);
    
       regel:= 0;
      while not Eof(myFile) do
       begin
       ReadLn(myFile, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur3;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    CloseFile(myFile);
      if(selecs= 0)then
      begin
      for i:=0 to aantal-1 do
      begin
       Form6.StringGrid1.RowCount:= aantal;
       Form6.StringGrid1.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid1.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid1.Cells[3,i] := inttostr(pixely[i]);
       end;
       end;
       if(selecs= 1)then
      begin
      for i:=0 to aantal-1 do
      begin
      Form6.StringGrid2.RowCount:= aantal;
       Form6.StringGrid2.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid2.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid2.Cells[3,i] := inttostr(pixely[i]);
       end;
       end;
       if(selecs= 2)then
      begin
      for i:=0 to aantal-1 do
      begin
      Form6.StringGrid3.RowCount:= aantal+aantal2+aantal3;
       Form6.StringGrid3.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid3.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid3.Cells[3,i] := inttostr(pixely[i]);
       end;
      end;
      end;
    
     for i:=0 to  Form6.StringGrid1.RowCount-2 do
     begin
     for J:=i+1 to  Form6.StringGrid1.RowCount-1 do
     begin
     firstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
     secondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
     firstx:= strtoint(Form6.StringGrid1.cells[2,i]);
     firsty:= strtoint(Form6.StringGrid1.cells[3,i]);
     secondx:= strtoint(Form6.StringGrid1.cells[2,j]);
     secondy:= strtoint(Form6.StringGrid1.cells[3,j]);
     verschilx:= secondx-firstx;
     verschily:= secondy-firsty;
    
      xt:=Form1.PageControl1.TabIndex+1;
      goed:= 0;
      for K:=0 to  Form6.StringGrid1.RowCount-1 do
     begin
     if(strtoint(Form6.StringGrid1.cells[1,K]) = firstcolor)then
     begin
     //kleur 1 is goed
     if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid1.cells[2,K]), strtoint(Form6.StringGrid1.cells[3,K])])then
     begin
     goed:= goed+1;
     end;
     end;
     end;
     goedvorig2:= goed;
     goed:= 0;
    
     for K:=0 to  Form6.StringGrid2.RowCount-1 do
     begin
     if(strtoint(Form6.StringGrid2.cells[1,K]) = firstcolor)then
     begin
     //kleur 1 is goed
     if(strtoint(Form6.StringGrid2.cells[2,K])+verschilx > 0)AND(strtoint(Form6.StringGrid2.cells[2,K])+verschilx < img[xt].Width)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily > 0)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily < img[xt].Height)then
     begin
     if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid2.cells[2,K])+verschilx, strtoint(Form6.StringGrid2.cells[3,K])+verschily])then
     begin
     goed:= goed+1;
     end;
     end;
     end;
     end;
     if(goedvorig2<goed)then goed:= goedvorig2;
     if(goed > goedvorig)then
     begin
     goedvorig:= goed;
     gfirstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
     gsecondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
     gfirstx:= strtoint(Form6.StringGrid1.cells[2,i]);
     gfirsty:= strtoint(Form6.StringGrid1.cells[3,i]);
     gsecondx:= strtoint(Form6.StringGrid1.cells[2,j]);
     gsecondy:= strtoint(Form6.StringGrid1.cells[3,j]);
     //ShowMessage('gelukt');
     end;
    
     end;
     end;
        ShowMessage(inttostr(goedvorig));
        Form6.StaticText1.Caption:= inttostr(gfirstcolor);
        Form6.StaticText2.Caption:= inttostr(gfirstx);
        Form6.StaticText3.Caption:= inttostr(gfirsty);
        Form6.StaticText4.Caption:= inttostr(gsecondx);
        Form6.StaticText5.Caption:= inttostr(gsecondy);
        Form6.StaticText6.Caption:= inttostr(gsecondcolor);
    
    end;
    
    
    
    end.
    i removed the other algoritmes.
    i don't expect you to understand what how it does because the names i use are a dutch and english mixed. sometimes not logical.
    Last edited by nielskool; 05-17-2010 at 11:08 PM.
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by nielskool View Post
    eej herman,

    i have to say it is a hell of a mess..:P
    and i started with other ways of searching for a dtm so there are 4 algorthmes in the app.. first 3 don't work, atleast not as i want it to.

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls, ExtCtrls, Menus, Buttons, ExtDlgs, Grids,
      ValEdit, ToolWin, Gauges, Mask;
    
    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Panel3: TPanel;
        PageControl1: TPageControl;
        Addb: TButton;
        delb: TButton;
        adds: TButton;
        dels: TButton;
        MainMenu1: TMainMenu;
        File1: TMenuItem;
        Exit1: TMenuItem;
        Help1: TMenuItem;
        Howtouse1: TMenuItem;
        About1: TMenuItem;
        New1: TMenuItem;
        Reset1: TMenuItem;
        Dtms1: TMenuItem;
        Makedtm1: TMenuItem;
        MakeDDTM1: TMenuItem;
        BitBtn1: TBitBtn;
        Edit1: TEdit;
        Label1: TLabel;
        OpenPictureDialog1: TOpenPictureDialog;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit5: TEdit;
        Edit6: TEdit;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Button1: TButton;
        Button2: TButton;
        CheckDTM1: TMenuItem;
        Checkcolor1: TMenuItem;
        GenerarteDTM1: TMenuItem;
        Credits1: TMenuItem;
        ValueListEditor1: TValueListEditor;
        Button4: TButton;
        Edit7: TEdit;
        Edit8: TEdit;
        Edit9: TEdit;
        Edit10: TEdit;
        Edit11: TEdit;
        Edit12: TEdit;
        Edit13: TEdit;
        ValueListEditor2: TValueListEditor;
        ValueListEditor3: TValueListEditor;
        Button6: TButton;
        StaticText1: TStaticText;
        BitBtn2: TBitBtn;
        Edit14: TEdit;
        Gauge1: TGauge;
        MaskEdit1: TMaskEdit;
        MaskEdit2: TMaskEdit;
        Button7: TButton;
        Button8: TButton;
        Button3: TButton;
        Button5: TButton;
        Label7: TLabel;
        procedure AddbClick(Sender: TObject);
        procedure PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure delbClick(Sender: TObject);
        procedure OpenPictureDialog1SelectionChange(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure BitBtn1Click(Sender: TObject);
        procedure About1Click(Sender: TObject);
        procedure Credits1Click(Sender: TObject);
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure Image1Mouseup(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
    
        procedure FormCreate(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure BitBtn2Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure Button7Click(Sender: TObject);
        procedure Button8Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
    
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      x : integer;
      im:boolean;
    tabSheetw : array[0..10] of TTabSheet;
    selec1x,selec1y,selec2x,selec2y : array[0..12] of integer;
    selec: array[0..12] of Tshape;
    img: array[0..10] of TImage;
    pixelsy, pixelsx: integer;
    scro: array[0..10] of TScrollBox;
    temparr , temparr2:array of integer;
      kleur1,kleur2,kleur3:integer;
      kleur1p,kleur2p,kleur3p:integer;
      kleur1g,kleur2g,kleur3g:integer;
    
    implementation
    
    uses Unit2, Unit3, Unit4, Math, Unit5, Unit6;
    var
     forma: array of TShape;    //Array to create
      formaUtil: Integer;        // Kind of shape
      Numforma: Integer;         //Number of shapes
      Izq, Arr, Ancho, alto, x1, x2, y1, y2: Integer; //Position and size of shape
      activar: Boolean;          //Tells when you are creating and sizing the shape
    
    
    {$R *.dfm}
    procedure TForm1.Image1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
      var
      xt:integer;
    begin
    formaUtil := 1;
    if formaUtil < 1 then Exit;
      activar  := True;
      xt:=Form1.PageControl1.TabIndex+1;
                   //starting draw the shape
      x1 := x+ img[xt].left;
      Edit10.text:= inttostr(x1);
      //ShowMessage(inttostr(x1));
      y1 := y+ img[xt].Top;
      Edit11.text:= inttostr(y1);
      //ShowMessage(inttostr(y1));
      numforma := numforma + 1;
      setlength(forma, numforma);
      forma[numforma - 1] := TShape.Create(TabSheetw[xt]);
        forma[numforma - 1].Pen.Mode:=pmNot;
        forma[numforma - 1].Pen.Width:=1;
        forma[numforma - 1].Pen.Color:=clBlack;
      if formaUtil = 1 then
        forma[numforma - 1].Shape :=stRectangle
      else
        forma[numforma - 1].Shape := stCircle;
      forma[numforma - 1].Left   := x1;
      forma[numforma - 1].Top    := y1;
      forma[numforma - 1].Parent := scro[xt];
      forma[numforma - 1].Width := 0;
      forma[numforma - 1].Height := 0;
      forma[numforma - 1].BringToFront;
    end;
    
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
      var                             
      xt:integer;
    begin
    xt:=Form1.PageControl1.TabIndex+1;
    Edit8.Text:= inttostr(x);
    Edit9.Text:= inttostr(y);
    Edit7.Color := img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top];
    Edit6.Text := inttostr(img[xt].Canvas.Pixels[x+img[xt].left, y+img[xt].Top]);
      if (formaUtil = 0) then Exit;
      if (numforma = 0) then Exit;
      if not activar then Exit;
      x2 := x+img[xt].left;
      Edit12.text:= inttostr(x2);
      y2 := y+img[xt].Top;
      Edit13.text:= inttostr(y2);
      forma[numforma - 1].Width := x2 - x1;
      forma[numforma - 1].Height := y2 - y1;
      StaticText1.Caption := IntToStr(numforma);
    end;
    
    procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
      var
      xt:integer;
    begin
    xt:=Form1.PageControl1.TabIndex+1;
      x2 := x+img[xt].left;
      //ShowMessage(inttostr(x2));
      y2 := y+img[xt].Top;
      //ShowMessage(inttostr(y2));
      forma[numforma - 1].Width := x2 - x1;
      forma[numforma - 1].Height := y2 - y1;
      formaUtil := 1;
      activar   := False;
      //form5.show;
      Form5.MaskEdit1.text := inttostr(forma[0].left);
      Form5.MaskEdit2.text := inttostr(forma[0].top);
      Form5.MaskEdit3.text := inttostr(forma[0].height);
      Form5.MaskEdit4.text := inttostr(forma[0].width);
    
    end;
    
    procedure TForm1.AddbClick(Sender: TObject);
    begin
    x:= pageControl1.PageCount+1;
    tabSheetw[x] := TTabSheet.Create(PageControl1) ;
    tabSheetw[x].PageControl := PageControl1;
    tabSheetw[x].Caption:= inttostr(pageControl1.PageCount);
    scro[x] := TScrollBox.Create(tabSheetw[x]);
    scro[x].Align := alClient;
    scro[x].Parent:= tabSheetw[x];
    scro[x].BorderStyle:=bsSingle;
    img[x] := TImage.Create(scro[x]);
    img[x].Parent := scro[x];
    img[x].OnMouseUp := Image1MouseUp;
    img[x].OnMouseDown := Image1MouseDown;
    img[x].OnMouseMove := Image1MouseMove;
    
    
    end;
    
    procedure setrechts();
    var
    x : integer;
    tabSheetw : array[0..10] of TTabSheet;
    begin
    end;
    
    procedure sorter();
    var i,j,temp, temp2,minIndex:integer;
    sortedstring:string;
    begin
    setlength(temparr2,high(temparr));
    for i:= low(temparr) to high(temparr) do
    begin
    temparr2[i] := strtoint(Form1.ValueListEditor2.Values[inttostr(temparr[i])]);
    end;
    
    for i:= 0 to length(temparr)-1 do
    begin
    	// zoek kleinste in de rest van de array
    	minIndex := i;
    	for j:=i to length(temparr2)do
      begin
    		if (temparr2[j] < temparr2[minIndex]) then
        begin
    			minIndex := j;
    		end;
    	end;
    
    	// verwissel waarden
    	temp := temparr[i];
    	temparr[i] := temparr[minIndex];
    	temparr[minIndex] := temp;
    
      temp := temparr2[i];
    	temparr2[i] := temparr2[minIndex];
    	temparr2[minIndex] := temp;
      //ShowMessage(inttostr(temparr[i]));
    
    
    end;
    end;
    
    
    procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    //setrechts();
    end;
    
    procedure TForm1.delbClick(Sender: TObject);
    begin
    x:= pageControl1.PageCount;
    tabSheetw[x].Destroy;
    end;
    
    procedure TForm1.OpenPictureDialog1SelectionChange(Sender: TObject);
    begin
    //Self.get
    //Self.Parent.image1.picture := Self.
    end;
    
    procedure TForm1.Button4Click(Sender: TObject);
    var
    Bitmap: TBitmap;
    x:integer;
    begin
    Bitmap := TBitmap.Create;
    if OpenPictureDialog1.Execute then
      begin
      x:= PageControl1.TabIndex+1;
      Bitmap.LoadFromFile(OpenPictureDialog1.FileName);
        img[x].Picture.LoadFromFile(OpenPictureDialog1.FileName);
        img[x].Width:= Bitmap.Width ;
        img[x].Height:= Bitmap.Height;
      end;
      Bitmap.Free;
    end;
    
    
    
    
    procedure TForm1.About1Click(Sender: TObject);
    begin
    About.show;
    end;
    
    procedure TForm1.Credits1Click(Sender: TObject);
    begin
    Credits.show;
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    formaUtil := 1;
      Numforma := 0;
      activar := False;
    end;
    
    
    
    
    
    
    
    procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
    Form4.ShowModal;
    end;
    
    
    
    procedure TForm1.Button8Click(Sender: TObject);
    var
      myFile : TextFile;
      text   : string;
      gkleur, fkleur: array[0..2550] of integer;
      rowcount: integer;
      xt:integer;
      startpixelcolor,pixel2color:integer;
      startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
      goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
      zoeky,zoekx,zoekx2,zoeky2:integer;
      tempprocent,tempprocent2,procent: variant;
      tempje,color: integer;
      color2: array[0..10000] of integer;
      startpixx,startpixy,startpixcol : integer;
      directory : string;
      selecs,tempje2,i, error:integer;
      bestaat: Boolean;
    
    begin
    xt:=Form1.PageControl1.TabIndex+1;
    tempje2:= 0;
    for zoeky2    := forma[0].top to forma[0].top+forma[0].Height-1 do
    begin
    for zoekx2    := forma[0].left to forma[0].left+forma[0].Width-1 do
    begin
    color2[tempje2] := img[xt].Canvas.Pixels[zoekx2, zoeky2];
    for i:=0 to tempje2-1 do
    begin
    if(color2[i] = color2[tempje2])then tempje2:= tempje2-1;
    end;
    tempje2:= tempje2+1;
    end;
    end;
    //tempje2:= 0;
    ShowMessage(inttostr(tempje2));
    
    
    for zoeky    := img[xt].top to img[xt].top+img[xt].Height-1 do
    begin
    for zoekx    := img[xt].left to img[xt].left+img[xt].width-1 do
    begin
    Gauge1.Progress:= floor((zoeky*img[xt].width+zoekx)/(img[xt].Height*img[xt].Width)*100);
    color:= img[xt].Canvas.Pixels[zoekx, zoeky];
    bestaat := false;
    for i:=0 to tempje2-1 do
    begin
    if(color2[i] = color)then bestaat:= true;
    end;
    if(bestaat)then begin
    CreateDir('C:\tmp\fout');
    ChDir('C:\tmp\fout');
    for selecs:=0 to numforma-1 do
    begin
    if(zoekx >= forma[selecs].left) AND (zoekx <= forma[selecs].left+forma[selecs].width) AND (zoeky >= forma[selecs].top) AND (zoeky <= forma[selecs].top+forma[selecs].height)then
     begin
      CreateDir('C:\tmp\goed'+inttostr(selecs));
      ChDir('C:\tmp\goed'+inttostr(selecs));
     end;
    end;
    
     AssignFile(myFile, inttostr(color)+'.txt');
     if FileExists(inttostr(color)+'.txt') then
       Append(myFile)
       else
       begin
          Rewrite(myFile);
          WriteLn(myFile, color);
          WriteLn(myFile, '1');
       end;
       WriteLn(myFile, '['+inttostr(zoekx)+', '+inttostr(zoeky)+']');
    
       // Close the file
       CloseFile(myFile);
    
    
    
    
    
    end;
    end;
    end;
    
    
    end;
    
    
    procedure TForm1.Button3Click(Sender: TObject);
    var
      myFile : TextFile;
      text   : string;
      rowcount: integer;
      temp,temp2,temp3: integer;
      xt:integer;
      startpixelcolor,pixel2color:integer;
      startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
      goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
      zoeky,zoekx:integer;
      tempprocent,tempprocent2,procent: variant;
      tempje,color: integer;
      startpixx,startpixy,startpixcol,regel,fout : integer;
      directory : string;
      selecs, selecs2:integer;
      verwijder:Boolean;
    
    begin
    kleur1:= 0;
    kleur2:= 0;
    kleur3:= 0;
    xt:=Form1.PageControl1.TabIndex+1;
    CreateDir('C:\tmp\berekend');
    ChDir('C:\tmp\berekend');
    for zoeky    := forma[0].top to forma[0].top+forma[0].Height-1 do
    begin
    for zoekx    := forma[0].left to forma[0].left+forma[0].Width-1 do
    begin
    Gauge1.Progress:= floor((zoeky*forma[0].width+zoekx)/(forma[0].Height*forma[0].Width)*100);
    color:= img[xt].Canvas.Pixels[zoekx, zoeky];
      verwijder:= false;
      for selecs:=0 to numforma-1 do
      begin
      ChDir('C:\tmp\goed'+inttostr(selecs));
      if not FileExists(inttostr(color)+'.txt') then
    begin
       for selecs2:=0 to numforma-1 do
      begin
       ChDir('C:\tmp\goed'+inttostr(selecs2));
       If(FileExists(inttostr(color)+'.txt'))then
       DeleteFile(inttostr(color)+'.txt');
      end;
      ChDir('C:\tmp\berekend');
      If(FileExists(inttostr(color)+'.txt'))then
      DeleteFile(inttostr(color)+'.txt');
      verwijder:= true;
    
    end;
    
      end;
    if(verwijder = false)then
    begin
    ChDir('C:\tmp\berekend');
    if not FileExists(inttostr(color)+'.txt') then
    begin
    CreateDir('C:\tmp\fout');
    ChDir('C:\tmp\fout');
    if FileExists(inttostr(color)+'.txt') then
    begin
    AssignFile(myFile, inttostr(color)+'.txt');
    Reset(myFile);
    regel:= 0;
    fout:= 0;
    
      while not Eof(myFile) do
       begin
       fout:= fout+1;
       ReadLn(myFile, text);
    
      end;
      CloseFile(myFile);
      end;
      //000000
      temp:= 99999999;
      //bestaat := 1;
    
      for selecs:=0 to numforma-1 do
      begin
    ChDir('C:\tmp\goed'+inttostr(selecs));
    if FileExists(inttostr(color)+'.txt') then
    begin
    AssignFile(myFile, inttostr(color)+'.txt');
    Reset(myFile);
    regel:= 0;
    
      while not Eof(myFile) do
       begin
       regel:= regel+1;
       ReadLn(myFile, text);
    
      end;
      CloseFile(myFile);
      if(temp > regel)then temp:= regel;
      end;
      regel:= temp;
      //000000
      end;
      if(regel =  99999999)then regel:= 0;
      CreateDir('C:\tmp\berekend');
      ChDir('C:\tmp\berekend');
      AssignFile(myFile, inttostr(color)+'.txt');
      Rewrite(myFile);
      if(regel >2)then
      begin
      regel:= regel-2;
      if(fout >=0)AND(fout < 3)then
      fout:=0 else
      fout:= fout -2;
      end;
      if(regel > 5)AND(regel+fout <> 0)then  //5 staat voor minimaal aantal
      procent:= floor(regel/(regel+fout)*100) else procent:= 0;
      WriteLn(myFile, inttostr(regel));
      WriteLn(myFile, inttostr(fout));
      WriteLn(myFile, inttostr(procent));
     if(procent > kleur3p)then
     begin
      if(kleur3 = 0)then
      begin
        if(kleur2 = 0)then
        begin
          if(kleur1 = 0)then
          begin
          kleur1 := color;
          kleur1p := procent;
          kleur1g := regel;
          end else
          begin
          kleur2 := color;
          kleur2p := procent;
          kleur2g := regel;
          end;
        end else
        begin
        kleur1 := color;
        kleur1p := procent;
        kleur1g := regel;
        end;
      end;
    
     end;
    
      if(procent > kleur3p)then
      begin
       kleur3 := color;
       kleur3p:= procent;
       kleur3g:= regel;
      end;
      if(procent = kleur3p)then
      begin
      if(regel > kleur3g)then
      begin
       kleur3 := color;
       kleur3p:= procent;
       kleur3g:= regel;
      end;
      end;
    
       if(kleur3p > kleur2p)then
      begin
       temp:= kleur3;
       temp2:= kleur3p;
       temp3:= kleur3g;
       kleur3 := kleur2;
       kleur3p:= kleur2p;
       kleur3g:= kleur2g;
       kleur2 := temp;
       kleur2p:= temp2;
       kleur2g:= temp3;
      end;
      if(kleur3p = kleur2p)then
      begin
      if(kleur3g > kleur2g)then
      begin
       temp:= kleur3;
       temp2:= kleur3p;
       temp3:= kleur3g;
       kleur3 := kleur2;
       kleur3p:= kleur2p;
       kleur3g:= kleur2g;
       kleur2 := temp;
       kleur2p:= temp2;
       kleur2g:= temp3;
      end;
      end;
    
      if(kleur2p > kleur1p)then
      begin
       temp:= kleur2;
       temp2:= kleur2p;
       temp3:= kleur2g;
       kleur2 := kleur1;
       kleur2p:= kleur1p;
       kleur2g:= kleur1g;
       kleur1 := temp;
       kleur1p:= temp2;
       kleur1g:= temp3;
      end;
      if(kleur2p = kleur1p)then
      begin
      if(kleur2g > kleur1g)then
      begin
       temp:= kleur2;
       temp2:= kleur2p;
       temp3:= kleur2g;
       kleur2 := kleur1;
       kleur2p:= kleur1p;
       kleur2g:= kleur1g;
       kleur1 := temp;
       kleur1p:= temp2;
       kleur1g:= temp3;
      end;
      end;
    
      CloseFile(myFile);
    
    
    end;
    end;
    end;
    end;
    ShowMessage(inttostr(kleur1p)+'/'+inttostr(kleur1));
    ShowMessage(inttostr(kleur2p)+'/'+inttostr(kleur2));
    ShowMessage(inttostr(kleur3p)+'/'+inttostr(kleur3));
    end;
    
    
    procedure TForm1.Button5Click(Sender: TObject);
    var
    myFile,myFile2 : TextFile;
    text   : string;
    master1, master2, delimiter, found1, found2 : string;
    i, j, K : integer;  //operating variables
    pixelkleur, pixelx, pixely: array[0..1000] of integer;
    aantal,regel, aantal2, aantal3: integer;
    selecs:integer;
    firstcolor, secondcolor:integer;
    firstx, secondx:integer;
    firsty, secondy:integer;
    gfirstcolor, gsecondcolor:integer;
    gfirstx, gsecondx:integer;
    gfirsty, gsecondy:integer;
    verschilx, verschily:integer;
    xt:integer;
    goed:integer;
    goedvorig,goedvorig2:integer;
    
    
    begin
    for selecs:=0 to numforma-1 do
    begin
    aantal:= 0;
    aantal2:= 0;
    aantal3:= 0;
    
    ChDir('C:\tmp\goed'+inttostr(selecs));
    AssignFile(myFile, inttostr(kleur1)+'.txt');
    Reset(myFile);
    
       regel:= 0;
      while not Eof(myFile) do
       begin
       ReadLn(myFile, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur1;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    CloseFile(myFile);
    AssignFile(myFile2, inttostr(kleur2)+'.txt');
    Reset(myFile2);
    
       regel:= 0;
      while not Eof(myFile2) do
       begin
       ReadLn(myFile2, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur2;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    
      CloseFile(myFile2);
      AssignFile(myFile, inttostr(kleur3)+'.txt');
    Reset(myFile);
    
       regel:= 0;
      while not Eof(myFile) do
       begin
       ReadLn(myFile, text);
       regel:= regel+1;
       if(regel > 2)then
       begin
       delimiter :='[';
        master1:= text;
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ',';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found1 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        delimiter :=',';
        i:= pos(delimiter, master1);     //Step 1-2
        if i > 0 then
         begin
           master2 := master1;
           delete(master2,i,1);   // Step 3
           delimiter := ']';
           j:= pos(delimiter, master2);   //Step 4
           if j > 0 then
             begin
               j := j +1;
               found2 :=  copy(master1,(i+1),(j-i-1)); //Step 5
             end
           else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
         end
        else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
        pixelkleur[aantal] := kleur3;
        pixelx[aantal] := strtoint(found1);
        pixely[aantal] := strtoint(found2);
        aantal := aantal+1;
    
    
       end;
      end;
    CloseFile(myFile);
      if(selecs= 0)then
      begin
      for i:=0 to aantal-1 do
      begin
       Form6.StringGrid1.RowCount:= aantal;
       Form6.StringGrid1.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid1.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid1.Cells[3,i] := inttostr(pixely[i]);
       end;
       end;
       if(selecs= 1)then
      begin
      for i:=0 to aantal-1 do
      begin
      Form6.StringGrid2.RowCount:= aantal;
       Form6.StringGrid2.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid2.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid2.Cells[3,i] := inttostr(pixely[i]);
       end;
       end;
       if(selecs= 2)then
      begin
      for i:=0 to aantal-1 do
      begin
      Form6.StringGrid3.RowCount:= aantal+aantal2+aantal3;
       Form6.StringGrid3.Cells[1,i] := inttostr(pixelkleur[i]);
       Form6.StringGrid3.Cells[2,i] := inttostr(pixelx[i]);
       Form6.StringGrid3.Cells[3,i] := inttostr(pixely[i]);
       end;
      end;
      end;
    
     for i:=0 to  Form6.StringGrid1.RowCount-2 do
     begin
     for J:=i+1 to  Form6.StringGrid1.RowCount-1 do
     begin
     firstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
     secondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
     firstx:= strtoint(Form6.StringGrid1.cells[2,i]);
     firsty:= strtoint(Form6.StringGrid1.cells[3,i]);
     secondx:= strtoint(Form6.StringGrid1.cells[2,j]);
     secondy:= strtoint(Form6.StringGrid1.cells[3,j]);
     verschilx:= secondx-firstx;
     verschily:= secondy-firsty;
    
      xt:=Form1.PageControl1.TabIndex+1;
      goed:= 0;
      for K:=0 to  Form6.StringGrid1.RowCount-1 do
     begin
     if(strtoint(Form6.StringGrid1.cells[1,K]) = firstcolor)then
     begin
     //kleur 1 is goed
     if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid1.cells[2,K]), strtoint(Form6.StringGrid1.cells[3,K])])then
     begin
     goed:= goed+1;
     end;
     end;
     end;
     goedvorig2:= goed;
     goed:= 0;
    
     for K:=0 to  Form6.StringGrid2.RowCount-1 do
     begin
     if(strtoint(Form6.StringGrid2.cells[1,K]) = firstcolor)then
     begin
     //kleur 1 is goed
     if(strtoint(Form6.StringGrid2.cells[2,K])+verschilx > 0)AND(strtoint(Form6.StringGrid2.cells[2,K])+verschilx < img[xt].Width)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily > 0)AND(strtoint(Form6.StringGrid2.cells[3,K])+verschily < img[xt].Height)then
     begin
     if(secondcolor = img[xt].Canvas.Pixels[strtoint(Form6.StringGrid2.cells[2,K])+verschilx, strtoint(Form6.StringGrid2.cells[3,K])+verschily])then
     begin
     goed:= goed+1;
     end;
     end;
     end;
     end;
     if(goedvorig2<goed)then goed:= goedvorig2;
     if(goed > goedvorig)then
     begin
     goedvorig:= goed;
     gfirstcolor:= strtoint(Form6.StringGrid1.cells[1,i]);
     gsecondcolor:= strtoint(Form6.StringGrid1.cells[1,j]);
     gfirstx:= strtoint(Form6.StringGrid1.cells[2,i]);
     gfirsty:= strtoint(Form6.StringGrid1.cells[3,i]);
     gsecondx:= strtoint(Form6.StringGrid1.cells[2,j]);
     gsecondy:= strtoint(Form6.StringGrid1.cells[3,j]);
     //ShowMessage('gelukt');
     end;
    
     end;
     end;
        ShowMessage(inttostr(goedvorig));
        Form6.StaticText1.Caption:= inttostr(gfirstcolor);
        Form6.StaticText2.Caption:= inttostr(gfirstx);
        Form6.StaticText3.Caption:= inttostr(gfirsty);
        Form6.StaticText4.Caption:= inttostr(gsecondx);
        Form6.StaticText5.Caption:= inttostr(gsecondy);
        Form6.StaticText6.Caption:= inttostr(gsecondcolor);
    
    end;
    
    
    
    end.
    i removed the other algoritmes.
    i don't expect you to understand what how it does because the names i use are a dutch and english mixed. sometimes not logical.
    First of all my name is Hermen.
    Second part of it is: I am also dutch.
    Last part, Imma going to check it our for you.

    Edit:
    Can you please send me the folder containing ALL files, because this is just unit1?
    ~Hermen

  6. #6
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok
    wait..
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  7. #7
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Use someting like www.uppit.com
    ~Hermen

  8. #8
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    just tryed my program on a evergreen tree(to start with)
    found a dtm of 2 pixels. finds all evergreen trees and as far as i know nothing else.
    does anyone have somethings he can't make a good dtm of.. tell me and il try
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  9. #9
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    The Youtube clip looks pretty impressive

  10. #10
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks, hope to improve it this week. i've got a week before my next exam is.
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  11. #11
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    The Youtube clip looks pretty impressive
    It indeed looks pretty cool!



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  12. #12
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I don't think I've ever seen a DTM work for main screen object finding.

  13. #13
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    This looks way to cool, you need to compile this to an exe

  14. #14
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    You should make this into an extension for Simba
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  15. #15
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i think i will. hmm i made this with delphi first thing todo when it is finished is to find out how extensions work with simba and more important whic language
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  16. #16
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    I don't think I've ever seen a DTM work for main screen object finding.
    In my old Varrock East miner, I used ALL dtms to find the iron rocks. That was back with the old jagged rocks with uniform color, though. Worked great. Very accurate and fast.

    I think I only needed 2 dtms to find all 4 iron rock, IIRC.


  17. #17
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    This looks sweet!

  18. #18
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by nielskool View Post
    i think i will. hmm i made this with delphi first thing todo when it is finished is to find out how extensions work with simba and more important whic language
    Simba plugins use delphi, so its your lucky day!

  19. #19
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by MylesMadness View Post
    Simba plugins use delphi, so its your lucky day!
    Actually, they use FPC ,but Delphi should work in most cases.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  20. #20
    Join Date
    Feb 2006
    Location
    Pennsylvania
    Posts
    1,524
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    And if not Simba is open source for a reason

  21. #21
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Update:

    Not limited to two selections anymore.
    Convert the points to a DTM string (DTMlib of nielsie95)
    Better sorting of the colors(second level sorting)

    Todo:

    Extend points from 2 to user set
    Use all colors greater than 90%(user editable) for dtm search
    Use all best colors until the pixel amount is greater than 400(user editable) for dtm search

    And at the end: add tolerance.
    Maybe area but i think it wil slowdown the search about 10 times
    tolerance would also slow it down but if done properly than it won't be much.
    With a bit luck it isn't even needed. If it is needed it will work because tolerance gives so much extra accuracy in combination with more points.

    there is only one problem... i don't know the way tolerance works with those color numbers
    Last edited by nielskool; 05-18-2010 at 11:05 PM.
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  22. #22
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nielskool View Post
    there is only one problem... i don't know the way tolerance works with those color numbers
    See the Simba source...



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  23. #23
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, that was my first option
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  24. #24
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i've got some bad news and good news:P

    i made some improvements to the script to be more accurate, but it made the script also 40-80 times slower.

    i think i know a solution to this problem but therefor i need to find a way to script something.

    to be continued...:P
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

  25. #25
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    189
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe some of you can help me with it:

    First i wanted to put every color of the image into an array. but than the array'ss length would me like 10 million!
    This gave me stack overflow. based on this i made something that saves every color in a map, every color got his own txt file.
    In this file are the coordinates of that color stored.

    Well first of all to open each, read each file and edit each file takes alot of time.
    So how do i store the colors of the image properly in the memory?

    //Edit
    Hmm maybe I kan make an array with al the colors numbers the picture has.
    Then make an array of an array with the x cordinats.
    And an arrar of an array with the y coordinates.
    Hmm then the array would be like this:
    array1 = [1221,135525,1233322,993,0]
    array2[0][11] = color 1221 with x coordinate 11
    array3[1][67] = color 135525 with y coordinate 67

    Hmm that would solve allot i guess

    /Edit2

    is color:= array[10];
    faster than
    color:= TImage.Canvas.Pixels[x, y] ?
    Last edited by nielskool; 05-19-2010 at 10:06 PM.
    We merely play "against the rules". We cheat. Thats what we are good at, thats what we do.
    http://www.frement.net/srl/simba_user4.png

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •